aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2016-11-28 09:26:31 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-28 14:58:41 +0000
commit3b66ab6f9fdc6eacdf0ee1921da28751de30c018 (patch)
treee81d2a52f48030084c53260a0d3b1bcf0463c96c /src/gpu
parent781c3c14629342ed3eb00d153822c751406ad80b (diff)
GrTextureProducer cleanup, phase one: Bitmap and Image makers
Split these into their own files, and actually name the files after the classes they contain. The top three classes in the hierarchy still need attention, but those are going to be trickier. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5195 Change-Id: I295f4d50e35748eac38a31f302e14b5b62653c55 Reviewed-on: https://skia-review.googlesource.com/5195 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrBitmapTextureMaker.cpp (renamed from src/gpu/GrImageIDTextureAdjuster.cpp)56
-rw-r--r--src/gpu/GrBitmapTextureMaker.h38
-rw-r--r--src/gpu/GrImageTextureMaker.cpp62
-rw-r--r--src/gpu/GrImageTextureMaker.h (renamed from src/gpu/GrImageIDTextureAdjuster.h)33
-rw-r--r--src/gpu/SkGpuDevice.cpp5
-rw-r--r--src/gpu/SkGr.cpp4
6 files changed, 111 insertions, 87 deletions
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"