Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Unified Diff: src/gpu/GrImageIDTextureAdjuster.cpp

Issue 1424313010: Separate out natively-texture image/bmp draws from cached-as-texture image/bmp draws (Closed) Base URL: https://skia.googlesource.com/skia.git@const
Patch Set: update Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrImageIDTextureAdjuster.h ('k') | src/gpu/GrStrokeInfo.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrImageIDTextureAdjuster.cpp
diff --git a/src/gpu/GrImageIDTextureAdjuster.cpp b/src/gpu/GrImageIDTextureAdjuster.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..525223cf7773470025de2981d4f43d57cd4d3202
--- /dev/null
+++ b/src/gpu/GrImageIDTextureAdjuster.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2015 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 "SkBitmap.h"
+#include "SkGrPriv.h"
+#include "SkImage_Base.h"
+
+
+GrBitmapTextureAdjuster::GrBitmapTextureAdjuster(const SkBitmap* bmp)
+ : INHERITED(bmp->getTexture(), SkIRect::MakeWH(bmp->width(), bmp->height()))
+ , fBmp(bmp) {}
+
+void GrBitmapTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) {
+ if (fBmp->isVolatile()) {
+ return;
+ }
+ // The content area must represent the whole bitmap. Texture-backed bitmaps don't support
+ // extractSubset(). Therefore, either the bitmap and the texture are the same size or the
+ // content's dimensions are the bitmap's dimensions which is pinned to the upper left
+ // of the texture.
+ GrUniqueKey baseKey;
+ GrMakeKeyFromImageID(&baseKey, fBmp->getGenerationID(),
+ SkIRect::MakeWH(fBmp->width(), fBmp->height()));
+ MakeCopyKeyFromOrigKey(baseKey, params, copyKey);
+}
+
+void GrBitmapTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) {
+ GrInstallBitmapUniqueKeyInvalidator(copyKey, fBmp->pixelRef());
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+GrImageTextureAdjuster::GrImageTextureAdjuster(const SkImage_Base* img)
+ : INHERITED(img->peekTexture(), SkIRect::MakeWH(img->width(), img->height()))
+ , fImageBase(img) {}
+
+void GrImageTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) {
+ // By construction this texture adjuster always represents an entire SkImage, so use the
+ // image's width and height for the key's rectangle.
+ GrUniqueKey baseKey;
+ GrMakeKeyFromImageID(&baseKey, fImageBase->uniqueID(),
+ SkIRect::MakeWH(fImageBase->width(), fImageBase->height()));
+ MakeCopyKeyFromOrigKey(baseKey, params, copyKey);
+}
+
+void GrImageTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) {
+ // We don't currently have a mechanism for notifications on Images!
+}
« no previous file with comments | « src/gpu/GrImageIDTextureAdjuster.h ('k') | src/gpu/GrStrokeInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698