diff options
author | 2016-08-04 08:45:02 -0700 | |
---|---|---|
committer | 2016-08-04 08:45:02 -0700 | |
commit | 15c42ca310e8b9785eab38b3dd36265948e85b0e (patch) | |
tree | c046b23f6c72377c28fdbd451bf2c997f799cc31 /src | |
parent | b83cdbcbb0829bf6e0c9cb2c7d9a0ff460f7f431 (diff) |
Remove SkSurface::MakeRenderTargetDirect
split into:
https://codereview.chromium.org/2182543003/ (Move prepareForExternalIO from GrRenderTarget to GrDrawContext)
https://codereview.chromium.org/2187573002/ (Reduce usage of MakeRenderTargetDirect)
https://codereview.chromium.org/2186073002/ (Rename GrContext's newDrawContext & drawContext to makeDrawContext)
https://codereview.chromium.org/2178353005/ (Remove use of MakeRenderTargetDirect from view system)
https://codereview.chromium.org/2198433003/ (Remove some ancillary users of SkSurface::MakeRenderTargetDirect)
https://codereview.chromium.org/2208483004/ (Remove GrRenderTarget member variable from SkGpuDevice)
https://codereview.chromium.org/2211473002/ (Move GrContext::makeDrawContext to new GrContextPriv object)
TBR=bsalomon@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2176333002
Review-Url: https://codereview.chromium.org/2176333002
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 37 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.h | 24 | ||||
-rw-r--r-- | src/image/SkSurface.cpp | 5 | ||||
-rw-r--r-- | src/image/SkSurface_Gpu.cpp | 52 |
4 files changed, 37 insertions, 81 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index ab4b319ed0..b1c6407d2f 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -9,10 +9,8 @@ #include "GrBlurUtils.h" #include "GrContext.h" -#include "GrContextPriv.h" #include "GrDrawContextPriv.h" #include "GrGpu.h" -#include "GrGpuResourcePriv.h" #include "GrImageIDTextureAdjuster.h" #include "GrStyle.h" #include "GrTracing.h" @@ -92,31 +90,9 @@ bool SkGpuDevice::CheckAlphaTypeAndGetFlags( return true; } -sk_sp<SkGpuDevice> SkGpuDevice::Make(sk_sp<GrRenderTarget> rt, sk_sp<SkColorSpace> colorSpace, - const SkSurfaceProps* props, InitContents init) { - if (!rt || rt->wasDestroyed() || !rt->getContext()) { - return nullptr; - } - unsigned flags; - if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) { - return nullptr; - } - - const int width = rt->width(); - const int height = rt->height(); - - GrContext* context = rt->getContext(); - - sk_sp<GrDrawContext> drawContext(context->contextPriv().makeWrappedDrawContext( - std::move(rt), - std::move(colorSpace), - props)); - return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(drawContext), width, height, flags)); -} - -sk_sp<SkBaseDevice> SkGpuDevice::Make(sk_sp<GrDrawContext> drawContext, - int width, int height, - InitContents init) { +sk_sp<SkGpuDevice> SkGpuDevice::Make(sk_sp<GrDrawContext> drawContext, + int width, int height, + InitContents init) { if (!drawContext || drawContext->wasAbandoned()) { return nullptr; } @@ -124,7 +100,7 @@ sk_sp<SkBaseDevice> SkGpuDevice::Make(sk_sp<GrDrawContext> drawContext, if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) { return nullptr; } - return sk_sp<SkBaseDevice>(new SkGpuDevice(std::move(drawContext), width, height, flags)); + return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(drawContext), width, height, flags)); } sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context, SkBudgeted budgeted, @@ -248,9 +224,8 @@ bool SkGpuDevice::onWritePixels(const SkImageInfo& info, const void* pixels, siz if (kUnpremul_SkAlphaType == info.alphaType()) { flags = GrContext::kUnpremul_PixelOpsFlag; } - fDrawContext->accessRenderTarget()->writePixels(x, y, info.width(), info.height(), - config, pixels, rowBytes, flags); - return true; + return fDrawContext->accessRenderTarget()->writePixels(x, y, info.width(), info.height(), + config, pixels, rowBytes, flags); } bool SkGpuDevice::onAccessPixels(SkPixmap* pmap) { diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h index 1b41bde3a9..fbbcc4ed2e 100644 --- a/src/gpu/SkGpuDevice.h +++ b/src/gpu/SkGpuDevice.h @@ -38,23 +38,12 @@ public: }; /** - * Creates an SkGpuDevice from a GrRenderTarget. - * TODO: rm this factory. It is used by SkSurface::MakeRenderTargetDirect, - * MakeFromBackendTexture, MakeFromBackendRenderTarget, - * and MakeFromBackendTextureAsRenderTarget. Only the first is worrisome. - */ - static sk_sp<SkGpuDevice> Make(sk_sp<GrRenderTarget> target, - sk_sp<SkColorSpace> colorSpace, - const SkSurfaceProps*, - InitContents); - - /** * Creates an SkGpuDevice from a GrDrawContext whose backing width/height is * different than its actual width/height (e.g., approx-match scratch texture). */ - static sk_sp<SkBaseDevice> Make(sk_sp<GrDrawContext> drawContext, - int width, int height, - InitContents); + static sk_sp<SkGpuDevice> Make(sk_sp<GrDrawContext> drawContext, + int width, int height, + InitContents); /** * New device that will create an offscreen renderTarget based on the ImageInfo and @@ -67,13 +56,6 @@ public: ~SkGpuDevice() override {} - SkGpuDevice* cloneDevice(const SkSurfaceProps& props) { - SkBaseDevice* dev = this->onCreateDevice(CreateInfo(this->imageInfo(), kPossible_TileUsage, - props.pixelGeometry()), - nullptr); - return static_cast<SkGpuDevice*>(dev); - } - GrContext* context() const override { return fContext; } // set all pixels to 0 diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp index 73b8286082..a0b9059e70 100644 --- a/src/image/SkSurface.cpp +++ b/src/image/SkSurface.cpp @@ -223,11 +223,6 @@ void SkSurface::prepareForExternalIO() { #if !SK_SUPPORT_GPU -sk_sp<SkSurface> SkSurface::MakeRenderTargetDirect(GrRenderTarget*, sk_sp<SkColorSpace>, - const SkSurfaceProps*) { - return nullptr; -} - sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext*, SkBudgeted, const SkImageInfo&, int, GrSurfaceOrigin, const SkSurfaceProps*) { return nullptr; diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index d8b4cee2dc..800cf477e3 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -7,6 +7,7 @@ #include "SkSurface_Gpu.h" +#include "GrContextPriv.h" #include "GrResourceProvider.h" #include "SkCanvas.h" #include "SkGpuDevice.h" @@ -132,18 +133,6 @@ void SkSurface_Gpu::onPrepareForExternalIO() { /////////////////////////////////////////////////////////////////////////////// -sk_sp<SkSurface> SkSurface::MakeRenderTargetDirect(GrRenderTarget* target, - sk_sp<SkColorSpace> colorSpace, - const SkSurfaceProps* props) { - sk_sp<SkGpuDevice> device( - SkGpuDevice::Make(sk_ref_sp(target), std::move(colorSpace), props, - SkGpuDevice::kUninit_InitContents)); - if (!device) { - return nullptr; - } - return sk_make_sp<SkSurface_Gpu>(std::move(device)); -} - sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext* ctx, SkBudgeted budgeted, const SkImageInfo& info, int sampleCount, GrSurfaceOrigin origin, const SkSurfaceProps* props) { @@ -159,19 +148,23 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context, const GrBackendTextureDesc& desc, sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* props) { - if (nullptr == context) { + if (!context) { return nullptr; } if (!SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFlag)) { return nullptr; } - SkAutoTUnref<GrSurface> surface(context->textureProvider()->wrapBackendTexture(desc, - kBorrow_GrWrapOwnership)); - if (!surface) { + + sk_sp<GrDrawContext> dc(context->contextPriv().makeBackendTextureDrawContext( + desc, + std::move(colorSpace), + props, + kBorrow_GrWrapOwnership)); + if (!dc) { return nullptr; } - sk_sp<SkGpuDevice> device(SkGpuDevice::Make(sk_ref_sp(surface->asRenderTarget()), - std::move(colorSpace), props, + + sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(dc), desc.fWidth, desc.fHeight, SkGpuDevice::kUninit_InitContents)); if (!device) { return nullptr; @@ -186,15 +179,21 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context, if (!context) { return nullptr; } - sk_sp<GrRenderTarget> rt(context->textureProvider()->wrapBackendRenderTarget(desc)); - if (!rt) { + + sk_sp<GrDrawContext> dc(context->contextPriv().makeBackendRenderTargetDrawContext( + desc, + std::move(colorSpace), + props)); + if (!dc) { return nullptr; } - sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), std::move(colorSpace), props, + + sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(dc), desc.fWidth, desc.fHeight, SkGpuDevice::kUninit_InitContents)); if (!device) { return nullptr; } + return sk_make_sp<SkSurface_Gpu>(std::move(device)); } @@ -205,11 +204,16 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* cont if (!context) { return nullptr; } - sk_sp<GrRenderTarget> rt(context->resourceProvider()->wrapBackendTextureAsRenderTarget(desc)); - if (!rt) { + + sk_sp<GrDrawContext> dc(context->contextPriv().makeBackendTextureAsRenderTargetDrawContext( + desc, + std::move(colorSpace), + props)); + if (!dc) { return nullptr; } - sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), std::move(colorSpace), props, + + sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(dc), desc.fWidth, desc.fHeight, SkGpuDevice::kUninit_InitContents)); if (!device) { return nullptr; |