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

Unified Diff: experimental/iOSSampleApp/SkSampleUIView.mm

Issue 637263004: fix some bit-rot in the ios port of sampleapp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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
Index: experimental/iOSSampleApp/SkSampleUIView.mm
diff --git a/experimental/iOSSampleApp/SkSampleUIView.mm b/experimental/iOSSampleApp/SkSampleUIView.mm
index a9defbe610f6bb24b8da9851189702821300fc82..01f7b1119a22cf84192c2d66f1e56d219c9beef7 100644
--- a/experimental/iOSSampleApp/SkSampleUIView.mm
+++ b/experimental/iOSSampleApp/SkSampleUIView.mm
@@ -7,6 +7,7 @@
#include "SkCanvas.h"
#include "SkCGUtils.h"
+#include "SkSurface.h"
#include "SampleApp.h"
#if SK_SUPPORT_GPU
@@ -119,36 +120,16 @@ public:
fBackend = SampleWindow::kNone_BackEndType;
}
- virtual SkCanvas* createCanvas(SampleWindow::DeviceType dType,
- SampleWindow* win) {
- switch (dType) {
- case SampleWindow::kRaster_DeviceType:
- // fallthrough
- case SampleWindow::kPicture_DeviceType:
- // fallthrough
-#if SK_ANGLE
- case SampleWindow::kANGLE_DeviceType:
-#endif
- break;
+ virtual SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindow* win) SK_OVERRIDE{
#if SK_SUPPORT_GPU
- case SampleWindow::kGPU_DeviceType:
- case SampleWindow::kNullGPU_DeviceType:
- if (fCurContext) {
- SkAutoTUnref<SkBaseDevice> device(new SkGpuDevice(fCurContext,
- fCurRenderTarget));
- return new SkCanvas(device);
- } else {
- return NULL;
- }
- break;
-#endif
- default:
- SkASSERT(false);
- return NULL;
+ if (SampleWindow::IsGpuDeviceType(dType) && fCurContext) {
+ SkSurfaceProps props(win->getSurfaceProps());
+ return SkSurface::NewRenderTargetDirect(fCurRenderTarget, &props);
}
+#endif
return NULL;
}
-
+
virtual void publishCanvas(SampleWindow::DeviceType dType,
SkCanvas* canvas,
SampleWindow* win) SK_OVERRIDE {
@@ -419,23 +400,27 @@ static FPSState gFPS;
glViewport(0, 0, fGL.fWidth, fGL.fHeight);
- SkAutoTUnref<SkCanvas> canvas(fWind->createCanvas());
+ SkAutoTUnref<SkSurface> surface(fWind->createSurface());
+ SkCanvas* canvas = surface->getCanvas();
+
// if we're not "retained", then we have to always redraw everything.
// This call forces us to ignore the fDirtyRgn, and draw everywhere.
// If we are "retained", we can skip this call (as the raster case does)
fWind->forceInvalAll();
[self drawWithCanvas:canvas];
-
+
+ // Do we need to call canvas->flush() here? <reed>
+
jvanverth1 2014/10/20 15:03:22 It appears to be working without it.
reed1 2014/10/22 19:56:53 Done.
// This application only creates a single color renderbuffer which is already bound at this point.
// This call is redundant, but needed if dealing with multiple renderbuffers.
glBindRenderbuffer(GL_RENDERBUFFER, fGL.fRenderbuffer);
[fGL.fContext presentRenderbuffer:GL_RENDERBUFFER];
-
}
- (void)drawInRaster {
- SkAutoTUnref<SkCanvas> canvas(fWind->createCanvas());
+ SkAutoTUnref<SkSurface> surface(fWind->createSurface());
+ SkCanvas* canvas = surface->getCanvas();
[self drawWithCanvas:canvas];
CGImageRef cgimage = SkCreateCGImageRef(fWind->getBitmap());
fRasterLayer.contents = (id)cgimage;

Powered by Google App Engine
This is Rietveld 408576698