diff options
-rw-r--r-- | gn/gpu.gni | 6 | ||||
-rw-r--r-- | src/core/SkImageCacherator.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrBitmapTextureMaker.cpp (renamed from src/gpu/GrImageIDTextureAdjuster.cpp) | 56 | ||||
-rw-r--r-- | src/gpu/GrBitmapTextureMaker.h | 38 | ||||
-rw-r--r-- | src/gpu/GrImageTextureMaker.cpp | 62 | ||||
-rw-r--r-- | src/gpu/GrImageTextureMaker.h (renamed from src/gpu/GrImageIDTextureAdjuster.h) | 33 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 5 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 4 | ||||
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 3 | ||||
-rw-r--r-- | src/image/SkImage_Raster.cpp | 2 |
10 files changed, 119 insertions, 92 deletions
diff --git a/gn/gpu.gni b/gn/gpu.gni index 1779f7f5b2..caa7fa170a 100644 --- a/gn/gpu.gni +++ b/gn/gpu.gni @@ -75,6 +75,8 @@ skia_gpu_sources = [ "$_src/gpu/GrBatchFlushState.h", "$_src/gpu/GrBatchTest.cpp", "$_src/gpu/GrBatchTest.h", + "$_src/gpu/GrBitmapTextureMaker.cpp", + "$_src/gpu/GrBitmapTextureMaker.h", "$_src/gpu/GrBlend.cpp", "$_src/gpu/GrBlurUtils.cpp", "$_src/gpu/GrBlurUtils.h", @@ -106,8 +108,8 @@ skia_gpu_sources = [ "$_src/gpu/GrGpuResource.cpp", "$_src/gpu/GrGpuFactory.cpp", "$_src/gpu/GrGpuFactory.h", - "$_src/gpu/GrImageIDTextureAdjuster.cpp", - "$_src/gpu/GrImageIDTextureAdjuster.h", + "$_src/gpu/GrImageTextureMaker.cpp", + "$_src/gpu/GrImageTextureMaker.h", "$_src/gpu/GrInvariantOutput.cpp", "$_src/gpu/GrMemoryPool.cpp", "$_src/gpu/GrMemoryPool.h", diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp index 157cea2bef..c614139487 100644 --- a/src/core/SkImageCacherator.cpp +++ b/src/core/SkImageCacherator.cpp @@ -18,7 +18,7 @@ #if SK_SUPPORT_GPU #include "GrContext.h" #include "GrGpuResourcePriv.h" -#include "GrImageIDTextureAdjuster.h" +#include "GrImageTextureMaker.h" #include "GrResourceKey.h" #include "GrSamplerParams.h" #include "GrYUVProvider.h" diff --git a/src/gpu/GrImageIDTextureAdjuster.cpp b/src/gpu/GrBitmapTextureMaker.cpp index 645d1c2a99..0f26e51e91 100644 --- a/src/gpu/GrImageIDTextureAdjuster.cpp +++ b/src/gpu/GrBitmapTextureMaker.cpp @@ -1,26 +1,23 @@ /* - * Copyright 2015 Google Inc. + * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include "GrImageIDTextureAdjuster.h" +#include "GrBitmapTextureMaker.h" #include "GrContext.h" #include "GrGpuResourcePriv.h" #include "SkBitmap.h" #include "SkGrPriv.h" -#include "SkImage_Base.h" -#include "SkImageCacherator.h" #include "SkPixelRef.h" static bool bmp_is_alpha_only(const SkBitmap& bm) { return kAlpha_8_SkColorType == bm.colorType(); } GrBitmapTextureMaker::GrBitmapTextureMaker(GrContext* context, const SkBitmap& bitmap) : INHERITED(context, bitmap.width(), bitmap.height(), bmp_is_alpha_only(bitmap)) - , fBitmap(bitmap) -{ + , fBitmap(bitmap) { if (!bitmap.isVolatile()) { SkIPoint origin = bitmap.pixelRefOrigin(); SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, bitmap.width(), @@ -72,50 +69,3 @@ sk_sp<SkColorSpace> GrBitmapTextureMaker::getColorSpace(SkDestinationSurfaceColo // Color space doesn't depend on mode - it's just whatever is in the bitmap return sk_ref_sp(fBitmap.colorSpace()); } - -////////////////////////////////////////////////////////////////////////////// -static bool cacher_is_alpha_only(const SkImageCacherator& cacher) { - return kAlpha_8_SkColorType == cacher.info().colorType(); -} -GrImageTextureMaker::GrImageTextureMaker(GrContext* context, SkImageCacherator* cacher, - const SkImage* client, SkImage::CachingHint chint) - : INHERITED(context, cacher->info().width(), cacher->info().height(), - cacher_is_alpha_only(*cacher)) - , fCacher(cacher) - , fClient(client) - , fCachingHint(chint) { - if (client) { - GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), - SkIRect::MakeWH(this->width(), this->height())); - } -} - -GrTexture* GrImageTextureMaker::refOriginalTexture(bool willBeMipped, - SkDestinationSurfaceColorMode colorMode) { - return fCacher->lockTexture(this->context(), fOriginalKey, fClient, fCachingHint, willBeMipped, - colorMode); -} - -void GrImageTextureMaker::makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey, - SkDestinationSurfaceColorMode colorMode) { - if (fOriginalKey.isValid() && SkImage::kAllow_CachingHint == fCachingHint) { - SkImageCacherator::CachedFormat cacheFormat = - fCacher->chooseCacheFormat(colorMode, this->context()->caps()); - GrUniqueKey cacheKey; - fCacher->makeCacheKeyFromOrigKey(fOriginalKey, cacheFormat, &cacheKey); - MakeCopyKeyFromOrigKey(cacheKey, stretch, paramsCopyKey); - } -} - -void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { - if (fClient) { - as_IB(fClient)->notifyAddedToCache(); - } -} - -SkAlphaType GrImageTextureMaker::alphaType() const { - return fCacher->info().alphaType(); -} -sk_sp<SkColorSpace> GrImageTextureMaker::getColorSpace(SkDestinationSurfaceColorMode colorMode) { - return fCacher->getColorSpace(this->context(), colorMode); -} diff --git a/src/gpu/GrBitmapTextureMaker.h b/src/gpu/GrBitmapTextureMaker.h new file mode 100644 index 0000000000..f66f20ce56 --- /dev/null +++ b/src/gpu/GrBitmapTextureMaker.h @@ -0,0 +1,38 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrBitmapTextureMaker_DEFINED +#define GrBitmapTextureMaker_DEFINED + +#include "GrTextureParamsAdjuster.h" + +/** This class manages the conversion of SW-backed bitmaps to GrTextures. If the input bitmap is + non-volatile the texture is cached using a key created from the pixels' image id and the + subset of the pixelref specified by the bitmap. */ +class GrBitmapTextureMaker : public GrTextureMaker { +public: + GrBitmapTextureMaker(GrContext* context, const SkBitmap& bitmap); + +protected: + GrTexture* refOriginalTexture(bool willBeMipped, SkDestinationSurfaceColorMode) override; + + void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey, + SkDestinationSurfaceColorMode colorMode) override; + + void didCacheCopy(const GrUniqueKey& copyKey) override; + + SkAlphaType alphaType() const override; + sk_sp<SkColorSpace> getColorSpace(SkDestinationSurfaceColorMode) override; + +private: + const SkBitmap fBitmap; + GrUniqueKey fOriginalKey; + + typedef GrTextureMaker INHERITED; +}; + +#endif diff --git a/src/gpu/GrImageTextureMaker.cpp b/src/gpu/GrImageTextureMaker.cpp new file mode 100644 index 0000000000..f4a311955d --- /dev/null +++ b/src/gpu/GrImageTextureMaker.cpp @@ -0,0 +1,62 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "GrImageTextureMaker.h" + +#include "GrContext.h" +#include "GrGpuResourcePriv.h" +#include "SkGrPriv.h" +#include "SkImage_Base.h" +#include "SkImageCacherator.h" +#include "SkPixelRef.h" + +static bool cacher_is_alpha_only(const SkImageCacherator& cacher) { + return kAlpha_8_SkColorType == cacher.info().colorType(); +} + +GrImageTextureMaker::GrImageTextureMaker(GrContext* context, SkImageCacherator* cacher, + const SkImage* client, SkImage::CachingHint chint) + : INHERITED(context, cacher->info().width(), cacher->info().height(), + cacher_is_alpha_only(*cacher)) + , fCacher(cacher) + , fClient(client) + , fCachingHint(chint) { + if (client) { + GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), + SkIRect::MakeWH(this->width(), this->height())); + } +} + +GrTexture* GrImageTextureMaker::refOriginalTexture(bool willBeMipped, + SkDestinationSurfaceColorMode colorMode) { + return fCacher->lockTexture(this->context(), fOriginalKey, fClient, fCachingHint, willBeMipped, + colorMode); +} + +void GrImageTextureMaker::makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey, + SkDestinationSurfaceColorMode colorMode) { + if (fOriginalKey.isValid() && SkImage::kAllow_CachingHint == fCachingHint) { + SkImageCacherator::CachedFormat cacheFormat = + fCacher->chooseCacheFormat(colorMode, this->context()->caps()); + GrUniqueKey cacheKey; + fCacher->makeCacheKeyFromOrigKey(fOriginalKey, cacheFormat, &cacheKey); + MakeCopyKeyFromOrigKey(cacheKey, stretch, paramsCopyKey); + } +} + +void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { + if (fClient) { + as_IB(fClient)->notifyAddedToCache(); + } +} + +SkAlphaType GrImageTextureMaker::alphaType() const { + return fCacher->info().alphaType(); +} +sk_sp<SkColorSpace> GrImageTextureMaker::getColorSpace(SkDestinationSurfaceColorMode colorMode) { + return fCacher->getColorSpace(this->context(), colorMode); +} diff --git a/src/gpu/GrImageIDTextureAdjuster.h b/src/gpu/GrImageTextureMaker.h index ad54331092..b156fabf7a 100644 --- a/src/gpu/GrImageIDTextureAdjuster.h +++ b/src/gpu/GrImageTextureMaker.h @@ -1,45 +1,18 @@ /* - * Copyright 2015 Google Inc. + * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#ifndef GrImageIDTextureAdjuster_DEFINED -#define GrImageIDTextureAdjuster_DEFINED +#ifndef GrImageTextureMaker_DEFINED +#define GrImageTextureMaker_DEFINED #include "GrTextureParamsAdjuster.h" #include "SkImage.h" -class SkBitmap; -class SkImage_Base; class SkImageCacherator; -/** This class manages the conversion of SW-backed bitmaps to GrTextures. If the input bitmap is - non-volatile the texture is cached using a key created from the pixels' image id and the - subset of the pixelref specified by the bitmap. */ -class GrBitmapTextureMaker : public GrTextureMaker { -public: - GrBitmapTextureMaker(GrContext* context, const SkBitmap& bitmap); - -protected: - GrTexture* refOriginalTexture(bool willBeMipped, SkDestinationSurfaceColorMode) override; - - void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey, - SkDestinationSurfaceColorMode colorMode) override; - - void didCacheCopy(const GrUniqueKey& copyKey) override; - - SkAlphaType alphaType() const override; - sk_sp<SkColorSpace> getColorSpace(SkDestinationSurfaceColorMode) override; - -private: - const SkBitmap fBitmap; - GrUniqueKey fOriginalKey; - - typedef GrTextureMaker INHERITED; -}; - /** This class manages the conversion of generator-backed images to GrTextures. If the caching hint is kAllow the image's ID is used for the cache key. */ class GrImageTextureMaker : public GrTextureMaker { diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 04147f6870..aae3b95ffb 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -7,11 +7,12 @@ #include "SkGpuDevice.h" +#include "GrBitmapTextureMaker.h" #include "GrBlurUtils.h" #include "GrContext.h" -#include "GrRenderTargetContextPriv.h" #include "GrGpu.h" -#include "GrImageIDTextureAdjuster.h" +#include "GrImageTextureMaker.h" +#include "GrRenderTargetContextPriv.h" #include "GrStyle.h" #include "GrTracing.h" diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 1319102150..c8eaac03e6 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -9,11 +9,11 @@ #include "SkGr.h" #include "SkGrPriv.h" +#include "GrBitmapTextureMaker.h" #include "GrCaps.h" #include "GrContext.h" -#include "GrRenderTargetContext.h" #include "GrGpuResourcePriv.h" -#include "GrImageIDTextureAdjuster.h" +#include "GrRenderTargetContext.h" #include "GrTextureParamsAdjuster.h" #include "GrTexturePriv.h" #include "GrTypes.h" diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 02f4d69519..780bfbe4bf 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -10,10 +10,11 @@ #include <type_traits> #include "SkAutoPixmapStorage.h" +#include "GrBitmapTextureMaker.h" #include "GrCaps.h" #include "GrContext.h" +#include "GrImageTextureMaker.h" #include "GrRenderTargetContext.h" -#include "GrImageIDTextureAdjuster.h" #include "GrTexturePriv.h" #include "effects/GrYUVEffect.h" #include "SkCanvas.h" diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp index dcc60c3e65..6fc03b2dce 100644 --- a/src/image/SkImage_Raster.cpp +++ b/src/image/SkImage_Raster.cpp @@ -17,7 +17,7 @@ #if SK_SUPPORT_GPU #include "GrContext.h" -#include "GrImageIDTextureAdjuster.h" +#include "GrTextureParamsAdjuster.h" #include "SkGr.h" #include "SkGrPriv.h" #endif |