From c8fcafb3f0d152fb92465451bdb2e4bd3ef37222 Mon Sep 17 00:00:00 2001 From: caryclark Date: Fri, 30 Jan 2015 12:37:02 -0800 Subject: [PATCH] First cut at cleaning up Sergio's example code and moving some common code to SkWindow. Eventually, this will be moved to be a peer of SampleApp so it is compiled by the bots to avoid future bit rot. Also ignore XCode auto-generated flag in CommandLineFlags, and remove the unused multiple-example part. Review URL: https://codereview.chromium.org/890873003 --- .../SkiaExamples/HelloSkiaExample.cpp | 106 -------- experimental/SkiaExamples/SkExample.cpp | 227 +++++++++--------- experimental/SkiaExamples/SkExample.h | 34 ++- gyp/experimental.gyp | 3 +- gyp/views.gyp | 5 + include/views/SkOSWindow_Android.h | 5 - include/views/SkOSWindow_Mac.h | 5 - include/views/SkOSWindow_NaCl.h | 5 - include/views/SkOSWindow_Unix.h | 5 - include/views/SkOSWindow_Win.h | 5 - include/views/SkOSWindow_iOS.h | 5 - include/views/SkWindow.h | 16 ++ samplecode/SampleApp.cpp | 14 +- src/views/SkWindow.cpp | 23 ++ tools/flags/SkCommandLineFlags.cpp | 5 + 15 files changed, 186 insertions(+), 277 deletions(-) delete mode 100644 experimental/SkiaExamples/HelloSkiaExample.cpp diff --git a/experimental/SkiaExamples/HelloSkiaExample.cpp b/experimental/SkiaExamples/HelloSkiaExample.cpp deleted file mode 100644 index 6fd2624c18..0000000000 --- a/experimental/SkiaExamples/HelloSkiaExample.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2013 Google Inc. - * - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - */ - -#include "SkExample.h" - -#include "SkApplication.h" -#include "SkDraw.h" -#include "SkGradientShader.h" -#include "SkGraphics.h" - -class HelloSkia : public SkExample { -public: - HelloSkia(SkExampleWindow* window) : SkExample(window) { - fName = "HelloSkia"; - fBGColor = SK_ColorWHITE; - fRotationAngle = SkIntToScalar(0); - - fWindow->setupBackend(SkExampleWindow::kGPU_DeviceType); - // Another option is software rendering: - // fWindow->setupBackend(SkExampleWindow::kRaster_DeviceType); - } - -protected: - void draw(SkCanvas* canvas) { - // Clear background - canvas->drawColor(fBGColor); - - SkPaint paint; - paint.setColor(SK_ColorRED); - - // Draw a rectangle with blue paint - SkRect rect = { - SkIntToScalar(10), SkIntToScalar(10), - SkIntToScalar(128), SkIntToScalar(128) - }; - canvas->drawRect(rect, paint); - - // Set up a linear gradient and draw a circle - { - SkPoint linearPoints[] = { - {SkIntToScalar(0), SkIntToScalar(0)}, - {SkIntToScalar(300), SkIntToScalar(300)} - }; - SkColor linearColors[] = {SK_ColorGREEN, SK_ColorBLACK}; - - SkShader* shader = SkGradientShader::CreateLinear( - linearPoints, linearColors, NULL, 2, - SkShader::kMirror_TileMode); - SkAutoUnref shader_deleter(shader); - - paint.setShader(shader); - paint.setFlags(SkPaint::kAntiAlias_Flag); - - canvas->drawCircle(SkIntToScalar(200), SkIntToScalar(200), - SkIntToScalar(64), paint); - - // Detach shader - paint.setShader(NULL); - } - - // Draw a message with a nice black paint. - paint.setFlags( - SkPaint::kAntiAlias_Flag | - SkPaint::kSubpixelText_Flag | // ... avoid waggly text when rotating. - SkPaint::kUnderlineText_Flag); - paint.setColor(SK_ColorBLACK); - paint.setTextSize(SkIntToScalar(20)); - - canvas->save(); - - static const char message[] = "Hello Skia!!!"; - - // Translate and rotate - canvas->translate(SkIntToScalar(300), SkIntToScalar(300)); - fRotationAngle += SkDoubleToScalar(0.2); - if (fRotationAngle > SkDoubleToScalar(360.0)) { - fRotationAngle -= SkDoubleToScalar(360.0); - } - canvas->rotate(fRotationAngle); - - // Draw the text: - canvas->drawText(message, strlen(message), SkIntToScalar(0), SkIntToScalar(0), paint); - - canvas->restore(); - - // Invalidate the window to force a redraw. Poor man's animation mechanism. - this->fWindow->inval(NULL); - } - -private: - SkScalar fRotationAngle; - SkColor fBGColor; -}; - -static SkExample* MyFactory(SkExampleWindow* window) { - return new HelloSkia(window); -} - -// Register this class as a Skia Example. -SkExample::Registry registry(MyFactory); diff --git a/experimental/SkiaExamples/SkExample.cpp b/experimental/SkiaExamples/SkExample.cpp index 637ec9df53..849c14b3ec 100644 --- a/experimental/SkiaExamples/SkExample.cpp +++ b/experimental/SkiaExamples/SkExample.cpp @@ -9,22 +9,12 @@ #include "SkExample.h" -#include "gl/GrGLUtil.h" -#include "gl/GrGLDefines.h" #include "gl/GrGLInterface.h" #include "SkApplication.h" -#include "SkCommandLineFlags.h" -#include "SkGpuDevice.h" +#include "SkCanvas.h" +#include "SkGradientShader.h" #include "SkGraphics.h" - -DEFINE_string2(match, m, NULL, "[~][^]substring[$] [...] of test name to run.\n" \ - "Multiple matches may be separated by spaces.\n" \ - "~ causes a matching test to always be skipped\n" \ - "^ requires the start of the test to match\n" \ - "$ requires the end of the test to match\n" \ - "^ and $ requires an exact match\n" \ - "If a test does not match any list entry,\n" \ - "it is skipped unless some list entry starts with ~"); +#include "SkGr.h" void application_init() { SkGraphics::Init(); @@ -38,36 +28,37 @@ void application_term() { SkExampleWindow::SkExampleWindow(void* hwnd) : INHERITED(hwnd) { - fRegistry = SkExample::Registry::Head(); - fCurrExample = fRegistry->factory()(this); + fType = SkExampleWindow::kGPU_DeviceType; + fRenderTarget = NULL; + fRotationAngle = 0; + this->setTitle(); + this->setUpBackend(); +} - if (FLAGS_match.count()) { - // Start with the a matching sample if possible. - bool found = this->findNextMatch(); - if (!found) { - SkDebugf("No matching SkExample found.\n"); - } - } +SkExampleWindow::~SkExampleWindow() { + tearDownBackend(); } void SkExampleWindow::tearDownBackend() { - if (kGPU_DeviceType == fType) { - SkSafeUnref(fContext); - fContext = NULL; + SkSafeUnref(fContext); + fContext = NULL; - SkSafeUnref(fInterface); - fInterface = NULL; + SkSafeUnref(fInterface); + fInterface = NULL; - SkSafeUnref(fRenderTarget); - fRenderTarget = NULL; + SkSafeUnref(fRenderTarget); + fRenderTarget = NULL; - detach(); - } + INHERITED::detach(); } -bool SkExampleWindow::setupBackend(DeviceType type) { - fType = type; +void SkExampleWindow::setTitle() { + SkString title("SkiaExample "); + title.appendf(fType == kRaster_DeviceType ? "raster" : "opengl"); + INHERITED::setTitle(title.c_str()); +} +bool SkExampleWindow::setUpBackend() { this->setColorType(kRGBA_8888_SkColorType); this->setVisibleP(true); this->setClipToBounds(false); @@ -86,109 +77,117 @@ bool SkExampleWindow::setupBackend(DeviceType type) { fContext = GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)fInterface); SkASSERT(NULL != fContext); - setupRenderTarget(); - + this->setUpRenderTarget(); return true; } -void SkExampleWindow::setupRenderTarget() { - GrBackendRenderTargetDesc desc; - desc.fWidth = SkScalarRoundToInt(width()); - desc.fHeight = SkScalarRoundToInt(height()); - desc.fConfig = kSkia8888_GrPixelConfig; - desc.fOrigin = kBottomLeft_GrSurfaceOrigin; - desc.fSampleCnt = fAttachmentInfo.fSampleCount; - desc.fStencilBits = fAttachmentInfo.fStencilBits; - - GrGLint buffer; - GR_GL_GetIntegerv(fInterface, GR_GL_FRAMEBUFFER_BINDING, &buffer); - desc.fRenderTargetHandle = buffer; - - fRenderTarget = fContext->wrapBackendRenderTarget(desc); - - fContext->setRenderTarget(fRenderTarget); +void SkExampleWindow::setUpRenderTarget() { + SkSafeUnref(fRenderTarget); + fRenderTarget = this->renderTarget(fAttachmentInfo, fInterface, fContext); } -SkCanvas* SkExampleWindow::createCanvas() { - if (fType == kGPU_DeviceType) { - if (NULL != fContext && NULL != fRenderTarget) { - SkAutoTUnref device(new SkGpuDevice(fContext, fRenderTarget)); - return new SkCanvas(device); - } - tearDownBackend(); - setupBackend(kRaster_DeviceType); +void SkExampleWindow::drawContents(SkCanvas* canvas) { + // Clear background + canvas->drawColor(SK_ColorWHITE); + + SkPaint paint; + paint.setColor(SK_ColorRED); + + // Draw a rectangle with red paint + SkRect rect = { + 10, 10, + 128, 128 + }; + canvas->drawRect(rect, paint); + + // Set up a linear gradient and draw a circle + { + SkPoint linearPoints[] = { + {0, 0}, + {300, 300} + }; + SkColor linearColors[] = {SK_ColorGREEN, SK_ColorBLACK}; + + SkShader* shader = SkGradientShader::CreateLinear( + linearPoints, linearColors, NULL, 2, + SkShader::kMirror_TileMode); + SkAutoUnref shader_deleter(shader); + + paint.setShader(shader); + paint.setFlags(SkPaint::kAntiAlias_Flag); + + canvas->drawCircle(200, 200, 64, paint); + + // Detach shader + paint.setShader(NULL); } - return INHERITED::createCanvas(); + + // Draw a message with a nice black paint. + paint.setFlags( + SkPaint::kAntiAlias_Flag | + SkPaint::kSubpixelText_Flag | // ... avoid waggly text when rotating. + SkPaint::kUnderlineText_Flag); + paint.setColor(SK_ColorBLACK); + paint.setTextSize(20); + + canvas->save(); + + static const char message[] = "Hello Skia!!!"; + + // Translate and rotate + canvas->translate(300, 300); + fRotationAngle += 0.2f; + if (fRotationAngle > 360) { + fRotationAngle -= 360; + } + canvas->rotate(fRotationAngle); + + // Draw the text: + canvas->drawText(message, strlen(message), 0, 0, paint); + + canvas->restore(); } void SkExampleWindow::draw(SkCanvas* canvas) { - if (NULL != fCurrExample) { - fCurrExample->draw(canvas); - } - if (fType == kGPU_DeviceType) { + drawContents(canvas); + // in case we have queued drawing calls + fContext->flush(); + // Invalidate the window to force a redraw. Poor man's animation mechanism. + this->inval(NULL); - SkASSERT(NULL != fContext); - fContext->flush(); - } - if (fType == kRaster_DeviceType) { + if (kRaster_DeviceType == fType) { // need to send the raster bits to the (gpu) window - fContext->setRenderTarget(fRenderTarget); - const SkBitmap& bm = getBitmap(); - fRenderTarget->writePixels(0, 0, bm.width(), bm.height(), - kSkia8888_GrPixelConfig, - bm.getPixels(), - bm.rowBytes()); + SkImage* snap = fSurface->newImageSnapshot(); + size_t rowBytes; + SkImageInfo info; + const void* pixels = snap->peekPixels(&info, &rowBytes); + fRenderTarget->writePixels(0, 0, snap->width(), snap->height(), + SkImageInfo2GrPixelConfig(info.colorType(), + info.alphaType(), + info.profileType()), + pixels, + rowBytes, + GrContext::kFlushWrites_PixelOp); + SkSafeUnref(snap); } INHERITED::present(); } void SkExampleWindow::onSizeChange() { - setupRenderTarget(); -} - -#ifdef SK_BUILD_FOR_WIN -void SkExampleWindow::onHandleInval(const SkIRect& rect) { - RECT winRect; - winRect.top = rect.top(); - winRect.bottom = rect.bottom(); - winRect.right = rect.right(); - winRect.left = rect.left(); - InvalidateRect((HWND)this->getHWND(), &winRect, false); -} -#endif - -bool SkExampleWindow::findNextMatch() { - bool found = false; - // Avoid infinite loop by knowing where we started. - const SkExample::Registry* begin = fRegistry; - while (!found) { - fRegistry = fRegistry->next(); - if (NULL == fRegistry) { // Reached the end of the registered samples. GOTO head. - fRegistry = SkExample::Registry::Head(); - } - SkExample* next = fRegistry->factory()(this); - if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, next->getName().c_str())) { - fCurrExample = next; - found = true; - } - if (begin == fRegistry) { // We looped through every sample without finding anything. - break; - } - } - return found; + setUpRenderTarget(); } bool SkExampleWindow::onHandleChar(SkUnichar unichar) { - if ('n' == unichar) { - bool found = findNextMatch(); - if (!found) { - SkDebugf("No SkExample that matches your query\n"); - } + if (' ' == unichar) { + fType = fType == kRaster_DeviceType ? kGPU_DeviceType: kRaster_DeviceType; + tearDownBackend(); + setUpBackend(); + this->setTitle(); + this->inval(NULL); } return true; } -SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { - SkCommandLineFlags::Parse(argc, argv); +SkOSWindow* create_sk_window(void* hwnd, int , char** ) { return new SkExampleWindow(hwnd); } diff --git a/experimental/SkiaExamples/SkExample.h b/experimental/SkiaExamples/SkExample.h index ee9e36e0d0..4f4b10be55 100644 --- a/experimental/SkiaExamples/SkExample.h +++ b/experimental/SkiaExamples/SkExample.h @@ -10,6 +10,7 @@ #ifndef SkExample_DEFINED #define SkExample_DEFINED +#include "SkSurface.h" #include "SkWindow.h" #include "SkTRegistry.h" @@ -44,33 +45,42 @@ public: kGPU_DeviceType, }; SkExampleWindow(void* hwnd); + virtual ~SkExampleWindow() SK_OVERRIDE; // Changes the device type of the object. - bool setupBackend(DeviceType type); - void tearDownBackend(); + bool setUpBackend(); DeviceType getDeviceType() const { return fType; } protected: + SkSurface* createSurface() SK_OVERRIDE { + if (kGPU_DeviceType == fType) { + SkSurfaceProps props(INHERITED::getSurfaceProps()); + return SkSurface::NewRenderTargetDirect(fRenderTarget, &props); + } + static const SkImageInfo info = SkImageInfo::MakeN32Premul( + SkScalarRoundToInt(this->width()), SkScalarRoundToInt(this->height())); + return fSurface = SkSurface::NewRaster(info); + } + void draw(SkCanvas* canvas) SK_OVERRIDE; + void drawContents(SkCanvas* canvas); void onSizeChange() SK_OVERRIDE; -#ifdef SK_BUILD_FOR_WIN - void onHandleInval(const SkIRect&) SK_OVERRIDE; -#endif - - SkCanvas* createCanvas() SK_OVERRIDE; - private: bool findNextMatch(); // Set example to the first one that matches FLAGS_match. - void setupRenderTarget(); + void setTitle(); + void setUpRenderTarget(); bool onHandleChar(SkUnichar unichar) SK_OVERRIDE; + void tearDownBackend(); + // draw contents + SkScalar fRotationAngle; + + // support framework DeviceType fType; - - SkExample* fCurrExample; - const SkExample::Registry* fRegistry; + SkSurface* fSurface; GrContext* fContext; GrRenderTarget* fRenderTarget; AttachmentInfo fAttachmentInfo; diff --git a/gyp/experimental.gyp b/gyp/experimental.gyp index ffc1753e68..ff7e144c5b 100644 --- a/gyp/experimental.gyp +++ b/gyp/experimental.gyp @@ -26,7 +26,6 @@ 'sources': [ '../experimental/SkiaExamples/SkExample.h', '../experimental/SkiaExamples/SkExample.cpp', - '../experimental/SkiaExamples/HelloSkiaExample.cpp', ], 'dependencies': [ 'flags.gyp:flags', @@ -36,7 +35,7 @@ 'conditions' : [ [ 'skia_gpu == 1', { 'include_dirs' : [ - '../src/gpu', + '../include/gpu', ], }], [ 'skia_os == "win"', { diff --git a/gyp/views.gyp b/gyp/views.gyp index 55fb6dad22..381e125393 100644 --- a/gyp/views.gyp +++ b/gyp/views.gyp @@ -77,6 +77,11 @@ '../src/views/SDL/SkOSWindow_SDL.cpp', ], 'conditions': [ + [ 'skia_gpu == 1', { + 'include_dirs' : [ + '../src/gpu', + ], + }], [ 'skia_os == "mac"', { 'link_settings': { 'libraries': [ diff --git a/include/views/SkOSWindow_Android.h b/include/views/SkOSWindow_Android.h index 9b0dcb282e..3b23d29b71 100644 --- a/include/views/SkOSWindow_Android.h +++ b/include/views/SkOSWindow_Android.h @@ -20,11 +20,6 @@ public: kNativeGL_BackEndType, }; - struct AttachmentInfo { - int fSampleCount; - int fStencilBits; - }; - bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo* info); void detach() {} void present() {} diff --git a/include/views/SkOSWindow_Mac.h b/include/views/SkOSWindow_Mac.h index 5dea2fc12e..2a15bf5f67 100644 --- a/include/views/SkOSWindow_Mac.h +++ b/include/views/SkOSWindow_Mac.h @@ -26,11 +26,6 @@ public: #endif }; - struct AttachmentInfo { - int fSampleCount; - int fStencilBits; - }; - void detach(); bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); void present(); diff --git a/include/views/SkOSWindow_NaCl.h b/include/views/SkOSWindow_NaCl.h index 317ef9f7df..26263371d9 100644 --- a/include/views/SkOSWindow_NaCl.h +++ b/include/views/SkOSWindow_NaCl.h @@ -20,11 +20,6 @@ public: kNativeGL_BackEndType, }; - struct AttachmentInfo { - int fSampleCount; - int fStencilBits; - }; - bool attach(SkBackEndTypes /* attachType */, int /* msaaSampleCount */, AttachmentInfo* info) { info->fSampleCount = 0; info->fStencilBits = 0; diff --git a/include/views/SkOSWindow_Unix.h b/include/views/SkOSWindow_Unix.h index 525123c3d3..8c4d81962a 100644 --- a/include/views/SkOSWindow_Unix.h +++ b/include/views/SkOSWindow_Unix.h @@ -38,11 +38,6 @@ public: kNativeGL_BackEndType, }; - struct AttachmentInfo { - int fSampleCount; - int fStencilBits; - }; - bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); void detach(); void present(); diff --git a/include/views/SkOSWindow_Win.h b/include/views/SkOSWindow_Win.h index 6b5977ce3f..fe65459f4d 100644 --- a/include/views/SkOSWindow_Win.h +++ b/include/views/SkOSWindow_Win.h @@ -37,11 +37,6 @@ public: #endif // SK_SUPPORT_GPU }; - struct AttachmentInfo { - int fSampleCount; - int fStencilBits; - }; - bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); void detach(); void present(); diff --git a/include/views/SkOSWindow_iOS.h b/include/views/SkOSWindow_iOS.h index 1984900ded..f386c738f9 100644 --- a/include/views/SkOSWindow_iOS.h +++ b/include/views/SkOSWindow_iOS.h @@ -21,11 +21,6 @@ public: kNativeGL_BackEndType, }; - struct AttachmentInfo { - int fSampleCount; - int fStencilBits; - }; - void detach(); bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); void present(); diff --git a/include/views/SkWindow.h b/include/views/SkWindow.h index e18aff3512..76a1aa5947 100644 --- a/include/views/SkWindow.h +++ b/include/views/SkWindow.h @@ -25,11 +25,22 @@ class SkSurface; class SkOSMenu; +#if SK_SUPPORT_GPU +struct GrGLInterface; +class GrContext; +class GrRenderTarget; +#endif + class SkWindow : public SkView { public: SkWindow(); virtual ~SkWindow(); + struct AttachmentInfo { + int fSampleCount; + int fStencilBits; + }; + SkSurfaceProps getSurfaceProps() const { return fSurfaceProps; } void setSurfaceProps(const SkSurfaceProps& props) { fSurfaceProps = props; @@ -85,6 +96,11 @@ protected: virtual bool onGetFocusView(SkView** focus) const; virtual bool onSetFocusView(SkView* focus); +#if SK_SUPPORT_GPU + GrRenderTarget* renderTarget(const AttachmentInfo& attachmentInfo, + const GrGLInterface* , GrContext* grContext); +#endif + private: SkSurfaceProps fSurfaceProps; SkColorType fColorType; diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index aa2130e8f0..dd771cec2d 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -315,20 +315,8 @@ public: if (fCurContext) { AttachmentInfo attachmentInfo; win->attach(fBackend, fMSAASampleCount, &attachmentInfo); - - GrBackendRenderTargetDesc desc; - desc.fWidth = SkScalarRoundToInt(win->width()); - desc.fHeight = SkScalarRoundToInt(win->height()); - desc.fConfig = kSkia8888_GrPixelConfig; - desc.fOrigin = kBottomLeft_GrSurfaceOrigin; - desc.fSampleCnt = attachmentInfo.fSampleCount; - desc.fStencilBits = attachmentInfo.fStencilBits; - GrGLint buffer; - GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer); - desc.fRenderTargetHandle = buffer; - SkSafeUnref(fCurRenderTarget); - fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc); + fCurRenderTarget = win->renderTarget(attachmentInfo, fCurIntf, fCurContext); } #endif } diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp index 7870d06bfe..61eaa978b1 100644 --- a/src/views/SkWindow.cpp +++ b/src/views/SkWindow.cpp @@ -341,3 +341,26 @@ bool SkWindow::onDispatchClick(int x, int y, Click::State state, } return handled; } + +#if SK_SUPPORT_GPU + +#include "gl/GrGLInterface.h" +#include "gl/GrGLUtil.h" +#include "SkGr.h" + +GrRenderTarget* SkWindow::renderTarget(const AttachmentInfo& attachmentInfo, + const GrGLInterface* interface, GrContext* grContext) { + GrBackendRenderTargetDesc desc; + desc.fWidth = SkScalarRoundToInt(this->width()); + desc.fHeight = SkScalarRoundToInt(this->height()); + desc.fConfig = kSkia8888_GrPixelConfig; + desc.fOrigin = kBottomLeft_GrSurfaceOrigin; + desc.fSampleCnt = attachmentInfo.fSampleCount; + desc.fStencilBits = attachmentInfo.fStencilBits; + GrGLint buffer; + GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer); + desc.fRenderTargetHandle = buffer; + return grContext->wrapBackendRenderTarget(desc); +} + +#endif diff --git a/tools/flags/SkCommandLineFlags.cpp b/tools/flags/SkCommandLineFlags.cpp index dc99fec8cd..50c193fdf2 100644 --- a/tools/flags/SkCommandLineFlags.cpp +++ b/tools/flags/SkCommandLineFlags.cpp @@ -303,6 +303,11 @@ void SkCommandLineFlags::Parse(int argc, char** argv) { flag = flag->next(); } if (!flagMatched) { +#if SK_BUILD_FOR_MAC + if (SkStrStartsWith(argv[i], "NSDocumentRevisions")) { + i++; // skip YES + } else +#endif if (!FLAGS_undefok) { SkDebugf("Got unknown flag \"%s\". Exiting.\n", argv[i]); exit(-1);