diff options
Diffstat (limited to 'include/gpu')
-rw-r--r-- | include/gpu/GrContext.h | 21 | ||||
-rw-r--r-- | include/gpu/GrSurface.h | 42 | ||||
-rw-r--r-- | include/gpu/GrTexture.h | 85 |
3 files changed, 31 insertions, 117 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 45cd599132..366fba993e 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -1082,7 +1082,7 @@ private: * Gets and locks a scratch texture from a descriptor using either exact or approximate criteria. * Unlocks texture in the destructor. */ -class GrAutoScratchTexture : public ::SkNoncopyable { +class SK_API GrAutoScratchTexture : public ::SkNoncopyable { public: GrAutoScratchTexture() : fContext(NULL) @@ -1121,24 +1121,7 @@ public: * Note that the caller is assumed to accept and manage the ref to the * returned texture. */ - GrTexture* detach() { - if (NULL == fTexture) { - return NULL; - } - GrTexture* texture = fTexture; - fTexture = NULL; - - // This GrAutoScratchTexture has a ref from lockAndRefScratchTexture, which we give up now. - // The cache also has a ref which we are lending to the caller of detach(). When the caller - // lets go of the ref and the ref count goes to 0 internal_dispose will see this flag is - // set and re-ref the texture, thereby restoring the cache's ref. - SkASSERT(!texture->unique()); - texture->impl()->setFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit); - texture->unref(); - SkASSERT(texture->getCacheEntry()); - - return texture; - } + GrTexture* detach(); GrTexture* set(GrContext* context, const GrTextureDesc& desc, diff --git a/include/gpu/GrSurface.h b/include/gpu/GrSurface.h index 24eb39a81b..23311a2f52 100644 --- a/include/gpu/GrSurface.h +++ b/include/gpu/GrSurface.h @@ -11,11 +11,12 @@ #include "GrTypes.h" #include "GrGpuResource.h" +#include "SkImageInfo.h" #include "SkRect.h" -class GrTexture; class GrRenderTarget; -struct SkImageInfo; +class GrSurfacePriv; +class GrTexture; class GrSurface : public GrGpuResource { public: @@ -59,8 +60,6 @@ public: */ const GrTextureDesc& desc() const { return fDesc; } - SkImageInfo info() const; - /** * @return the texture associated with the surface, may be NULL. */ @@ -74,22 +73,6 @@ public: virtual const GrRenderTarget* asRenderTarget() const = 0; /** - * Checks whether this GrSurface refers to the same GPU object as other. This - * catches the case where a GrTexture and GrRenderTarget refer to the same - * GPU memory. - */ - bool isSameAs(const GrSurface* other) const { - const GrRenderTarget* thisRT = this->asRenderTarget(); - if (thisRT) { - return thisRT == other->asRenderTarget(); - } else { - const GrTexture* thisTex = this->asTexture(); - SkASSERT(thisTex); // We must be one or the other - return thisTex == other->asTexture(); - } - } - - /** * Reads a rectangle of pixels from the surface. * @param left left edge of the rectangle to read (inclusive) * @param top top edge of the rectangle to read (inclusive) @@ -129,17 +112,22 @@ public: size_t rowBytes = 0, uint32_t pixelOpsFlags = 0) = 0; - /** - * Write the contents of the surface to a PNG. Returns true if successful. - * @param filename Full path to desired file - */ - bool savePixels(const char* filename); + /** Access methods that are only to be used within Skia code. */ + inline GrSurfacePriv surfacePriv(); + inline const GrSurfacePriv surfacePriv() const; +protected: + // Methods made available via GrSurfacePriv + SkImageInfo info() const; + bool savePixels(const char* filename); bool hasPendingRead() const; bool hasPendingWrite() const; bool hasPendingIO() const; + bool isSameAs(const GrSurface* other) const; + + // Provides access to methods that should be public within Skia code. + friend class GrSurfacePriv; -protected: GrSurface(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc) : INHERITED(gpu, isWrapped) , fDesc(desc) { @@ -151,4 +139,4 @@ private: typedef GrGpuResource INHERITED; }; -#endif // GrSurface_DEFINED +#endif diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h index 06ba2e4108..8bdff34df5 100644 --- a/include/gpu/GrTexture.h +++ b/include/gpu/GrTexture.h @@ -16,7 +16,7 @@ class GrResourceKey; class GrTextureParams; -class GrTextureImpl; +class GrTexturePriv; class GrTexture : public GrSurface { public: @@ -44,19 +44,6 @@ public: virtual const GrRenderTarget* asRenderTarget() const SK_OVERRIDE { return fRenderTarget.get(); } /** - * Convert from texels to normalized texture coords for POT textures only. Please don't add - * new callsites for these functions. They are slated for removal. - */ - SkFixed normalizeFixedX(SkFixed x) const { - SkASSERT(SkIsPow2(fDesc.fWidth)); - return x >> fShiftFixedX; - } - SkFixed normalizeFixedY(SkFixed y) const { - SkASSERT(SkIsPow2(fDesc.fHeight)); - return y >> fShiftFixedY; - } - - /** * Return the native ID or handle to the texture, depending on the * platform. e.g. on OpenGL, return the texture ID. */ @@ -67,11 +54,9 @@ public: * changed externally to Skia. */ virtual void textureParamsModified() = 0; - SK_ATTR_DEPRECATED("Renamed to textureParamsModified.") - void invalidateCachedState() { this->textureParamsModified(); } /** - * Informational texture flags. This will be moved to the private GrTextureImpl class soon. + * Informational texture flags. This will be removed soon. */ enum FlagBits { kFirstBit = (kLastPublic_GrTextureFlagBit << 1), @@ -94,21 +79,16 @@ public: } #endif - GrTextureImpl* impl() { return reinterpret_cast<GrTextureImpl*>(this); } - const GrTextureImpl* impl() const { return reinterpret_cast<const GrTextureImpl*>(this); } + /** Access methods that are only to be used within Skia code. */ + inline GrTexturePriv texturePriv(); + inline const GrTexturePriv texturePriv() const; protected: // A texture refs its rt representation but not vice-versa. It is up to // the subclass constructor to initialize this pointer. SkAutoTUnref<GrRenderTarget> fRenderTarget; - GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc) - : INHERITED(gpu, isWrapped, desc) - , fRenderTarget(NULL) { - // only make sense if alloc size is pow2 - fShiftFixedX = 31 - SkCLZ(fDesc.fWidth); - fShiftFixedY = 31 - SkCLZ(fDesc.fHeight); - } + GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc); virtual ~GrTexture(); @@ -121,60 +101,23 @@ protected: private: void abandonReleaseCommon(); virtual void internal_dispose() const SK_OVERRIDE; - - // these two shift a fixed-point value into normalized coordinates - // for this texture if the texture is power of two sized. - int fShiftFixedX; - int fShiftFixedY; - - typedef GrSurface INHERITED; -}; - -class GrTextureImpl : public GrTexture { -public: - SK_DECLARE_INST_COUNT(GrTextureImpl) - - void setFlag(GrTextureFlags flags) { - fDesc.fFlags = fDesc.fFlags | flags; - } - void resetFlag(GrTextureFlags flags) { - fDesc.fFlags = fDesc.fFlags & ~flags; - } - bool isSetFlag(GrTextureFlags flags) const { - return 0 != (fDesc.fFlags & flags); - } - void dirtyMipMaps(bool mipMapsDirty); - bool mipMapsAreDirty() const { - return kValid_MipMapsStatus != fMipMapsStatus; - } - - bool hasMipMaps() const { - return kNotAllocated_MipMapsStatus != fMipMapsStatus; - } - - static GrResourceKey ComputeKey(const GrGpu* gpu, - const GrTextureParams* params, - const GrTextureDesc& desc, - const GrCacheID& cacheID); - static GrResourceKey ComputeScratchKey(const GrTextureDesc& desc); - static bool NeedsResizing(const GrResourceKey& key); - static bool NeedsBilerp(const GrResourceKey& key); - -protected: - GrTextureImpl(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc); - -private: enum MipMapsStatus { kNotAllocated_MipMapsStatus, kAllocated_MipMapsStatus, kValid_MipMapsStatus }; - MipMapsStatus fMipMapsStatus; + MipMapsStatus fMipMapsStatus; + // These two shift a fixed-point value into normalized coordinates + // for this texture if the texture is power of two sized. + int fShiftFixedX; + int fShiftFixedY; + + friend class GrTexturePriv; - typedef GrTexture INHERITED; + typedef GrSurface INHERITED; }; /** |