| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkAutoPixmapStorage.h" | 8 #include "SkAutoPixmapStorage.h" |
| 9 #include "GrCaps.h" | 9 #include "GrCaps.h" |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 for (int y = 0; y < info.height(); ++y) { | 104 for (int y = 0; y < info.height(); ++y) { |
| 105 for (int x = 0; x < info.width(); ++x) { | 105 for (int x = 0; x < info.width(); ++x) { |
| 106 row[x] = SkPreMultiplyColor(row[x]); | 106 row[x] = SkPreMultiplyColor(row[x]); |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 bool SkImage_Gpu::onReadPixels(const SkImageInfo& info, void* pixels, size_t row
Bytes, | 111 bool SkImage_Gpu::onReadPixels(const SkImageInfo& info, void* pixels, size_t row
Bytes, |
| 112 int srcX, int srcY, CachingHint) const { | 112 int srcX, int srcY, CachingHint) const { |
| 113 GrPixelConfig config = SkImageInfo2GrPixelConfig(info.colorType(), info.alph
aType(), | 113 GrPixelConfig config = SkImageInfo2GrPixelConfig(info.colorType(), info.alph
aType(), |
| 114 info.profileType()); | 114 info.profileType(), |
| 115 *fTexture->getContext()->ca
ps()); |
| 115 uint32_t flags = 0; | 116 uint32_t flags = 0; |
| 116 if (kUnpremul_SkAlphaType == info.alphaType() && kPremul_SkAlphaType == fAlp
haType) { | 117 if (kUnpremul_SkAlphaType == info.alphaType() && kPremul_SkAlphaType == fAlp
haType) { |
| 117 // let the GPU perform this transformation for us | 118 // let the GPU perform this transformation for us |
| 118 flags = GrContext::kUnpremul_PixelOpsFlag; | 119 flags = GrContext::kUnpremul_PixelOpsFlag; |
| 119 } | 120 } |
| 120 if (!fTexture->readPixels(srcX, srcY, info.width(), info.height(), config, | 121 if (!fTexture->readPixels(srcX, srcY, info.width(), info.height(), config, |
| 121 pixels, rowBytes, flags)) { | 122 pixels, rowBytes, flags)) { |
| 122 return false; | 123 return false; |
| 123 } | 124 } |
| 124 // do we have to manually fix-up the alpha channel? | 125 // do we have to manually fix-up the alpha channel? |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 return nullptr; | 451 return nullptr; |
| 451 } | 452 } |
| 452 | 453 |
| 453 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); | 454 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); |
| 454 const SkIPoint dstP = SkIPoint::Make(0, 0); | 455 const SkIPoint dstP = SkIPoint::Make(0, 0); |
| 455 ctx->copySurface(dst, src, srcR, dstP); | 456 ctx->copySurface(dst, src, srcR, dstP); |
| 456 ctx->flushSurfaceWrites(dst); | 457 ctx->flushSurfaceWrites(dst); |
| 457 return dst; | 458 return dst; |
| 458 } | 459 } |
| 459 | 460 |
| OLD | NEW |