1 /* 2 * Copyright 2021 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 skgpu_graphite_Image_Graphite_DEFINED 9 #define skgpu_graphite_Image_Graphite_DEFINED 10 11 #include "src/gpu/graphite/Image_Base_Graphite.h" 12 13 #include "src/gpu/graphite/TextureProxyView.h" 14 15 namespace skgpu { 16 class RefCntedCallback; 17 } 18 19 namespace skgpu::graphite { 20 21 class Context; 22 class Recorder; 23 24 class Image final : public Image_Base { 25 public: 26 Image(uint32_t uniqueID, TextureProxyView, const SkColorInfo&); 27 Image(TextureProxyView, const SkColorInfo&); 28 ~Image() override; 29 onHasMipmaps()30 bool onHasMipmaps() const override { 31 return fTextureProxyView.proxy()->mipmapped() == skgpu::Mipmapped::kYes; 32 } 33 34 using Image_Base::onMakeSubset; 35 36 sk_sp<SkImage> onReinterpretColorSpace(sk_sp<SkColorSpace>) const override; 37 textureProxyView()38 TextureProxyView textureProxyView() const { return fTextureProxyView; } 39 40 static sk_sp<TextureProxy> MakePromiseImageLazyProxy(SkISize dimensions, 41 TextureInfo, 42 Volatile, 43 GraphitePromiseImageFulfillProc, 44 sk_sp<RefCntedCallback>, 45 GraphitePromiseTextureReleaseProc); 46 47 private: 48 sk_sp<SkImage> onMakeTextureImage(Recorder*, RequiredImageProperties) const override; 49 sk_sp<SkImage> copyImage(const SkIRect& subset, Recorder*, RequiredImageProperties) const; 50 sk_sp<SkImage> onMakeSubset(const SkIRect&, Recorder*, RequiredImageProperties) const override; 51 using Image_Base::onMakeColorTypeAndColorSpace; 52 sk_sp<SkImage> onMakeColorTypeAndColorSpace(SkColorType targetCT, 53 sk_sp<SkColorSpace> targetCS, 54 Recorder*, 55 RequiredImageProperties) const override; 56 57 TextureProxyView fTextureProxyView; 58 }; 59 60 } // namespace skgpu::graphite 61 62 #endif // skgpu_graphite_Image_Graphite_DEFINED 63