| Index: src/gpu/SkGpuDevice.cpp
|
| diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
|
| index a86170b75e1aa88bba07f670fa4ba87b31a4048a..59b659656f66d9b3233005618ea00fa61580e4d8 100644
|
| --- a/src/gpu/SkGpuDevice.cpp
|
| +++ b/src/gpu/SkGpuDevice.cpp
|
| @@ -372,6 +372,29 @@ GrPixelConfig config8888_to_grconfig_and_flags(SkCanvas::Config8888 config8888,
|
| }
|
| }
|
|
|
| +#ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
|
| +void SkGpuDevice::writePixels(const SkBitmap& bitmap, int x, int y,
|
| + SkCanvas::Config8888 config8888) {
|
| + SkAutoLockPixels alp(bitmap);
|
| + if (!bitmap.readyToDraw()) {
|
| + return;
|
| + }
|
| +
|
| + GrPixelConfig config;
|
| + uint32_t flags;
|
| + if (SkBitmap::kARGB_8888_Config == bitmap.config()) {
|
| + config = config8888_to_grconfig_and_flags(config8888, &flags);
|
| + } else {
|
| + flags = 0;
|
| + config= SkBitmapConfig2GrPixelConfig(bitmap.config());
|
| + }
|
| +
|
| + fRenderTarget->writePixels(x, y, bitmap.width(), bitmap.height(),
|
| + config, bitmap.getPixels(), bitmap.rowBytes(), flags);
|
| +}
|
| +#endif
|
| +
|
| +#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
|
| bool SkGpuDevice::onReadPixels(const SkBitmap& bitmap,
|
| int x, int y,
|
| SkCanvas::Config8888 config8888) {
|
| @@ -379,7 +402,7 @@ bool SkGpuDevice::onReadPixels(const SkBitmap& bitmap,
|
| SkASSERT(SkBitmap::kARGB_8888_Config == bitmap.config());
|
| SkASSERT(!bitmap.isNull());
|
| SkASSERT(SkIRect::MakeWH(this->width(), this->height()).contains(SkIRect::MakeXYWH(x, y, bitmap.width(), bitmap.height())));
|
| -
|
| +
|
| SkAutoLockPixels alp(bitmap);
|
| GrPixelConfig config;
|
| uint32_t flags;
|
| @@ -393,28 +416,25 @@ bool SkGpuDevice::onReadPixels(const SkBitmap& bitmap,
|
| bitmap.rowBytes(),
|
| flags);
|
| }
|
| +#endif
|
|
|
| -#ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
|
| -void SkGpuDevice::writePixels(const SkBitmap& bitmap, int x, int y,
|
| - SkCanvas::Config8888 config8888) {
|
| - SkAutoLockPixels alp(bitmap);
|
| - if (!bitmap.readyToDraw()) {
|
| - return;
|
| - }
|
| +bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
|
| + int x, int y) {
|
| + DO_DEFERRED_CLEAR();
|
|
|
| - GrPixelConfig config;
|
| - uint32_t flags;
|
| - if (SkBitmap::kARGB_8888_Config == bitmap.config()) {
|
| - config = config8888_to_grconfig_and_flags(config8888, &flags);
|
| - } else {
|
| - flags = 0;
|
| - config= SkBitmapConfig2GrPixelConfig(bitmap.config());
|
| + // TODO: teach fRenderTarget to take ImageInfo directly to specify the src pixels
|
| + GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo.colorType(), dstInfo.alphaType());
|
| + if (kUnknown_GrPixelConfig == config) {
|
| + return false;
|
| }
|
|
|
| - fRenderTarget->writePixels(x, y, bitmap.width(), bitmap.height(),
|
| - config, bitmap.getPixels(), bitmap.rowBytes(), flags);
|
| + uint32_t flags = 0;
|
| + if (kUnpremul_SkAlphaType == dstInfo.alphaType()) {
|
| + flags = GrContext::kUnpremul_PixelOpsFlag;
|
| + }
|
| + return fContext->readRenderTargetPixels(fRenderTarget, x, y, dstInfo.width(), dstInfo.height(),
|
| + config, dstPixels, dstRowBytes, flags);
|
| }
|
| -#endif
|
|
|
| bool SkGpuDevice::onWritePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes,
|
| int x, int y) {
|
|
|