| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkGpuDevice.h" | 8 #include "SkGpuDevice.h" |
| 9 | 9 |
| 10 #include "effects/GrTextureDomainEffect.h" | 10 #include "effects/GrTextureDomainEffect.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // a 8888 is opaque based on the config. | 131 // a 8888 is opaque based on the config. |
| 132 *isOpaque = false; | 132 *isOpaque = false; |
| 133 return SkBitmap::kARGB_8888_Config; | 133 return SkBitmap::kARGB_8888_Config; |
| 134 default: | 134 default: |
| 135 *isOpaque = false; | 135 *isOpaque = false; |
| 136 return SkBitmap::kNo_Config; | 136 return SkBitmap::kNo_Config; |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 static SkBitmap make_bitmap(GrContext* context, GrRenderTarget* renderTarget) { | 140 static SkBitmap make_bitmap(GrContext* context, GrRenderTarget* renderTarget) { |
| 141 GrPixelConfig config = renderTarget->config(); | 141 bool isOpaque; |
| 142 SkBitmap::Config config = grConfig2skConfig(renderTarget->config(), &isOpaqu
e); |
| 142 | 143 |
| 143 bool isOpaque; | |
| 144 SkBitmap bitmap; | 144 SkBitmap bitmap; |
| 145 bitmap.setConfig(grConfig2skConfig(config, &isOpaque), | 145 bitmap.setConfig(config, renderTarget->width(), renderTarget->height(), 0, |
| 146 renderTarget->width(), renderTarget->height()); | 146 isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); |
| 147 bitmap.setIsOpaque(isOpaque); | |
| 148 return bitmap; | 147 return bitmap; |
| 149 } | 148 } |
| 150 | 149 |
| 151 SkGpuDevice* SkGpuDevice::Create(GrSurface* surface) { | 150 SkGpuDevice* SkGpuDevice::Create(GrSurface* surface) { |
| 152 SkASSERT(NULL != surface); | 151 SkASSERT(NULL != surface); |
| 153 if (NULL == surface->asRenderTarget() || NULL == surface->getContext()) { | 152 if (NULL == surface->asRenderTarget() || NULL == surface->getContext()) { |
| 154 return NULL; | 153 return NULL; |
| 155 } | 154 } |
| 156 if (surface->asTexture()) { | 155 if (surface->asTexture()) { |
| 157 return SkNEW_ARGS(SkGpuDevice, (surface->getContext(), surface->asTextur
e())); | 156 return SkNEW_ARGS(SkGpuDevice, (surface->getContext(), surface->asTextur
e())); |
| (...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1878 GrTexture* texture, | 1877 GrTexture* texture, |
| 1879 bool needClear) | 1878 bool needClear) |
| 1880 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { | 1879 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { |
| 1881 | 1880 |
| 1882 SkASSERT(texture && texture->asRenderTarget()); | 1881 SkASSERT(texture && texture->asRenderTarget()); |
| 1883 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture | 1882 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture |
| 1884 // cache. We pass true for the third argument so that it will get unlocked. | 1883 // cache. We pass true for the third argument so that it will get unlocked. |
| 1885 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1884 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
| 1886 fNeedClear = needClear; | 1885 fNeedClear = needClear; |
| 1887 } | 1886 } |
| OLD | NEW |