Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Unified Diff: src/views/SkWindow.cpp

Issue 2178353005: Remove use of MakeRenderTargetDirect from view system (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix Mac Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | src/views/mac/SkNSView.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | src/views/mac/SkNSView.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698