diff options
author | robertphillips <robertphillips@google.com> | 2016-08-01 05:53:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-01 05:53:23 -0700 |
commit | 12e9662cf796c7c1bd1f6e247691d8603335e57f (patch) | |
tree | 6ee536e15cb7ff494dd8123ba3ce596d21ca07dc | |
parent | f5b675efbe6f8255d08a9e822ad5774cbd53c827 (diff) |
Remove some ancillary users of SkSurface::MakeRenderTargetDirect
calved off of: https://codereview.chromium.org/2176333002/ (Remove SkSurface::MakeRenderTargetDirect)
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2198433003
Review-Url: https://codereview.chromium.org/2198433003
-rw-r--r-- | debugger/QT/SkGLWidget.cpp | 19 | ||||
-rw-r--r-- | debugger/QT/SkGLWidget.h | 6 | ||||
-rw-r--r-- | example/SkiaSDLExample.cpp | 5 | ||||
-rw-r--r-- | experimental/SkV8Example/SkV8Example.cpp | 7 | ||||
-rw-r--r-- | include/core/SkSurface.h | 6 |
5 files changed, 15 insertions, 28 deletions
diff --git a/debugger/QT/SkGLWidget.cpp b/debugger/QT/SkGLWidget.cpp index 57cb49dc6f..5335da47bd 100644 --- a/debugger/QT/SkGLWidget.cpp +++ b/debugger/QT/SkGLWidget.cpp @@ -38,8 +38,9 @@ void SkGLWidget::initializeGL() { if (fCurContext) { fCurContext->abandonContext(); } - fGpuDevice.reset(nullptr); - fCanvas.reset(nullptr); + + fGpuSurface = nullptr; + fCanvas = nullptr; fCurContext.reset(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext) fCurIntf.get())); } @@ -55,17 +56,11 @@ void SkGLWidget::createRenderTarget() { glClear(GL_STENCIL_BUFFER_BIT); fCurContext->resetContext(); - fGpuDevice.reset(nullptr); - fCanvas.reset(nullptr); - GrBackendRenderTargetDesc desc = this->getDesc(this->width(), this->height()); desc.fOrigin = kBottomLeft_GrSurfaceOrigin; - sk_sp<GrRenderTarget> curRenderTarget( - fCurContext->textureProvider()->wrapBackendRenderTarget(desc)); - SkSurfaceProps props(0, kUnknown_SkPixelGeometry); - fGpuDevice.reset(SkGpuDevice::Make(std::move(curRenderTarget), nullptr, &props, - SkGpuDevice::kUninit_InitContents).release()); - fCanvas.reset(new SkCanvas(fGpuDevice)); + + fGpuSurface = SkSurface::MakeFromBackendRenderTarget(fCurContext, desc, nullptr); + fCanvas = fGpuSurface->getCanvas(); } void SkGLWidget::resizeGL(int w, int h) { @@ -76,7 +71,7 @@ void SkGLWidget::resizeGL(int w, int h) { void SkGLWidget::paintGL() { if (!this->isHidden() && fCanvas) { fCurContext->resetContext(); - fDebugger->draw(fCanvas.get()); + fDebugger->draw(fCanvas); // TODO(chudy): Implement an optional flush button in Gui. fCanvas->flush(); Q_EMIT drawComplete(); diff --git a/debugger/QT/SkGLWidget.h b/debugger/QT/SkGLWidget.h index bb00857cd4..465e0997ed 100644 --- a/debugger/QT/SkGLWidget.h +++ b/debugger/QT/SkGLWidget.h @@ -47,8 +47,10 @@ private: void createRenderTarget(); SkAutoTUnref<const GrGLInterface> fCurIntf; SkAutoTUnref<GrContext> fCurContext; - SkAutoTUnref<SkGpuDevice> fGpuDevice; - SkAutoTUnref<SkCanvas> fCanvas; + + sk_sp<SkSurface> fGpuSurface; + SkCanvas* fCanvas; + SkDebugger* fDebugger; GrBackendRenderTargetDesc getDesc(int w, int h); }; diff --git a/example/SkiaSDLExample.cpp b/example/SkiaSDLExample.cpp index 0cc3402d71..da5f2dc9c1 100644 --- a/example/SkiaSDLExample.cpp +++ b/example/SkiaSDLExample.cpp @@ -206,15 +206,14 @@ int main(int argc, char** argv) { GrGLint buffer; GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer); desc.fRenderTargetHandle = buffer; - SkAutoTUnref<GrRenderTarget> - renderTarget(grContext->textureProvider()->wrapBackendRenderTarget(desc)); // setup SkSurface // To use distance field text, use commented out SkSurfaceProps instead // SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag, // SkSurfaceProps::kLegacyFontHost_InitType); SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); - SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(renderTarget, &props)); + + sk_sp<SkSurface> surface(SkSurface::MakeFromBackendRenderTarget(grContext, desc, &props)); SkCanvas* canvas = surface->getCanvas(); diff --git a/experimental/SkV8Example/SkV8Example.cpp b/experimental/SkV8Example/SkV8Example.cpp index bb448bad15..3882c3e9b3 100644 --- a/experimental/SkV8Example/SkV8Example.cpp +++ b/experimental/SkV8Example/SkV8Example.cpp @@ -48,7 +48,6 @@ SkV8ExampleWindow::SkV8ExampleWindow(void* hwnd, JsContext* context) #if SK_SUPPORT_GPU , fCurContext(NULL) , fCurIntf(NULL) - , fCurRenderTarget(NULL) , fCurSurface(NULL) #endif { @@ -64,7 +63,6 @@ SkV8ExampleWindow::~SkV8ExampleWindow() { #if SK_SUPPORT_GPU SkSafeUnref(fCurContext); SkSafeUnref(fCurIntf); - SkSafeUnref(fCurRenderTarget); SkSafeUnref(fCurSurface); #endif } @@ -99,10 +97,9 @@ void SkV8ExampleWindow::windowSizeChanged() { GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer); desc.fRenderTargetHandle = buffer; - SkSafeUnref(fCurRenderTarget); - fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc); SkSafeUnref(fCurSurface); - fCurSurface = SkSurface::NewRenderTargetDirect(fCurRenderTarget); + fCurSurface = SkSurface::MakeFromBackendRenderTarget(fCurContext, desc, + nullptr, nullptr).release(); } } #endif diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h index e60f50e3fa..7c4d21bd5f 100644 --- a/include/core/SkSurface.h +++ b/include/core/SkSurface.h @@ -178,12 +178,6 @@ public: const SkSurfaceProps* props = NULL) { return NewRaster(SkImageInfo::MakeN32Premul(width, height), props); } - static SkSurface* NewRenderTargetDirect(GrRenderTarget* rt, const SkSurfaceProps* props) { - return MakeRenderTargetDirect(rt, nullptr, props).release(); - } - static SkSurface* NewRenderTargetDirect(GrRenderTarget* target) { - return NewRenderTargetDirect(target, NULL); - } static SkSurface* NewFromBackendTexture(GrContext* ctx, const GrBackendTextureDesc& desc, const SkSurfaceProps* props) { return MakeFromBackendTexture(ctx, desc, props).release(); |