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

Unified Diff: src/core/SkBitmapDevice.cpp

Issue 533323002: Use SkBitmapCache to optimize readPixels on a texture-backed bitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase master Created 6 years, 3 months 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 | « no previous file | src/gpu/SkGrPixelRef.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapDevice.cpp
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 44ce2173a34b4800cfdf319b4f262638538a48b1..0d6c4fcd7696702095ed69c3362c1a447626b83a 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -145,6 +145,7 @@ void* SkBitmapDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) {
}
#include "SkConfig8888.h"
+#include "SkPixelRef.h"
bool SkBitmapDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPixels,
size_t srcRowBytes, int x, int y) {
@@ -261,8 +262,14 @@ void SkBitmapDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
// the bitmap, we extract a subset.
SkIRect srcIR;
tmpSrc.roundOut(&srcIR);
- if (!bitmap.extractSubset(&tmpBitmap, srcIR)) {
- return;
+ if(bitmap.pixelRef()->getTexture()) {
+ // Accelerated source canvas, don't use extractSubset but readPixels to get the subset.
+ // This way, the pixels are copied in CPU memory instead of GPU memory.
+ bitmap.pixelRef()->readPixels(&tmpBitmap, &srcIR);
+ } else {
+ if (!bitmap.extractSubset(&tmpBitmap, srcIR)) {
+ return;
+ }
}
bitmapPtr = &tmpBitmap;
« no previous file with comments | « no previous file | src/gpu/SkGrPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698