diff options
author | robertphillips <robertphillips@google.com> | 2016-05-17 09:57:46 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-17 09:57:46 -0700 |
commit | ca6eafc0f7e59ed89f03a9891b9fdf7de64f1f35 (patch) | |
tree | 06a052b8018ae4fb6ccbac647d2a4f77cc3a99d1 /src/core/SkSpecialSurface.cpp | |
parent | cc49e5950d3a0de03c24da71d23bbdaebead97c6 (diff) |
(Mostly) Retract GrRenderTarget from SkGpuDevice
This gets us most of the way to having SkGpuDevice exclusively use a GrDrawContext instead of a GrRenderTarget. There are a few other refactorings (e.g., rm need for fLegacyBitmap and accessRenderTarget) before the GrRenderTarget can be completely removed.
Has calved off:
https://codereview.chromium.org/1925313002/ (Tighten up SkSpecialSurface factory functions)
https://codereview.chromium.org/1925803004/ (Add sk_sp to SkSurface_Gpu and SkGpuDevice)
https://codereview.chromium.org/1956473002/ (Retract GrRenderTarget a bit within SkGpuDevice)
https://codereview.chromium.org/1979913002/ (Rename GrDrawingMgr::abandon to wasAbandoned & add a matching entry point to GrDrawingContext)
https://codereview.chromium.org/1982583002/ (Add isUnifiedMultisampled entry point to GrDrawContext)
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1930013002
Review-Url: https://codereview.chromium.org/1930013002
Diffstat (limited to 'src/core/SkSpecialSurface.cpp')
-rw-r--r-- | src/core/SkSpecialSurface.cpp | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp index dee9811f95..510926a1f5 100644 --- a/src/core/SkSpecialSurface.cpp +++ b/src/core/SkSpecialSurface.cpp @@ -115,18 +115,14 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRaster(const SkImageInfo& info, class SkSpecialSurface_Gpu : public SkSpecialSurface_Base { public: - SkSpecialSurface_Gpu(sk_sp<GrTexture> texture, + SkSpecialSurface_Gpu(sk_sp<GrDrawContext> drawContext, int width, int height, - const SkIRect& subset, - const SkSurfaceProps* props) - : INHERITED(subset, props) - , fTexture(std::move(texture)) { - - SkASSERT(fTexture->asRenderTarget()); + const SkIRect& subset) + : INHERITED(subset, &drawContext->surfaceProps()) + , fDrawContext(std::move(drawContext)) { - sk_sp<SkGpuDevice> device(SkGpuDevice::Make(sk_ref_sp(fTexture->asRenderTarget()), - width, height, props, - SkGpuDevice::kUninit_InitContents)); + sk_sp<SkBaseDevice> device(SkGpuDevice::Make(fDrawContext, width, height, + SkGpuDevice::kUninit_InitContents)); if (!device) { return; } @@ -141,15 +137,16 @@ public: ~SkSpecialSurface_Gpu() override { } sk_sp<SkSpecialImage> onMakeImageSnapshot() override { - // Note: we are intentionally zeroing out 'fTexture' here - return SkSpecialImage::MakeFromGpu(this->subset(), - kNeedNewImageUniqueID_SpecialImage, - std::move(fTexture), - &this->props()); + sk_sp<SkSpecialImage> tmp(SkSpecialImage::MakeFromGpu(this->subset(), + kNeedNewImageUniqueID_SpecialImage, + fDrawContext->asTexture(), + &this->props())); + fDrawContext = nullptr; + return tmp; } private: - sk_sp<GrTexture> fTexture; + sk_sp<GrDrawContext> fDrawContext; typedef SkSpecialSurface_Base INHERITED; }; @@ -161,20 +158,15 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrContext* context, return nullptr; } - GrSurfaceDesc desc; - desc.fFlags = kRenderTarget_GrSurfaceFlag; - desc.fWidth = width; - desc.fHeight = height; - desc.fConfig = config; - - sk_sp<GrTexture> tex(context->textureProvider()->createApproxTexture(desc)); - if (!tex) { + sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox, + width, height, config)); + if (!drawContext) { return nullptr; } const SkIRect subset = SkIRect::MakeWH(width, height); - return sk_make_sp<SkSpecialSurface_Gpu>(std::move(tex), width, height, subset, nullptr); + return sk_make_sp<SkSpecialSurface_Gpu>(std::move(drawContext), width, height, subset); } #endif |