aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-04-29 06:46:36 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-29 06:46:36 -0700
commit24e912869499352e8947d3943acb43edd7ffded6 (patch)
tree44f487f18b3e241bfd28370f747c5cfe2cedeb7b /src/gpu
parentefe46d20949efbc59bedd1f28e6f42a0dd069688 (diff)
Add sk_sp to SkSurface_Gpu and SkGpuDevice
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/SkGpuDevice.cpp29
-rw-r--r--src/gpu/SkGpuDevice.h12
2 files changed, 23 insertions, 18 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 0e6eb92537..98da472581 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -127,13 +127,15 @@ bool SkGpuDevice::CheckAlphaTypeAndGetFlags(
return true;
}
-SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, const SkSurfaceProps* props,
- InitContents init) {
- return SkGpuDevice::Create(rt, rt->width(), rt->height(), props, init);
+sk_sp<SkGpuDevice> SkGpuDevice::Make(sk_sp<GrRenderTarget> rt, const SkSurfaceProps* props,
+ InitContents init) {
+ const int width = rt->width();
+ const int height = rt->height();
+ return SkGpuDevice::Make(std::move(rt), width, height, props, init);
}
-SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, int width, int height,
- const SkSurfaceProps* props, InitContents init) {
+sk_sp<SkGpuDevice> SkGpuDevice::Make(sk_sp<GrRenderTarget> rt, int width, int height,
+ const SkSurfaceProps* props, InitContents init) {
if (!rt || rt->wasDestroyed()) {
return nullptr;
}
@@ -141,23 +143,23 @@ SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, int width, int height,
if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) {
return nullptr;
}
- return new SkGpuDevice(rt, width, height, props, flags);
+ return sk_sp<SkGpuDevice>(new SkGpuDevice(rt.get(), width, height, props, flags));
}
-SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkBudgeted budgeted,
- const SkImageInfo& info, int sampleCount,
- const SkSurfaceProps* props, InitContents init) {
+sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context, SkBudgeted budgeted,
+ const SkImageInfo& info, int sampleCount,
+ const SkSurfaceProps* props, InitContents init) {
unsigned flags;
if (!CheckAlphaTypeAndGetFlags(&info, init, &flags)) {
return nullptr;
}
SkAutoTUnref<GrRenderTarget> rt(CreateRenderTarget(context, budgeted, info, sampleCount));
- if (nullptr == rt) {
+ if (!rt) {
return nullptr;
}
- return new SkGpuDevice(rt, info.width(), info.height(), props, flags);
+ return sk_sp<SkGpuDevice>(new SkGpuDevice(rt, info.width(), info.height(), props, flags));
}
SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height,
@@ -1756,8 +1758,9 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
if (texture) {
SkSurfaceProps props(this->surfaceProps().flags(), cinfo.fPixelGeometry);
- return SkGpuDevice::Create(
- texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height(), &props, init);
+ return SkGpuDevice::Make(sk_ref_sp(texture->asRenderTarget()),
+ cinfo.fInfo.width(), cinfo.fInfo.height(),
+ &props, init).release();
} else {
SkErrorInternals::SetError( kInternalError_SkError,
"---- failed to create gpu device texture [%d %d]\n",
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index 8420449a9a..1e025670ef 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -37,22 +37,24 @@ public:
/**
* Creates an SkGpuDevice from a GrRenderTarget.
*/
- static SkGpuDevice* Create(GrRenderTarget* target, const SkSurfaceProps*, InitContents);
+ static sk_sp<SkGpuDevice> Make(sk_sp<GrRenderTarget> target,
+ const SkSurfaceProps*,
+ InitContents);
/**
* Creates an SkGpuDevice from a GrRenderTarget whose texture width/height is
* different than its actual width/height (e.g., approx-match scratch texture).
*/
- static SkGpuDevice* Create(GrRenderTarget* target, int width, int height,
- const SkSurfaceProps*, InitContents);
+ static sk_sp<SkGpuDevice> Make(sk_sp<GrRenderTarget> target, int width, int height,
+ const SkSurfaceProps*, InitContents);
/**
* New device that will create an offscreen renderTarget based on the ImageInfo and
* sampleCount. The Budgeted param controls whether the device's backing store counts against
* the resource cache budget. On failure, returns nullptr.
*/
- static SkGpuDevice* Create(GrContext*, SkBudgeted, const SkImageInfo&,
- int sampleCount, const SkSurfaceProps*, InitContents);
+ static sk_sp<SkGpuDevice> Make(GrContext*, SkBudgeted, const SkImageInfo&,
+ int sampleCount, const SkSurfaceProps*, InitContents);
~SkGpuDevice() override {}