Index: src/views/SkWindow.cpp |
diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp |
index a1af70444258f09b947c9f9c294738bb858eb712..e578b1a01fac03c601e3f2c8ba4ddeba74338d18 100644 |
--- a/src/views/SkWindow.cpp |
+++ b/src/views/SkWindow.cpp |
@@ -30,10 +30,9 @@ SkWindow::~SkWindow() { |
fMenus.deleteAll(); |
} |
-SkSurface* SkWindow::createSurface() { |
+sk_sp<SkSurface> SkWindow::makeSurface() { |
const SkBitmap& bm = this->getBitmap(); |
- return SkSurface::MakeRasterDirect(bm.info(), bm.getPixels(), bm.rowBytes(), |
- &fSurfaceProps).release(); |
+ return SkSurface::MakeRasterDirect(bm.info(), bm.getPixels(), bm.rowBytes(), &fSurfaceProps); |
} |
void SkWindow::setMatrix(const SkMatrix& matrix) { |
@@ -106,7 +105,7 @@ extern bool gEnableControlledThrow; |
bool SkWindow::update(SkIRect* updateArea) { |
if (!fDirtyRgn.isEmpty()) { |
- SkAutoTUnref<SkSurface> surface(this->createSurface()); |
+ sk_sp<SkSurface> surface(this->makeSurface()); |
SkCanvas* canvas = surface->getCanvas(); |
canvas->clipRegion(fDirtyRgn); |
@@ -322,11 +321,16 @@ bool SkWindow::onDispatchClick(int x, int y, Click::State state, |
#include "gl/GrGLUtil.h" |
#include "SkGr.h" |
-GrRenderTarget* SkWindow::renderTarget(const AttachmentInfo& attachmentInfo, |
- const GrGLInterface* interface, GrContext* grContext) { |
+sk_sp<SkSurface> SkWindow::makeGpuBackedSurface(const AttachmentInfo& attachmentInfo, |
+ const GrGLInterface* interface, |
+ GrContext* grContext) { |
GrBackendRenderTargetDesc desc; |
desc.fWidth = SkScalarRoundToInt(this->width()); |
desc.fHeight = SkScalarRoundToInt(this->height()); |
+ if (0 == desc.fWidth || 0 == desc.fHeight) { |
+ return nullptr; |
+ } |
+ |
// TODO: Query the actual framebuffer for sRGB capable. However, to |
// preserve old (fake-linear) behavior, we don't do this. Instead, rely |
// on the flag (currently driven via 'C' mode in SampleApp). |
@@ -347,7 +351,8 @@ GrRenderTarget* SkWindow::renderTarget(const AttachmentInfo& attachmentInfo, |
GrGLint buffer; |
GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer); |
desc.fRenderTargetHandle = buffer; |
- return grContext->textureProvider()->wrapBackendRenderTarget(desc); |
+ |
+ return SkSurface::MakeFromBackendRenderTarget(grContext, desc, &fSurfaceProps); |
} |
#endif |