aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/SkGr.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-11-09 11:55:57 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-09 11:55:57 -0800
commitc55271f2551533b37043aa2e37f754832a43073c (patch)
tree5e9729a4c8fe05519805b97db38621efbc34956a /src/gpu/SkGr.cpp
parent3a210bfd403815bebbc7efabe7bbd373e5a3d8f8 (diff)
Separate out natively-texture image/bmp draws from cached-as-texture image/bmp draws
This makes texture-backed images and bitmaps down a new code path. It adds a pinch point via the texture adjuster that will be used to handle copied necessary for different texture targets. It also fixes bugs in the existing code exhibited by recent updates to the bleed GM. The plan is to move the the sw/generator-backed imgs/bmps on to this code path with future changes. Review URL: https://codereview.chromium.org/1424313010
Diffstat (limited to 'src/gpu/SkGr.cpp')
-rw-r--r--src/gpu/SkGr.cpp39
1 files changed, 5 insertions, 34 deletions
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 469ef5bbe2..540edb6a38 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -12,6 +12,7 @@
#include "GrContext.h"
#include "GrTextureParamsAdjuster.h"
#include "GrGpuResourcePriv.h"
+#include "GrImageIDTextureAdjuster.h"
#include "GrXferProcessor.h"
#include "GrYUVProvider.h"
@@ -271,7 +272,7 @@ GrTexture* GrUploadBitmapToTexture(GrContext* ctx, const SkBitmap& bmp) {
////////////////////////////////////////////////////////////////////////////////
-static void install_bmp_key_invalidator(const GrUniqueKey& key, SkPixelRef* pixelRef) {
+void GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey& key, SkPixelRef* pixelRef) {
class Invalidator : public SkPixelRef::GenIDChangeListener {
public:
explicit Invalidator(const GrUniqueKey& key) : fMsg(key) {}
@@ -313,7 +314,7 @@ protected:
tex = GrUploadBitmapToTexture(ctx, fBitmap);
if (tex && fOriginalKey.isValid()) {
tex->resourcePriv().setUniqueKey(fOriginalKey);
- install_bmp_key_invalidator(fOriginalKey, fBitmap.pixelRef());
+ GrInstallBitmapUniqueKeyInvalidator(fOriginalKey, fBitmap.pixelRef());
}
return tex;
}
@@ -325,7 +326,7 @@ protected:
}
void didCacheCopy(const GrUniqueKey& copyKey) override {
- install_bmp_key_invalidator(copyKey, fBitmap.pixelRef());
+ GrInstallBitmapUniqueKeyInvalidator(copyKey, fBitmap.pixelRef());
}
private:
@@ -335,40 +336,10 @@ private:
typedef GrTextureMaker INHERITED;
};
-class TextureBitmap_GrTextureAdjuster : public GrTextureAdjuster {
-public:
- explicit TextureBitmap_GrTextureAdjuster(const SkBitmap* bmp)
- : INHERITED(bmp->getTexture(), SkIRect::MakeWH(bmp->width(), bmp->height()))
- , fBmp(bmp) {}
-
-private:
- void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) override {
- 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 didCacheCopy(const GrUniqueKey& copyKey) override {
- install_bmp_key_invalidator(copyKey, fBmp->pixelRef());
- }
-
- const SkBitmap* fBmp;
-
- typedef GrTextureAdjuster INHERITED;
-};
-
GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap,
const GrTextureParams& params) {
if (bitmap.getTexture()) {
- return TextureBitmap_GrTextureAdjuster(&bitmap).refTextureSafeForParams(params, nullptr);
+ return GrBitmapTextureAdjuster(&bitmap).refTextureSafeForParams(params, nullptr);
}
return RasterBitmap_GrTextureMaker(bitmap).refTextureForParams(ctx, params);
}