Chromium Code Reviews| 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 "SkSurface_Base.h" | 8 #include "SkSurface_Base.h" |
| 9 #include "SkImagePriv.h" | 9 #include "SkImagePriv.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 typedef SkSurface_Base INHERITED; | 31 typedef SkSurface_Base INHERITED; |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 SK_DEFINE_INST_COUNT(SkSurface_Gpu) | 34 SK_DEFINE_INST_COUNT(SkSurface_Gpu) |
| 35 | 35 |
| 36 /////////////////////////////////////////////////////////////////////////////// | 36 /////////////////////////////////////////////////////////////////////////////// |
| 37 | 37 |
| 38 SkSurface_Gpu::SkSurface_Gpu(GrContext* ctx, const SkImage::Info& info, | 38 SkSurface_Gpu::SkSurface_Gpu(GrContext* ctx, const SkImage::Info& info, |
| 39 int sampleCount) | 39 int sampleCount) |
| 40 : INHERITED(info.fWidth, info.fHeight) { | 40 : INHERITED(info.fWidth, info.fHeight) { |
| 41 bool isOpaque; | 41 SkBitmap::Config config = SkImageInfoToBitmapConfig(info); |
| 42 SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque); | |
| 43 | 42 |
| 44 fDevice = SkNEW_ARGS(SkGpuDevice, (ctx, config, info.fWidth, info.fHeight, s ampleCount)); | 43 fDevice = SkNEW_ARGS(SkGpuDevice, (ctx, config, info.fWidth, info.fHeight, s ampleCount)); |
| 45 | 44 |
| 46 if (!isOpaque) { | 45 if (!SkAlphaTypeIsOpaque(info.fAlphaType)) { |
| 47 fDevice->clear(0x0); | 46 fDevice->clear(0x0); |
|
scroggo
2013/10/18 21:52:41
Not needed for this CL, obviously, but is this a c
reed1
2013/10/21 12:24:25
The clear() turns into a GPU command, and does not
bsalomon
2013/10/21 13:18:04
Not that I know of. On some OSes newly created tex
| |
| 48 } | 47 } |
| 49 } | 48 } |
| 50 | 49 |
| 51 SkSurface_Gpu::SkSurface_Gpu(GrContext* ctx, GrRenderTarget* renderTarget) | 50 SkSurface_Gpu::SkSurface_Gpu(GrContext* ctx, GrRenderTarget* renderTarget) |
| 52 : INHERITED(renderTarget->width(), renderTarget->height()) { | 51 : INHERITED(renderTarget->width(), renderTarget->height()) { |
| 53 fDevice = SkNEW_ARGS(SkGpuDevice, (ctx, renderTarget)); | 52 fDevice = SkNEW_ARGS(SkGpuDevice, (ctx, renderTarget)); |
| 54 | 53 |
| 55 if (kRGB_565_GrPixelConfig != renderTarget->config()) { | 54 if (kRGB_565_GrPixelConfig != renderTarget->config()) { |
| 56 fDevice->clear(0x0); | 55 fDevice->clear(0x0); |
| 57 } | 56 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 } | 111 } |
| 113 | 112 |
| 114 return SkNEW_ARGS(SkSurface_Gpu, (ctx, target)); | 113 return SkNEW_ARGS(SkSurface_Gpu, (ctx, target)); |
| 115 } | 114 } |
| 116 | 115 |
| 117 SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImage::Info& info, int sampleCount) { | 116 SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImage::Info& info, int sampleCount) { |
| 118 if (NULL == ctx) { | 117 if (NULL == ctx) { |
| 119 return NULL; | 118 return NULL; |
| 120 } | 119 } |
| 121 | 120 |
| 122 bool isOpaque; | 121 SkBitmap::Config config = SkImageInfoToBitmapConfig(info); |
| 123 SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque); | |
| 124 | 122 |
| 125 GrTextureDesc desc; | 123 GrTextureDesc desc; |
| 126 desc.fFlags = kRenderTarget_GrTextureFlagBit | kCheckAllocation_GrTextureFla gBit; | 124 desc.fFlags = kRenderTarget_GrTextureFlagBit | kCheckAllocation_GrTextureFla gBit; |
| 127 desc.fWidth = info.fWidth; | 125 desc.fWidth = info.fWidth; |
| 128 desc.fHeight = info.fHeight; | 126 desc.fHeight = info.fHeight; |
| 129 desc.fConfig = SkBitmapConfig2GrPixelConfig(config); | 127 desc.fConfig = SkBitmapConfig2GrPixelConfig(config); |
| 130 desc.fSampleCnt = sampleCount; | 128 desc.fSampleCnt = sampleCount; |
| 131 | 129 |
| 132 SkAutoTUnref<GrTexture> tex(ctx->createUncachedTexture(desc, NULL, 0)); | 130 SkAutoTUnref<GrTexture> tex(ctx->createUncachedTexture(desc, NULL, 0)); |
| 133 if (NULL == tex) { | 131 if (NULL == tex) { |
| 134 return NULL; | 132 return NULL; |
| 135 } | 133 } |
| 136 | 134 |
| 137 return SkNEW_ARGS(SkSurface_Gpu, (ctx, tex->asRenderTarget())); | 135 return SkNEW_ARGS(SkSurface_Gpu, (ctx, tex->asRenderTarget())); |
| 138 } | 136 } |
| 137 | |
| OLD | NEW |