| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 int sampleCount = rt->numColorSamples(); | 74 int sampleCount = rt->numColorSamples(); |
| 75 // TODO: Make caller specify this (change virtual signature of onNewSurface)
. | 75 // TODO: Make caller specify this (change virtual signature of onNewSurface)
. |
| 76 static const Budgeted kBudgeted = kNo_Budgeted; | 76 static const Budgeted kBudgeted = kNo_Budgeted; |
| 77 return SkSurface::NewRenderTarget(fDevice->context(), kBudgeted, info, sampl
eCount, | 77 return SkSurface::NewRenderTarget(fDevice->context(), kBudgeted, info, sampl
eCount, |
| 78 &this->props()); | 78 &this->props()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 SkImage* SkSurface_Gpu::onNewImageSnapshot(Budgeted budgeted) { | 81 SkImage* SkSurface_Gpu::onNewImageSnapshot(Budgeted budgeted) { |
| 82 const SkImageInfo info = fDevice->imageInfo(); | 82 const SkImageInfo info = fDevice->imageInfo(); |
| 83 const int sampleCount = fDevice->accessRenderTarget()->numColorSamples(); | 83 const int sampleCount = fDevice->accessRenderTarget()->numColorSamples(); |
| 84 SkImage* image = NULL; | 84 SkImage* image = nullptr; |
| 85 GrTexture* tex = fDevice->accessRenderTarget()->asTexture(); | 85 GrTexture* tex = fDevice->accessRenderTarget()->asTexture(); |
| 86 if (tex) { | 86 if (tex) { |
| 87 image = new SkImage_Gpu(info.width(), info.height(), kNeedNewImageUnique
ID, | 87 image = new SkImage_Gpu(info.width(), info.height(), kNeedNewImageUnique
ID, |
| 88 info.alphaType(), tex, sampleCount, budgeted); | 88 info.alphaType(), tex, sampleCount, budgeted); |
| 89 } | 89 } |
| 90 if (image) { | 90 if (image) { |
| 91 as_IB(image)->initWithProps(this->props()); | 91 as_IB(image)->initWithProps(this->props()); |
| 92 } | 92 } |
| 93 return image; | 93 return image; |
| 94 } | 94 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 113 void SkSurface_Gpu::onDiscard() { | 113 void SkSurface_Gpu::onDiscard() { |
| 114 fDevice->accessRenderTarget()->discard(); | 114 fDevice->accessRenderTarget()->discard(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 /////////////////////////////////////////////////////////////////////////////// | 117 /////////////////////////////////////////////////////////////////////////////// |
| 118 | 118 |
| 119 SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, const SkSurf
aceProps* props) { | 119 SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, const SkSurf
aceProps* props) { |
| 120 SkAutoTUnref<SkGpuDevice> device( | 120 SkAutoTUnref<SkGpuDevice> device( |
| 121 SkGpuDevice::Create(target, props, SkGpuDevice::kUninit_InitContents)); | 121 SkGpuDevice::Create(target, props, SkGpuDevice::kUninit_InitContents)); |
| 122 if (!device) { | 122 if (!device) { |
| 123 return NULL; | 123 return nullptr; |
| 124 } | 124 } |
| 125 return new SkSurface_Gpu(device); | 125 return new SkSurface_Gpu(device); |
| 126 } | 126 } |
| 127 | 127 |
| 128 SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, Budgeted budgeted, const S
kImageInfo& info, | 128 SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, Budgeted budgeted, const S
kImageInfo& info, |
| 129 int sampleCount, const SkSurfaceProps* pro
ps) { | 129 int sampleCount, const SkSurfaceProps* pro
ps) { |
| 130 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(ctx, budgeted, info, sa
mpleCount, props, | 130 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(ctx, budgeted, info, sa
mpleCount, props, |
| 131 SkGpuDevice::kClear_Ini
tContents)); | 131 SkGpuDevice::kClear_Ini
tContents)); |
| 132 if (!device) { | 132 if (!device) { |
| 133 return NULL; | 133 return nullptr; |
| 134 } | 134 } |
| 135 return new SkSurface_Gpu(device); | 135 return new SkSurface_Gpu(device); |
| 136 } | 136 } |
| 137 | 137 |
| 138 SkSurface* SkSurface::NewFromBackendTexture(GrContext* context, const GrBackendT
extureDesc& desc, | 138 SkSurface* SkSurface::NewFromBackendTexture(GrContext* context, const GrBackendT
extureDesc& desc, |
| 139 const SkSurfaceProps* props) { | 139 const SkSurfaceProps* props) { |
| 140 if (NULL == context) { | 140 if (nullptr == context) { |
| 141 return NULL; | 141 return nullptr; |
| 142 } | 142 } |
| 143 if (!SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFlag)) { | 143 if (!SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFlag)) { |
| 144 return NULL; | 144 return nullptr; |
| 145 } | 145 } |
| 146 SkAutoTUnref<GrSurface> surface(context->textureProvider()->wrapBackendTextu
re(desc, | 146 SkAutoTUnref<GrSurface> surface(context->textureProvider()->wrapBackendTextu
re(desc, |
| 147 kBorrow_GrWrapOwnership)); | 147 kBorrow_GrWrapOwnership)); |
| 148 if (!surface) { | 148 if (!surface) { |
| 149 return NULL; | 149 return nullptr; |
| 150 } | 150 } |
| 151 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(surface->asRenderTarget
(), props, | 151 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(surface->asRenderTarget
(), props, |
| 152 SkGpuDevice::kUninit_In
itContents)); | 152 SkGpuDevice::kUninit_In
itContents)); |
| 153 if (!device) { | 153 if (!device) { |
| 154 return NULL; | 154 return nullptr; |
| 155 } | 155 } |
| 156 return new SkSurface_Gpu(device); | 156 return new SkSurface_Gpu(device); |
| 157 } | 157 } |
| 158 | 158 |
| 159 SkSurface* SkSurface::NewFromBackendRenderTarget(GrContext* context, | 159 SkSurface* SkSurface::NewFromBackendRenderTarget(GrContext* context, |
| 160 const GrBackendRenderTargetDesc
& desc, | 160 const GrBackendRenderTargetDesc
& desc, |
| 161 const SkSurfaceProps* props) { | 161 const SkSurfaceProps* props) { |
| 162 if (NULL == context) { | 162 if (nullptr == context) { |
| 163 return NULL; | 163 return nullptr; |
| 164 } | 164 } |
| 165 SkAutoTUnref<GrRenderTarget> rt(context->textureProvider()->wrapBackendRende
rTarget(desc)); | 165 SkAutoTUnref<GrRenderTarget> rt(context->textureProvider()->wrapBackendRende
rTarget(desc)); |
| 166 if (!rt) { | 166 if (!rt) { |
| 167 return NULL; | 167 return nullptr; |
| 168 } | 168 } |
| 169 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props, | 169 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props, |
| 170 SkGpuDevice::kUninit_In
itContents)); | 170 SkGpuDevice::kUninit_In
itContents)); |
| 171 if (!device) { | 171 if (!device) { |
| 172 return NULL; | 172 return nullptr; |
| 173 } | 173 } |
| 174 return new SkSurface_Gpu(device); | 174 return new SkSurface_Gpu(device); |
| 175 } | 175 } |
| 176 | 176 |
| 177 #endif | 177 #endif |
| OLD | NEW |