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

Unified Diff: src/gpu/SkGrPixelRef.cpp

Issue 1576983002: Make SkBitmap::CopyTo respect requested dst color type when bitmap is texture backed. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix size_t warnings Created 4 years, 11 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 | « src/core/SkPixelRef.cpp ('k') | tests/BitmapCopyTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGrPixelRef.cpp
diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp
index 6e014feded1faba16afb4b0607349857a6172ce0..58f516a19c6d3ad370456fcb0ad8a24fcd23b182 100644
--- a/src/gpu/SkGrPixelRef.cpp
+++ b/src/gpu/SkGrPixelRef.cpp
@@ -25,7 +25,7 @@ SkROLockPixelsPixelRef::~SkROLockPixelsPixelRef() {}
bool SkROLockPixelsPixelRef::onNewLockPixels(LockRec* rec) {
fBitmap.reset();
// SkDebugf("---------- calling readpixels in support of lockpixels\n");
- if (!this->onReadPixels(&fBitmap, nullptr)) {
+ if (!this->onReadPixels(&fBitmap, this->info().colorType(), nullptr)) {
SkDebugf("SkROLockPixelsPixelRef::onLockPixels failed!\n");
return false;
}
@@ -155,11 +155,20 @@ static bool tryAllocBitmapPixels(SkBitmap* bitmap) {
}
}
-bool SkGrPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) {
+bool SkGrPixelRef::onReadPixels(SkBitmap* dst, SkColorType colorType, const SkIRect* subset) {
if (nullptr == fSurface || fSurface->wasDestroyed()) {
return false;
}
+ GrPixelConfig config;
+ if (kRGBA_8888_SkColorType == colorType) {
+ config = kRGBA_8888_GrPixelConfig;
+ } else if (kBGRA_8888_SkColorType == colorType) {
+ config = kBGRA_8888_GrPixelConfig;
+ } else {
+ return false;
+ }
+
SkIRect bounds;
if (subset) {
bounds = *subset;
@@ -172,7 +181,9 @@ bool SkGrPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) {
//Cache miss
SkBitmap cachedBitmap;
- cachedBitmap.setInfo(this->info().makeWH(bounds.width(), bounds.height()));
+ cachedBitmap.setInfo(SkImageInfo::Make(bounds.width(), bounds.height(), colorType,
+ this->info().alphaType(),
+ this->info().profileType()));
// If we can't alloc the pixels, then fail
if (!tryAllocBitmapPixels(&cachedBitmap)) {
@@ -183,8 +194,7 @@ bool SkGrPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) {
void* buffer = cachedBitmap.getPixels();
bool readPixelsOk = fSurface->readPixels(bounds.fLeft, bounds.fTop,
bounds.width(), bounds.height(),
- kSkia8888_GrPixelConfig,
- buffer, cachedBitmap.rowBytes());
+ config, buffer, cachedBitmap.rowBytes());
if (!readPixelsOk) {
return false;
« no previous file with comments | « src/core/SkPixelRef.cpp ('k') | tests/BitmapCopyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698