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_Gpu.h" | 8 #include "SkSurface_Gpu.h" |
| 9 | 9 |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 // TODO: Make caller specify this (change virtual signature of onNewSurface) . | 73 // TODO: Make caller specify this (change virtual signature of onNewSurface) . |
| 74 static const Budgeted kBudgeted = kNo_Budgeted; | 74 static const Budgeted kBudgeted = kNo_Budgeted; |
| 75 return SkSurface::NewRenderTarget(fDevice->context(), kBudgeted, info, sampl eCount, | 75 return SkSurface::NewRenderTarget(fDevice->context(), kBudgeted, info, sampl eCount, |
| 76 &this->props()); | 76 &this->props()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 SkImage* SkSurface_Gpu::onNewImageSnapshot(Budgeted budgeted, ForceCopyMode forc eCopyMode) { | 79 SkImage* SkSurface_Gpu::onNewImageSnapshot(Budgeted budgeted, ForceCopyMode forc eCopyMode) { |
| 80 GrRenderTarget* rt = fDevice->accessRenderTarget(); | 80 GrRenderTarget* rt = fDevice->accessRenderTarget(); |
| 81 SkASSERT(rt); | 81 SkASSERT(rt); |
| 82 GrTexture* tex = rt->asTexture(); | 82 GrTexture* tex = rt->asTexture(); |
| 83 SkAutoTUnref<GrTexture> copy; | 83 SkAutoTUnref<GrTexture> copy; |
|
robertphillips
2016/02/24 13:11:54
// When clients wrap an external FBO in a Surface
bsalomon
2016/02/26 17:44:44
Added a comment.
| |
| 84 // TODO: Force a copy when the rt is an external resource. | 84 if (kYes_ForceCopyMode == forceCopyMode || !tex || rt->resourcePriv().isExte rnal()) { |
| 85 if (kYes_ForceCopyMode == forceCopyMode || !tex) { | |
| 86 GrSurfaceDesc desc = fDevice->accessRenderTarget()->desc(); | 85 GrSurfaceDesc desc = fDevice->accessRenderTarget()->desc(); |
| 87 GrContext* ctx = fDevice->context(); | 86 GrContext* ctx = fDevice->context(); |
| 88 desc.fFlags = desc.fFlags & !kRenderTarget_GrSurfaceFlag; | 87 desc.fFlags = desc.fFlags & !kRenderTarget_GrSurfaceFlag; |
| 89 copy.reset(ctx->textureProvider()->createTexture(desc, budgeted)); | 88 copy.reset(ctx->textureProvider()->createTexture(desc, budgeted)); |
| 90 if (!copy) { | 89 if (!copy) { |
| 91 return nullptr; | 90 return nullptr; |
| 92 } | 91 } |
| 93 if (!ctx->copySurface(copy, rt)) { | 92 if (!ctx->copySurface(copy, rt)) { |
| 94 return nullptr; | 93 return nullptr; |
| 95 } | 94 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 } | 180 } |
| 182 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props, | 181 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props, |
| 183 SkGpuDevice::kUninit_In itContents)); | 182 SkGpuDevice::kUninit_In itContents)); |
| 184 if (!device) { | 183 if (!device) { |
| 185 return nullptr; | 184 return nullptr; |
| 186 } | 185 } |
| 187 return new SkSurface_Gpu(device); | 186 return new SkSurface_Gpu(device); |
| 188 } | 187 } |
| 189 | 188 |
| 190 #endif | 189 #endif |
| OLD | NEW |