/* * Copyright 2015 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkImage_Gpu_DEFINED #define SkImage_Gpu_DEFINED #include "GrClip.h" #include "GrGpuResourcePriv.h" #include "GrSurfaceProxyPriv.h" #include "GrTexture.h" #include "SkAtomics.h" #include "SkBitmap.h" #include "SkGr.h" #include "SkImagePriv.h" #include "SkImage_Base.h" #include "SkSurface.h" class SkImage_Gpu : public SkImage_Base { public: SkImage_Gpu(uint32_t uniqueID, SkAlphaType, sk_sp, sk_sp, SkBudgeted); SkImage_Gpu(GrContext*, uint32_t uniqueID, SkAlphaType, sk_sp, sk_sp, SkBudgeted); ~SkImage_Gpu() override; SkImageInfo onImageInfo() const override; SkAlphaType onAlphaType() const override { return fAlphaType; } bool getROPixels(SkBitmap*, SkColorSpace* dstColorSpace, CachingHint) const override; GrTexture* asTextureRef(GrContext*, const GrSamplerParams&, SkColorSpace*, sk_sp*, SkScalar scaleAdjust[2]) const override; sk_sp onMakeSubset(const SkIRect&) const override; GrTexture* peekTexture() const override { return fProxy->instantiate(fContext->resourceProvider()); } sk_sp asTextureProxyRef() const override { return fProxy; } sk_sp asTextureProxyRef(GrContext*, const GrSamplerParams&, SkColorSpace*, sk_sp*, SkScalar scaleAdjust[2]) const override; sk_sp refPinnedTexture(uint32_t* uniqueID) const override { *uniqueID = this->uniqueID(); return sk_ref_sp(this->peekTexture()); } bool onReadYUV8Planes(const SkISize sizes[3], void* const planes[3], const size_t rowBytes[3], SkYUVColorSpace colorSpace) const override; bool onReadPixels(const SkImageInfo&, void* dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint) const override; GrContext* context() { return fContext; } sk_sp refColorSpace() { return fColorSpace; } sk_sp onMakeColorSpace(sk_sp) const override; private: GrContext* fContext; sk_sp fProxy; const SkAlphaType fAlphaType; const SkBudgeted fBudgeted; sk_sp fColorSpace; mutable SkAtomic fAddedRasterVersionToCache; typedef SkImage_Base INHERITED; }; #endif