1 /* 2 * Copyright 2023 Google LLC 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkImage_RasterPinnable_DEFINED 9 #define SkImage_RasterPinnable_DEFINED 10 11 #include "include/core/SkTypes.h" 12 #include "include/private/gpu/ganesh/GrTypesPriv.h" 13 #include "src/gpu/ganesh/GrSurfaceProxyView.h" 14 #include "src/image/SkImage_Base.h" 15 #include "src/image/SkImage_Raster.h" 16 17 #include <cstdint> 18 #include <memory> 19 #include <tuple> 20 21 class GrRecordingContext; 22 class SkBitmap; 23 enum class GrImageTexGenPolicy : int; 24 25 namespace skgpu { 26 enum class Mipmapped : bool; 27 } 28 29 struct PinnedData { 30 GrSurfaceProxyView fPinnedView; 31 int32_t fPinnedCount = 0; 32 uint32_t fPinnedUniqueID = SK_InvalidUniqueID; 33 uint32_t fPinnedContextID = SK_InvalidUniqueID; 34 GrColorType fPinnedColorType = GrColorType::kUnknown; 35 }; 36 37 class SkImage_RasterPinnable final : public SkImage_Raster { 38 public: SkImage_RasterPinnable(const SkBitmap & bm)39 SkImage_RasterPinnable(const SkBitmap& bm) 40 : SkImage_Raster(bm, /*bitmapMayBeMutable = */ true) {} 41 42 std::tuple<GrSurfaceProxyView, GrColorType> asView(GrRecordingContext*, 43 skgpu::Mipmapped, 44 GrImageTexGenPolicy) const; 45 type()46 SkImage_Base::Type type() const override { return SkImage_Base::Type::kRasterPinnable; } 47 48 std::unique_ptr<PinnedData> fPinnedData; 49 }; 50 51 #endif 52