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 "SkImage_Gpu.h" | 8 #include "SkImage_Gpu.h" |
9 #include "GrContext.h" | 9 #include "GrContext.h" |
10 #include "GrDrawContext.h" | 10 #include "GrDrawContext.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 return false; | 54 return false; |
55 } | 55 } |
56 if (!fTexture->readPixels(0, 0, dst->width(), dst->height(), kSkia8888_GrPix
elConfig, | 56 if (!fTexture->readPixels(0, 0, dst->width(), dst->height(), kSkia8888_GrPix
elConfig, |
57 dst->getPixels(), dst->rowBytes())) { | 57 dst->getPixels(), dst->rowBytes())) { |
58 return false; | 58 return false; |
59 } | 59 } |
60 return true; | 60 return true; |
61 } | 61 } |
62 | 62 |
63 bool SkImage_Gpu::isOpaque() const { | 63 bool SkImage_Gpu::isOpaque() const { |
64 return GrPixelConfigIsOpaque(fTexture->config()); | 64 return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaque_Sk
AlphaType; |
65 } | 65 } |
66 | 66 |
67 static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes)
{ | 67 static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes)
{ |
68 switch (info.colorType()) { | 68 switch (info.colorType()) { |
69 case kRGBA_8888_SkColorType: | 69 case kRGBA_8888_SkColorType: |
70 case kBGRA_8888_SkColorType: | 70 case kBGRA_8888_SkColorType: |
71 break; | 71 break; |
72 default: | 72 default: |
73 return; // nothing to do | 73 return; // nothing to do |
74 } | 74 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 colorSpace))->unref(); | 249 colorSpace))->unref(); |
250 | 250 |
251 const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth), | 251 const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth), |
252 SkIntToScalar(dstDesc.fHeight)); | 252 SkIntToScalar(dstDesc.fHeight)); |
253 GrDrawContext* drawContext = ctx->drawContext(); | 253 GrDrawContext* drawContext = ctx->drawContext(); |
254 drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMa
trix::I(), rect); | 254 drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMa
trix::I(), rect); |
255 ctx->flushSurfaceWrites(dst); | 255 ctx->flushSurfaceWrites(dst); |
256 return SkNEW_ARGS(SkImage_Gpu, (dstDesc.fWidth, dstDesc.fHeight, kOpaque_SkA
lphaType, dst, 0, | 256 return SkNEW_ARGS(SkImage_Gpu, (dstDesc.fWidth, dstDesc.fHeight, kOpaque_SkA
lphaType, dst, 0, |
257 budgeted)); | 257 budgeted)); |
258 } | 258 } |
OLD | NEW |