Make SkBitmap::CopyTo respect requested dst color type when bitmap is texture backed.
BUG=chromium:550559
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1576983002
Review URL: https://codereview.chromium.org/1576983002
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index c66a5b2..bdf1daa 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -828,7 +828,7 @@
SkIRect subset;
subset.setXYWH(fPixelRefOrigin.fX, fPixelRefOrigin.fY,
fInfo.width(), fInfo.height());
- if (fPixelRef->readPixels(&tmpSrc, &subset)) {
+ if (fPixelRef->readPixels(&tmpSrc, dstColorType, &subset)) {
if (fPixelRef->info().alphaType() == kUnpremul_SkAlphaType) {
// FIXME: The only meaningful implementation of readPixels
// (GrPixelRef) assumes premultiplied pixels.
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 1b9130a..a7ca7b7 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -286,7 +286,7 @@
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);
+ bitmap.pixelRef()->readPixels(&tmpBitmap, kN32_SkColorType, &srcIR);
} else {
if (!bitmap.extractSubset(&tmpBitmap, srcIR)) {
return;
diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp
index d711761..0825760 100644
--- a/src/core/SkPixelRef.cpp
+++ b/src/core/SkPixelRef.cpp
@@ -307,13 +307,13 @@
fMutability = kMutable;
}
-bool SkPixelRef::readPixels(SkBitmap* dst, const SkIRect* subset) {
- return this->onReadPixels(dst, subset);
+bool SkPixelRef::readPixels(SkBitmap* dst, SkColorType ct, const SkIRect* subset) {
+ return this->onReadPixels(dst, ct, subset);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
-bool SkPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) {
+bool SkPixelRef::onReadPixels(SkBitmap* dst, SkColorType, const SkIRect* subset) {
return false;
}