Chromium Code Reviews| 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); | |
|
scroggo
2013/10/18 19:32:40
Will rendertargets support alphatype at some point
scroggo
2013/10/18 20:04:34
Thoughts?
reed1
2013/10/18 21:37:34
Done.
| |
| 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 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1851 GrTexture* texture, | 1850 GrTexture* texture, |
| 1852 bool needClear) | 1851 bool needClear) |
| 1853 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { | 1852 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { |
| 1854 | 1853 |
| 1855 SkASSERT(texture && texture->asRenderTarget()); | 1854 SkASSERT(texture && texture->asRenderTarget()); |
| 1856 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture | 1855 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture |
| 1857 // cache. We pass true for the third argument so that it will get unlocked. | 1856 // cache. We pass true for the third argument so that it will get unlocked. |
| 1858 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1857 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
| 1859 fNeedClear = needClear; | 1858 fNeedClear = needClear; |
| 1860 } | 1859 } |
| OLD | NEW |