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()); | |
116 uint32_t flags = 0; | 115 uint32_t flags = 0; |
117 if (kUnpremul_SkAlphaType == info.alphaType() && kPremul_SkAlphaType == fAlp
haType) { | 116 if (kUnpremul_SkAlphaType == info.alphaType() && kPremul_SkAlphaType == fAlp
haType) { |
118 // let the GPU perform this transformation for us | 117 // let the GPU perform this transformation for us |
119 flags = GrContext::kUnpremul_PixelOpsFlag; | 118 flags = GrContext::kUnpremul_PixelOpsFlag; |
120 } | 119 } |
121 if (!fTexture->readPixels(srcX, srcY, info.width(), info.height(), config, | 120 if (!fTexture->readPixels(srcX, srcY, info.width(), info.height(), config, |
122 pixels, rowBytes, flags)) { | 121 pixels, rowBytes, flags)) { |
123 return false; | 122 return false; |
124 } | 123 } |
125 // do we have to manually fix-up the alpha channel? | 124 // do we have to manually fix-up the alpha channel? |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 return nullptr; | 450 return nullptr; |
452 } | 451 } |
453 | 452 |
454 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); | 453 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); |
455 const SkIPoint dstP = SkIPoint::Make(0, 0); | 454 const SkIPoint dstP = SkIPoint::Make(0, 0); |
456 ctx->copySurface(dst, src, srcR, dstP); | 455 ctx->copySurface(dst, src, srcR, dstP); |
457 ctx->flushSurfaceWrites(dst); | 456 ctx->flushSurfaceWrites(dst); |
458 return dst; | 457 return dst; |
459 } | 458 } |
460 | 459 |
OLD | NEW |