diff options
author | 2016-11-17 12:45:04 -0500 | |
---|---|---|
committer | 2016-11-17 18:35:22 +0000 | |
commit | 9fab7e98d711968df3ec4fd2f3fe5c40820b2a0d (patch) | |
tree | f69b3d6d3dc13bca5bfcb33ee296ddb842855926 | |
parent | a7c4c29abfee3b17f1ba0e6c6b1f98b6fb9cd2b8 (diff) |
Remove accessRenderTarget call in SkGpuDevice ctor
This is a follow up to https://skia-review.googlesource.com/c/4929/ (Guard against instantiate & accessRenderTarget failures).
Rather than guard this call to accessRenderTarget I would prefer to remove it.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4961
BUG=665681,665500,665621
Change-Id: I2c9ec245491d9059de892b2e6a7d4a4de4accdfd
Reviewed-on: https://skia-review.googlesource.com/4961
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
-rw-r--r-- | src/core/SkSpecialSurface.cpp | 10 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 20 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.h | 7 | ||||
-rw-r--r-- | src/image/SkSurface_Gpu.cpp | 6 |
4 files changed, 21 insertions, 22 deletions
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp index b490421aa8..f0c66ae1d7 100644 --- a/src/core/SkSpecialSurface.cpp +++ b/src/core/SkSpecialSurface.cpp @@ -115,13 +115,12 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRaster(const SkImageInfo& info, class SkSpecialSurface_Gpu : public SkSpecialSurface_Base { public: - SkSpecialSurface_Gpu(sk_sp<GrRenderTargetContext> renderTargetContext, - int width, int height, - const SkIRect& subset) + SkSpecialSurface_Gpu(GrContext* context, sk_sp<GrRenderTargetContext> renderTargetContext, + int width, int height, const SkIRect& subset) : INHERITED(subset, &renderTargetContext->surfaceProps()) , fRenderTargetContext(std::move(renderTargetContext)) { - sk_sp<SkBaseDevice> device(SkGpuDevice::Make(fRenderTargetContext, width, height, + sk_sp<SkBaseDevice> device(SkGpuDevice::Make(context, fRenderTargetContext, width, height, SkGpuDevice::kUninit_InitContents)); if (!device) { return; @@ -169,7 +168,8 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrContext* context, const SkIRect subset = SkIRect::MakeWH(width, height); - return sk_make_sp<SkSpecialSurface_Gpu>(std::move(renderTargetContext), width, height, subset); + return sk_make_sp<SkSpecialSurface_Gpu>(context, std::move(renderTargetContext), + width, height, subset); } #endif diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 1fbc953b65..7f88790909 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -87,7 +87,8 @@ bool SkGpuDevice::CheckAlphaTypeAndGetFlags( return true; } -sk_sp<SkGpuDevice> SkGpuDevice::Make(sk_sp<GrRenderTargetContext> renderTargetContext, +sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context, + sk_sp<GrRenderTargetContext> renderTargetContext, int width, int height, InitContents init) { if (!renderTargetContext || renderTargetContext->wasAbandoned()) { @@ -97,8 +98,8 @@ sk_sp<SkGpuDevice> SkGpuDevice::Make(sk_sp<GrRenderTargetContext> renderTargetCo if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) { return nullptr; } - return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(renderTargetContext), width, height, - flags)); + return sk_sp<SkGpuDevice>(new SkGpuDevice(context, std::move(renderTargetContext), + width, height, flags)); } sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context, SkBudgeted budgeted, @@ -117,7 +118,7 @@ sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context, SkBudgeted budgeted, return nullptr; } - return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(renderTargetContext), + return sk_sp<SkGpuDevice>(new SkGpuDevice(context, std::move(renderTargetContext), info.width(), info.height(), flags)); } @@ -131,11 +132,11 @@ static SkImageInfo make_info(GrRenderTargetContext* context, int w, int h, bool sk_ref_sp(context->getColorSpace())); } -SkGpuDevice::SkGpuDevice(sk_sp<GrRenderTargetContext> renderTargetContext, int width, int height, - unsigned flags) +SkGpuDevice::SkGpuDevice(GrContext* context, sk_sp<GrRenderTargetContext> renderTargetContext, + int width, int height, unsigned flags) : INHERITED(make_info(renderTargetContext.get(), width, height, SkToBool(flags & kIsOpaque_Flag)), renderTargetContext->surfaceProps()) - , fContext(SkRef(renderTargetContext->accessRenderTarget()->getContext())) + , fContext(SkRef(context)) , fRenderTargetContext(std::move(renderTargetContext)) { fSize.set(width, height); @@ -1811,9 +1812,8 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint // Skia's convention is to only clear a device if it is non-opaque. InitContents init = cinfo.fInfo.isOpaque() ? kUninit_InitContents : kClear_InitContents; - return SkGpuDevice::Make(std::move(rtc), - cinfo.fInfo.width(), cinfo.fInfo.height(), - init).release(); + return SkGpuDevice::Make(fContext.get(), std::move(rtc), + cinfo.fInfo.width(), cinfo.fInfo.height(), init).release(); } sk_sp<SkSurface> SkGpuDevice::makeSurface(const SkImageInfo& info, const SkSurfaceProps& props) { diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h index ca5be45ff6..b81da4e0ec 100644 --- a/src/gpu/SkGpuDevice.h +++ b/src/gpu/SkGpuDevice.h @@ -42,9 +42,8 @@ public: * Creates an SkGpuDevice from a GrRenderTargetContext whose backing width/height is * different than its actual width/height (e.g., approx-match scratch texture). */ - static sk_sp<SkGpuDevice> Make(sk_sp<GrRenderTargetContext> renderTargetContext, - int width, int height, - InitContents); + static sk_sp<SkGpuDevice> Make(GrContext*, sk_sp<GrRenderTargetContext> renderTargetContext, + int width, int height, InitContents); /** * New device that will create an offscreen renderTarget based on the ImageInfo and @@ -148,7 +147,7 @@ private: static bool CheckAlphaTypeAndGetFlags(const SkImageInfo* info, InitContents init, unsigned* flags); - SkGpuDevice(sk_sp<GrRenderTargetContext>, int width, int height, unsigned flags); + SkGpuDevice(GrContext*, sk_sp<GrRenderTargetContext>, int width, int height, unsigned flags); SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index abd8332ee0..778eb24f6c 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -207,7 +207,7 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context, return nullptr; } - sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rtc), desc.fWidth, desc.fHeight, + sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), desc.fWidth, desc.fHeight, SkGpuDevice::kUninit_InitContents)); if (!device) { return nullptr; @@ -234,7 +234,7 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context, return nullptr; } - sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rtc), desc.fWidth, desc.fHeight, + sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), desc.fWidth, desc.fHeight, SkGpuDevice::kUninit_InitContents)); if (!device) { return nullptr; @@ -263,7 +263,7 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* cont return nullptr; } - sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rtc), desc.fWidth, desc.fHeight, + sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), desc.fWidth, desc.fHeight, SkGpuDevice::kUninit_InitContents)); if (!device) { return nullptr; |