| 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 SkColor* row = (SkColor*)pixels; | 104 SkColor* row = (SkColor*)pixels; |
| 105 for (int y = 0; y < info.height(); ++y) { | 105 for (int y = 0; y < info.height(); ++y) { |
| 106 for (int x = 0; x < info.width(); ++x) { | 106 for (int x = 0; x < info.width(); ++x) { |
| 107 row[x] = SkPreMultiplyColor(row[x]); | 107 row[x] = SkPreMultiplyColor(row[x]); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool SkImage_Gpu::onReadPixels(const SkImageInfo& info, void* pixels, size_t row
Bytes, | 112 bool SkImage_Gpu::onReadPixels(const SkImageInfo& info, void* pixels, size_t row
Bytes, |
| 113 int srcX, int srcY, CachingHint) const { | 113 int srcX, int srcY, CachingHint) const { |
| 114 GrPixelConfig config = SkImageInfo2GrPixelConfig(info, *fTexture->getContext
()->caps()); | 114 GrPixelConfig config = SkImageInfo2GrPixelConfig(info.colorType(), info.alph
aType(), |
| 115 info.profileType(), |
| 116 *fTexture->getContext()->ca
ps()); |
| 115 uint32_t flags = 0; | 117 uint32_t flags = 0; |
| 116 if (kUnpremul_SkAlphaType == info.alphaType() && kPremul_SkAlphaType == fAlp
haType) { | 118 if (kUnpremul_SkAlphaType == info.alphaType() && kPremul_SkAlphaType == fAlp
haType) { |
| 117 // let the GPU perform this transformation for us | 119 // let the GPU perform this transformation for us |
| 118 flags = GrContext::kUnpremul_PixelOpsFlag; | 120 flags = GrContext::kUnpremul_PixelOpsFlag; |
| 119 } | 121 } |
| 120 if (!fTexture->readPixels(srcX, srcY, info.width(), info.height(), config, | 122 if (!fTexture->readPixels(srcX, srcY, info.width(), info.height(), config, |
| 121 pixels, rowBytes, flags)) { | 123 pixels, rowBytes, flags)) { |
| 122 return false; | 124 return false; |
| 123 } | 125 } |
| 124 // do we have to manually fix-up the alpha channel? | 126 // do we have to manually fix-up the alpha channel? |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 if (!ctx) { | 537 if (!ctx) { |
| 536 return nullptr; | 538 return nullptr; |
| 537 } | 539 } |
| 538 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m
ipLevelCount)); | 540 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m
ipLevelCount)); |
| 539 if (!texture) { | 541 if (!texture) { |
| 540 return nullptr; | 542 return nullptr; |
| 541 } | 543 } |
| 542 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, | 544 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, |
| 543 info.alphaType(), texture, budgeted); | 545 info.alphaType(), texture, budgeted); |
| 544 } | 546 } |
| OLD | NEW |