| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 return NULL; | 103 return NULL; |
| 104 } | 104 } |
| 105 return SkNEW_ARGS(SkSurface_Gpu, (target, false)); | 105 return SkNEW_ARGS(SkSurface_Gpu, (target, false)); |
| 106 } | 106 } |
| 107 | 107 |
| 108 SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, i
nt sampleCount) { | 108 SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, i
nt sampleCount) { |
| 109 if (NULL == ctx) { | 109 if (NULL == ctx) { |
| 110 return NULL; | 110 return NULL; |
| 111 } | 111 } |
| 112 | 112 |
| 113 SkBitmap::Config config = SkImageInfoToBitmapConfig(info); | |
| 114 | |
| 115 GrTextureDesc desc; | 113 GrTextureDesc desc; |
| 116 desc.fFlags = kRenderTarget_GrTextureFlagBit | kCheckAllocation_GrTextureFla
gBit; | 114 desc.fFlags = kRenderTarget_GrTextureFlagBit | kCheckAllocation_GrTextureFla
gBit; |
| 117 desc.fWidth = info.fWidth; | 115 desc.fWidth = info.width(); |
| 118 desc.fHeight = info.fHeight; | 116 desc.fHeight = info.height(); |
| 119 desc.fConfig = SkBitmapConfig2GrPixelConfig(config); | 117 desc.fConfig = SkImageInfo2GrPixelConfig(info); |
| 120 desc.fSampleCnt = sampleCount; | 118 desc.fSampleCnt = sampleCount; |
| 121 | 119 |
| 122 SkAutoTUnref<GrTexture> tex(ctx->createUncachedTexture(desc, NULL, 0)); | 120 SkAutoTUnref<GrTexture> tex(ctx->createUncachedTexture(desc, NULL, 0)); |
| 123 if (NULL == tex) { | 121 if (NULL == tex) { |
| 124 return NULL; | 122 return NULL; |
| 125 } | 123 } |
| 126 | 124 |
| 127 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), false)); | 125 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), false)); |
| 128 } | 126 } |
| 129 | 127 |
| 130 SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo&
info, int sampleCount) { | 128 SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo&
info, int sampleCount) { |
| 131 if (NULL == ctx) { | 129 if (NULL == ctx) { |
| 132 return NULL; | 130 return NULL; |
| 133 } | 131 } |
| 134 | 132 |
| 135 SkBitmap::Config config = SkImageInfoToBitmapConfig(info); | |
| 136 | |
| 137 GrTextureDesc desc; | 133 GrTextureDesc desc; |
| 138 desc.fFlags = kRenderTarget_GrTextureFlagBit | kCheckAllocation_GrTextureFla
gBit; | 134 desc.fFlags = kRenderTarget_GrTextureFlagBit | kCheckAllocation_GrTextureFla
gBit; |
| 139 desc.fWidth = info.fWidth; | 135 desc.fWidth = info.width(); |
| 140 desc.fHeight = info.fHeight; | 136 desc.fHeight = info.height(); |
| 141 desc.fConfig = SkBitmapConfig2GrPixelConfig(config); | 137 desc.fConfig = SkImageInfo2GrPixelConfig(info); |
| 142 desc.fSampleCnt = sampleCount; | 138 desc.fSampleCnt = sampleCount; |
| 143 | 139 |
| 144 SkAutoTUnref<GrTexture> tex(ctx->lockAndRefScratchTexture(desc, GrContext::k
Exact_ScratchTexMatch)); | 140 SkAutoTUnref<GrTexture> tex(ctx->lockAndRefScratchTexture(desc, GrContext::k
Exact_ScratchTexMatch)); |
| 145 | 141 |
| 146 if (NULL == tex) { | 142 if (NULL == tex) { |
| 147 return NULL; | 143 return NULL; |
| 148 } | 144 } |
| 149 | 145 |
| 150 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true)); | 146 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true)); |
| 151 } | 147 } |
| OLD | NEW |