diff options
author | Android Chromium Automerger <chromium-automerger@android> | 2014-05-06 07:27:39 +0000 |
---|---|---|
committer | Android Chromium Automerger <chromium-automerger@android> | 2014-05-06 07:27:39 +0000 |
commit | 0b927f282c03b81323a41c7ef3558b93b435924f (patch) | |
tree | 6cf24983bbc94a08b0db9ff2f7353be254e36b1d | |
parent | fe1bfbf8bcc440a04ca20051e75f95a411e36bf8 (diff) | |
parent | abc68a8eeb478a8123d4d283bab5088d0bb949f9 (diff) | |
download | include-0b927f282c03b81323a41c7ef3558b93b435924f.tar.gz |
Merge third_party/skia/include from https://chromium.googlesource.com/external/skia/include.git at abc68a8eeb478a8123d4d283bab5088d0bb949f9
This commit was generated by merge_from_chromium.py.
Change-Id: Ia575c4a48fa4dfb8fca42fba218c13c3fa56b1c3
-rw-r--r-- | core/SkColorPriv.h | 9 | ||||
-rw-r--r-- | gpu/GrCacheable.h | 8 | ||||
-rw-r--r-- | gpu/GrContext.h | 11 | ||||
-rw-r--r-- | gpu/GrTexture.h | 22 |
4 files changed, 39 insertions, 11 deletions
diff --git a/core/SkColorPriv.h b/core/SkColorPriv.h index 9591f22..d5571df 100644 --- a/core/SkColorPriv.h +++ b/core/SkColorPriv.h @@ -181,6 +181,15 @@ static inline unsigned SkAlpha255To256(U8CPU alpha) { return alpha + 1; } +/** + * Turn a 0..255 value into a 0..256 value, rounding up if the value is >= 0x80. + * This is slightly more accurate than SkAlpha255To256. + */ +static inline unsigned Sk255To256(U8CPU value) { + SkASSERT(SkToU8(value) == value); + return value + (value >> 7); +} + /** Multiplify value by 0..256, and shift the result down 8 (i.e. return (value * alpha256) >> 8) */ diff --git a/gpu/GrCacheable.h b/gpu/GrCacheable.h index 75dec16..39c62b1 100644 --- a/gpu/GrCacheable.h +++ b/gpu/GrCacheable.h @@ -46,6 +46,14 @@ protected: bool isInCache() const { return NULL != fCacheEntry; } + /** + * This entry point should be called whenever gpuMemorySize() begins + * reporting a different size. If the object is in the cache, it will call + * gpuMemorySize() immediately and pass the new size on to the resource + * cache. + */ + void didChangeGpuMemorySize() const; + private: GrResourceCacheEntry* fCacheEntry; // NULL if not in cache diff --git a/gpu/GrContext.h b/gpu/GrContext.h index 4d0a94e..195ab72 100644 --- a/gpu/GrContext.h +++ b/gpu/GrContext.h @@ -899,6 +899,17 @@ public: GrPathRendererChain::DrawType drawType = GrPathRendererChain::kColor_DrawType, GrPathRendererChain::StencilSupport* stencilSupport = NULL); + /** + * Stores a custom resource in the cache, based on the specified key. + */ + void addResourceToCache(const GrResourceKey&, GrCacheable*); + + /** + * Finds a resource in the cache, based on the specified key. This is intended for use in + * conjunction with addResourceToCache(). The return value will be NULL if not found. The + * caller must balance with a call to unref(). + */ + GrCacheable* findAndRefCachedResource(const GrResourceKey&); #if GR_CACHE_STATS void printCacheStats() const; diff --git a/gpu/GrTexture.h b/gpu/GrTexture.h index 1b9f7b7..ac31f51 100644 --- a/gpu/GrTexture.h +++ b/gpu/GrTexture.h @@ -44,22 +44,16 @@ public: return 0 != (fDesc.fFlags & flags); } - void dirtyMipMaps(bool mipMapsDirty) { - fMipMapsDirty = mipMapsDirty; - } + void dirtyMipMaps(bool mipMapsDirty); bool mipMapsAreDirty() const { - return fMipMapsDirty; + return kValid_MipMapsStatus != fMipMapsStatus; } /** * Approximate number of bytes used by the texture */ - virtual size_t gpuMemorySize() const SK_OVERRIDE { - return (size_t) fDesc.fWidth * - fDesc.fHeight * - GrBytesPerPixel(fDesc.fConfig); - } + virtual size_t gpuMemorySize() const SK_OVERRIDE; // GrSurface overrides virtual bool readPixels(int left, int top, int width, int height, @@ -144,7 +138,7 @@ protected: GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc) : INHERITED(gpu, isWrapped, desc) , fRenderTarget(NULL) - , fMipMapsDirty(true) { + , fMipMapsStatus(kNotAllocated_MipMapsStatus) { // only make sense if alloc size is pow2 fShiftFixedX = 31 - SkCLZ(fDesc.fWidth); @@ -159,12 +153,18 @@ protected: void validateDesc() const; private: + enum MipMapsStatus { + kNotAllocated_MipMapsStatus, + kAllocated_MipMapsStatus, + kValid_MipMapsStatus + }; + // 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; - bool fMipMapsDirty; + MipMapsStatus fMipMapsStatus; virtual void internal_dispose() const SK_OVERRIDE; |