From 52edc4d05380c88de5b334479ad8e537ef2b4925 Mon Sep 17 00:00:00 2001 From: caryclark Date: Mon, 2 Feb 2015 12:55:14 -0800 Subject: [PATCH] move HelloWorld to be a peer of SampleApp This is working towards making a simple example part of the buildbot compile step and removing SkExamples from the experimental directory. This works on Mac, Windows, and Linux but isn't complete for Android, ChromeOS and iOS. Review URL: https://codereview.chromium.org/886413004 --- example/HelloWorld.cpp | 193 ++ example/HelloWorld.h | 72 + example/mac/HelloWorld-Info.plist | 32 + example/mac/HelloWorld.xib | 3661 +++++++++++++++++++++++++++++++++++++ example/mac/HelloWorldDelegate.h | 27 + example/mac/HelloWorldDelegate.mm | 27 + example/mac/HelloWorldNSView.h | 13 + example/mac/HelloWorldNSView.mm | 27 + gyp/example.gyp | 51 + gyp/most.gyp | 12 +- 10 files changed, 4114 insertions(+), 1 deletion(-) create mode 100644 example/HelloWorld.cpp create mode 100644 example/HelloWorld.h create mode 100644 example/mac/HelloWorld-Info.plist create mode 100644 example/mac/HelloWorld.xib create mode 100644 example/mac/HelloWorldDelegate.h create mode 100644 example/mac/HelloWorldDelegate.mm create mode 100644 example/mac/HelloWorldNSView.h create mode 100644 example/mac/HelloWorldNSView.mm create mode 100644 gyp/example.gyp diff --git a/example/HelloWorld.cpp b/example/HelloWorld.cpp new file mode 100644 index 0000000..495d2af --- /dev/null +++ b/example/HelloWorld.cpp @@ -0,0 +1,193 @@ +/* + * Copyright 2015 Google Inc. + * + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + */ + +#include "HelloWorld.h" + +#include "gl/GrGLInterface.h" +#include "SkApplication.h" +#include "SkCanvas.h" +#include "SkGradientShader.h" +#include "SkGraphics.h" +#include "SkGr.h" + +void application_init() { + SkGraphics::Init(); + SkEvent::Init(); +} + +void application_term() { + SkEvent::Term(); + SkGraphics::Term(); +} + +HelloWorldWindow::HelloWorldWindow(void* hwnd) + : INHERITED(hwnd) { + fType = kGPU_DeviceType; + fRenderTarget = NULL; + fRotationAngle = 0; + this->setTitle(); + this->setUpBackend(); +} + +HelloWorldWindow::~HelloWorldWindow() { + tearDownBackend(); +} + +void HelloWorldWindow::tearDownBackend() { + SkSafeUnref(fContext); + fContext = NULL; + + SkSafeUnref(fInterface); + fInterface = NULL; + + SkSafeUnref(fRenderTarget); + fRenderTarget = NULL; + + INHERITED::detach(); +} + +void HelloWorldWindow::setTitle() { + SkString title("Hello World "); + title.appendf(fType == kRaster_DeviceType ? "raster" : "opengl"); + INHERITED::setTitle(title.c_str()); +} + +bool HelloWorldWindow::setUpBackend() { + this->setColorType(kRGBA_8888_SkColorType); + this->setVisibleP(true); + this->setClipToBounds(false); + + bool result = attach(kNativeGL_BackEndType, 0 /*msaa*/, &fAttachmentInfo); + if (false == result) { + SkDebugf("Not possible to create backend.\n"); + detach(); + return false; + } + + fInterface = GrGLCreateNativeInterface(); + + SkASSERT(NULL != fInterface); + + fContext = GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)fInterface); + SkASSERT(NULL != fContext); + + this->setUpRenderTarget(); + return true; +} + +void HelloWorldWindow::setUpRenderTarget() { + SkSafeUnref(fRenderTarget); + fRenderTarget = this->renderTarget(fAttachmentInfo, fInterface, fContext); +} + +void HelloWorldWindow::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); + } + + // 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 World"; + + // 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 HelloWorldWindow::draw(SkCanvas* canvas) { + 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); + + if (kRaster_DeviceType == fType) { + // need to send the raster bits to the (gpu) window + 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 HelloWorldWindow::onSizeChange() { + setUpRenderTarget(); +} + +bool HelloWorldWindow::onHandleChar(SkUnichar unichar) { + 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 , char** ) { + return new HelloWorldWindow(hwnd); +} diff --git a/example/HelloWorld.h b/example/HelloWorld.h new file mode 100644 index 0000000..e5cde27 --- /dev/null +++ b/example/HelloWorld.h @@ -0,0 +1,72 @@ +/* + * Copyright 2015 Google Inc. + * + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + */ + +#ifndef HelloWorld_DEFINED +#define HelloWorld_DEFINED + +#include "SkSurface.h" +#include "SkWindow.h" + +class GrContext; +struct GrGLInterface; +class GrRenderTarget; +class SkCanvas; + +class HelloWorldWindow : public SkOSWindow { +public: + enum DeviceType { + kRaster_DeviceType, + kGPU_DeviceType, + }; + HelloWorldWindow(void* hwnd); + virtual ~HelloWorldWindow() SK_OVERRIDE; + + // Changes the device type of the object. + 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; + +private: + bool findNextMatch(); // Set example to the first one that matches FLAGS_match. + void setTitle(); + void setUpRenderTarget(); + bool onHandleChar(SkUnichar unichar) SK_OVERRIDE; + void tearDownBackend(); + + // draw contents + SkScalar fRotationAngle; + + // support framework + DeviceType fType; + SkSurface* fSurface; + GrContext* fContext; + GrRenderTarget* fRenderTarget; + AttachmentInfo fAttachmentInfo; + const GrGLInterface* fInterface; + + typedef SkOSWindow INHERITED; +}; + +#endif diff --git a/example/mac/HelloWorld-Info.plist b/example/mac/HelloWorld-Info.plist new file mode 100644 index 0000000..e9a9aa4 --- /dev/null +++ b/example/mac/HelloWorld-Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIdentifier + com.googlecode.skia.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSMinimumSystemVersion + ${MACOSX_DEPLOYMENT_TARGET} + NSMainNibFile + HelloWorld + NSPrincipalClass + NSApplication + + diff --git a/example/mac/HelloWorld.xib b/example/mac/HelloWorld.xib new file mode 100644 index 0000000..8ff60a2 --- /dev/null +++ b/example/mac/HelloWorld.xib @@ -0,0 +1,3661 @@ + + + + 1070 + 12D78 + 3084 + 1187.37 + 626.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 3084 + + + NSCustomObject + NSCustomView + NSDrawer + NSMenu + NSMenuItem + NSScrollView + NSScroller + NSTableColumn + NSTableView + NSTextFieldCell + NSView + NSWindowTemplate + + + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + + NSApplication + + + FirstResponder + + + NSApplication + + + HelloWorldDelegate + + + NSWindowController + + + 15 + 2 + {{335, 288}, {640, 480}} + 1417150464 + Hello World + NSWindow + + + + + 256 + {640, 480} + + + + {{0, 0}, {1280, 778}} + {10000000000000, 10000000000000} + YES + + + + 4352 + + + + 274 + + + + 2304 + + + + 256 + {339, 319} + + YES + NO + YES + + + -2147483392 + {{224, 0}, {16, 17}} + + + + Labels + 100 + 40 + 1000 + + 75497536 + 2048 + + + LucidaGrande + 11 + 3100 + + + 3 + MC4zMzMzMzI5ODU2AA + + + 6 + System + headerTextColor + + 3 + MAA + + + + + 68157504 + 67241216 + Text Cell + + + + 6 + System + controlBackgroundColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + controlTextColor + + + + 3 + YES + YES + + + + Controls + 233 + 40 + 1000 + + 75497536 + 2048 + + + + + + + 67108928 + 272630784 + Text + + LucidaGrande + 13 + 1044 + + + + 6 + System + controlColor + + + + + 3 + YES + YES + + + + 3 + 2 + + 6 + System + _sourceListBackgroundColor + + 6 + System + alternateSelectedControlColor + + 1 + MCAwIDEAA + + + + + 6 + System + gridColor + + 3 + MC41AA + + + 35 + 1665138688 + + + 2 + 4 + 15 + 0 + NO + 1 + 1 + 1 + + + {{1, 1}, {339, 319}} + + + + + 4 + + + + -2147483392 + {{317, 1}, {15, 574}} + + NO + + _doScroller: + 0.99687498807907104 + + + + -2147483392 + {{1, 263}, {157, 15}} + + NO + 1 + + _doScroller: + 0.99705880880355835 + + + {341, 321} + + + 133682 + + + + QSAAAEEgAABCFAAAQhQAAA + 0.25 + 4 + 1 + + + {341, 321} + YES + NSView + + + + {300, 100} + {0, 0} + {10000, 10000} + 2 + 0.0 + 15 + + + + + AMainMenu + + + + SimpleCocoaApp + + 1048576 + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + submenuAction: + + SimpleCocoaApp + + + + About SimpleCocoaApp + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Show Options +  + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Preferences… + , + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Services + + 1048576 + 2147483647 + + + submenuAction: + + Services + + _NSServicesMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Hide SimpleCocoaApp + h + 1048576 + 2147483647 + + + + + + Hide Others + h + 1572864 + 2147483647 + + + + + + Show All + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Quit SimpleCocoaApp + q + 1048576 + 2147483647 + + + + + _NSAppleMenu + + + + + File + + 1048576 + 2147483647 + + + submenuAction: + + File + + + + New + n + 1048576 + 2147483647 + + + + + + Open… + o + 1048576 + 2147483647 + + + + + + Open Recent + + 1048576 + 2147483647 + + + submenuAction: + + Open Recent + + + + Clear Menu + + 1048576 + 2147483647 + + + + + _NSRecentDocumentsMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Close + w + 1048576 + 2147483647 + + + + + + Save + s + 1048576 + 2147483647 + + + + + + Save As… + S + 1179648 + 2147483647 + + + + + + Revert to Saved + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Page Setup... + P + 1179648 + 2147483647 + + + + + + + Print… + p + 1048576 + 2147483647 + + + + + + + + + Edit + + 1048576 + 2147483647 + + + submenuAction: + + Edit + + + + Undo + z + 1048576 + 2147483647 + + + + + + Redo + Z + 1179648 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Cut + x + 1048576 + 2147483647 + + + + + + Copy + c + 1048576 + 2147483647 + + + + + + Paste + v + 1048576 + 2147483647 + + + + + + Paste and Match Style + V + 1572864 + 2147483647 + + + + + + Delete + + 1048576 + 2147483647 + + + + + + Select All + a + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Find + + 1048576 + 2147483647 + + + submenuAction: + + Find + + + + Find… + f + 1048576 + 2147483647 + + + 1 + + + + Find Next + g + 1048576 + 2147483647 + + + 2 + + + + Find Previous + G + 1179648 + 2147483647 + + + 3 + + + + Use Selection for Find + e + 1048576 + 2147483647 + + + 7 + + + + Jump to Selection + j + 1048576 + 2147483647 + + + + + + + + + Spelling and Grammar + + 1048576 + 2147483647 + + + submenuAction: + + Spelling and Grammar + + + + Show Spelling and Grammar + : + 1048576 + 2147483647 + + + + + + Check Document Now + ; + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Check Spelling While Typing + + 1048576 + 2147483647 + + + + + + Check Grammar With Spelling + + 1048576 + 2147483647 + + + + + + Correct Spelling Automatically + + 2147483647 + + + + + + + + + Substitutions + + 1048576 + 2147483647 + + + submenuAction: + + Substitutions + + + + Show Substitutions + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Smart Copy/Paste + f + 1048576 + 2147483647 + + + 1 + + + + Smart Quotes + g + 1048576 + 2147483647 + + + 2 + + + + Smart Dashes + + 2147483647 + + + + + + Smart Links + G + 1179648 + 2147483647 + + + 3 + + + + Text Replacement + + 2147483647 + + + + + + + + + Transformations + + 2147483647 + + + submenuAction: + + Transformations + + + + Make Upper Case + + 2147483647 + + + + + + Make Lower Case + + 2147483647 + + + + + + Capitalize + + 2147483647 + + + + + + + + + Speech + + 1048576 + 2147483647 + + + submenuAction: + + Speech + + + + Start Speaking + + 1048576 + 2147483647 + + + + + + Stop Speaking + + 1048576 + 2147483647 + + + + + + + + + + + + View + + 1048576 + 2147483647 + + + submenuAction: + + View + + + + Show Menu Key Equivalents + + 2147483647 + 1 + + + + + + Show Toolbar + t + 1572864 + 2147483647 + + + + + + Customize Toolbar… + + 1048576 + 2147483647 + + + + + + + + + Format + + 2147483647 + + + submenuAction: + + Format + + + + Font + + 2147483647 + + + submenuAction: + + Font + + + + Show Fonts + t + 1048576 + 2147483647 + + + + + + Bold + b + 1048576 + 2147483647 + + + 2 + + + + Italic + i + 1048576 + 2147483647 + + + 1 + + + + Underline + u + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Bigger + + + 1048576 + 2147483647 + + + 3 + + + + Smaller + - + 1048576 + 2147483647 + + + 4 + + + + YES + YES + + + 2147483647 + + + + + + Kern + + 2147483647 + + + submenuAction: + + Kern + + + + Use Default + + 2147483647 + + + + + + Use None + + 2147483647 + + + + + + Tighten + + 2147483647 + + + + + + Loosen + + 2147483647 + + + + + + + + + Ligature + + 2147483647 + + + submenuAction: + + Ligature + + + + Use Default + + 2147483647 + + + + + + Use None + + 2147483647 + + + + + + Use All + + 2147483647 + + + + + + + + + Baseline + + 2147483647 + + + submenuAction: + + Baseline + + + + Use Default + + 2147483647 + + + + + + Superscript + + 2147483647 + + + + + + Subscript + + 2147483647 + + + + + + Raise + + 2147483647 + + + + + + Lower + + 2147483647 + + + + + + + + + YES + YES + + + 2147483647 + + + + + + Show Colors + C + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Copy Style + c + 1572864 + 2147483647 + + + + + + Paste Style + v + 1572864 + 2147483647 + + + + + _NSFontMenu + + + + + Text + + 2147483647 + + + submenuAction: + + Text + + + + Align Left + { + 1048576 + 2147483647 + + + + + + Center + | + 1048576 + 2147483647 + + + + + + Justify + + 2147483647 + + + + + + Align Right + } + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Writing Direction + + 2147483647 + + + submenuAction: + + Writing Direction + + + + YES + Paragraph + + 2147483647 + + + + + + CURlZmF1bHQ + + 2147483647 + + + + + + CUxlZnQgdG8gUmlnaHQ + + 2147483647 + + + + + + CVJpZ2h0IHRvIExlZnQ + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + YES + Selection + + 2147483647 + + + + + + CURlZmF1bHQ + + 2147483647 + + + + + + CUxlZnQgdG8gUmlnaHQ + + 2147483647 + + + + + + CVJpZ2h0IHRvIExlZnQ + + 2147483647 + + + + + + + + + YES + YES + + + 2147483647 + + + + + + Show Ruler + + 2147483647 + + + + + + Copy Ruler + c + 1310720 + 2147483647 + + + + + + Paste Ruler + v + 1310720 + 2147483647 + + + + + + + + + + + + Window + + 1048576 + 2147483647 + + + submenuAction: + + Window + + + + Minimize + m + 1048576 + 2147483647 + + + + + + Zoom + + 1048576 + 2147483647 + + + + + + 768 x 1024 + = + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Bring All to Front + + 1048576 + 2147483647 + + + + + _NSWindowsMenu + + + + + Help + + 2147483647 + + + submenuAction: + + Help + + + + SimpleCocoaApp Help + ? + 1048576 + 2147483647 + + + + + _NSHelpMenu + + + + _NSMainMenu + + + NSFontManager + + + + + + + terminate: + + + + 449 + + + + orderFrontStandardAboutPanel: + + + + 142 + + + + delegate + + + + 656 + + + + performMiniaturize: + + + + 37 + + + + arrangeInFront: + + + + 39 + + + + print: + + + + 86 + + + + runPageLayout: + + + + 87 + + + + clearRecentDocuments: + + + + 127 + + + + performClose: + + + + 193 + + + + toggleContinuousSpellChecking: + + + + 222 + + + + undo: + + + + 223 + + + + copy: + + + + 224 + + + + checkSpelling: + + + + 225 + + + + paste: + + + + 226 + + + + stopSpeaking: + + + + 227 + + + + cut: + + + + 228 + + + + showGuessPanel: + + + + 230 + + + + redo: + + + + 231 + + + + selectAll: + + + + 232 + + + + startSpeaking: + + + + 233 + + + + delete: + + + + 235 + + + + performZoom: + + + + 240 + + + + performFindPanelAction: + + + + 241 + + + + centerSelectionInVisibleArea: + + + + 245 + + + + toggleGrammarChecking: + + + + 347 + + + + toggleSmartInsertDelete: + + + + 355 + + + + toggleAutomaticQuoteSubstitution: + + + + 356 + + + + toggleAutomaticLinkDetection: + + + + 357 + + + + saveDocument: + + + + 362 + + + + saveDocumentAs: + + + + 363 + + + + revertDocumentToSaved: + + + + 364 + + + + runToolbarCustomizationPalette: + + + + 365 + + + + toggleToolbarShown: + + + + 366 + + + + hide: + + + + 367 + + + + hideOtherApplications: + + + + 368 + + + + unhideAllApplications: + + + + 370 + + + + newDocument: + + + + 373 + + + + openDocument: + + + + 374 + + + + raiseBaseline: + + + + 426 + + + + lowerBaseline: + + + + 427 + + + + copyFont: + + + + 428 + + + + subscript: + + + + 429 + + + + superscript: + + + + 430 + + + + tightenKerning: + + + + 431 + + + + underline: + + + + 432 + + + + orderFrontColorPanel: + + + + 433 + + + + useAllLigatures: + + + + 434 + + + + loosenKerning: + + + + 435 + + + + pasteFont: + + + + 436 + + + + unscript: + + + + 437 + + + + useStandardKerning: + + + + 438 + + + + useStandardLigatures: + + + + 439 + + + + turnOffLigatures: + + + + 440 + + + + turnOffKerning: + + + + 441 + + + + toggleAutomaticSpellingCorrection: + + + + 456 + + + + orderFrontSubstitutionsPanel: + + + + 458 + + + + toggleAutomaticDashSubstitution: + + + + 461 + + + + toggleAutomaticTextReplacement: + + + + 463 + + + + uppercaseWord: + + + + 464 + + + + capitalizeWord: + + + + 467 + + + + lowercaseWord: + + + + 468 + + + + pasteAsPlainText: + + + + 486 + + + + performFindPanelAction: + + + + 487 + + + + performFindPanelAction: + + + + 488 + + + + performFindPanelAction: + + + + 489 + + + + showHelp: + + + + 493 + + + + alignCenter: + + + + 518 + + + + pasteRuler: + + + + 519 + + + + toggleRuler: + + + + 520 + + + + alignRight: + + + + 521 + + + + copyRuler: + + + + 522 + + + + alignJustified: + + + + 523 + + + + alignLeft: + + + + 524 + + + + makeBaseWritingDirectionNatural: + + + + 525 + + + + makeBaseWritingDirectionLeftToRight: + + + + 526 + + + + makeBaseWritingDirectionRightToLeft: + + + + 527 + + + + makeTextWritingDirectionNatural: + + + + 528 + + + + makeTextWritingDirectionLeftToRight: + + + + 529 + + + + makeTextWritingDirectionRightToLeft: + + + + 530 + + + + fOptionsDelegate + + + + 667 + + + + addFontTrait: + + + + 421 + + + + addFontTrait: + + + + 422 + + + + modifyFont: + + + + 423 + + + + orderFrontFontPanel: + + + + 424 + + + + modifyFont: + + + + 425 + + + + fWindow + + + + 673 + + + + fOptions + + + + 674 + + + + fView + + + + 682 + + + + toiPadSize: + + + + 721 + + + + contentView + + + + 542 + + + + parentWindow + + + + 651 + + + + toggle: + + + + 707 + + + + + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 29 + + + + + + + + + + + + + + 19 + + + + + + + + 56 + + + + + + + + 217 + + + + + + + + 83 + + + + + + + + 81 + + + + + + + + + + + + + + + + + + 75 + + + + + 80 + + + + + 78 + + + + + 72 + + + + + 82 + + + + + 124 + + + + + + + + 77 + + + + + 73 + + + + + 79 + + + + + 112 + + + + + 74 + + + + + 125 + + + + + + + + 126 + + + + + 205 + + + + + + + + + + + + + + + + + + + + + + 202 + + + + + 198 + + + + + 207 + + + + + 214 + + + + + 199 + + + + + 203 + + + + + 197 + + + + + 206 + + + + + 215 + + + + + 218 + + + + + + + + 216 + + + + + + + + 200 + + + + + + + + + + + + + 219 + + + + + 201 + + + + + 204 + + + + + 220 + + + + + + + + + + + + 213 + + + + + 210 + + + + + 221 + + + + + 208 + + + + + 209 + + + + + 57 + + + + + + + + + + + + + + + + + + + + 58 + + + + + 134 + + + + + 150 + + + + + 136 + + + + + 144 + + + + + 129 + + + + + 143 + + + + + 236 + + + + + 131 + + + + + + + + 149 + + + + + 145 + + + + + 130 + + + + + 24 + + + + + + + + + + + + 92 + + + + + 5 + + + + + 239 + + + + + 23 + + + + + 295 + + + + + + + + 296 + + + + + + + + + + 297 + + + + + 298 + + + + + 211 + + + + + + + + 212 + + + + + + + + + 195 + + + + + 196 + + + + + 346 + + + + + 348 + + + + + + + + 349 + + + + + + + + + + + + + + 350 + + + + + 351 + + + + + 354 + + + + + 371 + + + + + + + + 372 + + + + + + 375 + + + + + + + + 376 + + + + + + + + + 377 + + + + + + + + 388 + + + + + + + + + + + + + + + + + + + + + + + 389 + + + + + 390 + + + + + 391 + + + + + 392 + + + + + 393 + + + + + 394 + + + + + 395 + + + + + 396 + + + + + 397 + + + + + + + + 398 + + + + + + + + 399 + + + + + + + + 400 + + + + + 401 + + + + + 402 + + + + + 403 + + + + + 404 + + + + + 405 + + + + + + + + + + + + 406 + + + + + 407 + + + + + 408 + + + + + 409 + + + + + 410 + + + + + 411 + + + + + + + + + + 412 + + + + + 413 + + + + + 414 + + + + + 415 + + + + + + + + + + + 416 + + + + + 417 + + + + + 418 + + + + + 419 + + + + + 420 + + + + + 450 + + + + + + + + 451 + + + + + + + + + + 452 + + + + + 453 + + + + + 454 + + + + + 457 + + + + + 459 + + + + + 460 + + + + + 462 + + + + + 465 + + + + + 466 + + + + + 485 + + + + + 490 + + + + + + + + 491 + + + + + + + + 492 + + + + + 496 + + + + + + + + 497 + + + + + + + + + + + + + + + + + 498 + + + + + 499 + + + + + 500 + + + + + 501 + + + + + 502 + + + + + 503 + + + + + + + + 504 + + + + + 505 + + + + + 506 + + + + + 507 + + + + + 508 + + + + + + + + + + + + + + + + 509 + + + + + 510 + + + + + 511 + + + + + 512 + + + + + 513 + + + + + 514 + + + + + 515 + + + + + 516 + + + + + 517 + + + + + 538 + + + + + + Drawer Content View + + + 539 + + + + + 629 + + + + + + + + + + 630 + + + + + 631 + + + + + 632 + + + + + + + + + 634 + + + + + + + + 637 + + + + + 494 + + + + + 661 + + + + + 635 + + + + + + + + 698 + + + + + 705 + + + + + 706 + + + + + 718 + + + + + 720 + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{254, 23}, {640, 480}} + + HelloWorldNSView + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + + 721 + + + + + HelloWorldDelegate + NSObject + + toiPadSize: + id + + + toiPadSize: + + toiPadSize: + id + + + + SkSampleNSView + NSWindow + + + + fView + SkSampleNSView + + + fWindow + NSWindow + + + + IBProjectSource + ./Classes/HelloWorldDelegate.h + + + + HelloWorldNSView + SkNSView + + IBProjectSource + ./Classes/HelloWorldNSView.h + + + + SkNSView + NSView + + IBProjectSource + ./Classes/SkNSView.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + YES + 3 + + {11, 11} + {10, 3} + + + diff --git a/example/mac/HelloWorldDelegate.h b/example/mac/HelloWorldDelegate.h new file mode 100644 index 0000000..40e910b --- /dev/null +++ b/example/mac/HelloWorldDelegate.h @@ -0,0 +1,27 @@ + +/* + * Copyright 2011 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + +#import +#import "SkSampleNSView.h" +#import "SkOptionsTableView.h" +@interface HelloWorldDelegate : NSObject { + NSWindow* fWindow; + SkSampleNSView* fView; + SkOptionsTableView* fOptions; +} + +@property (assign) IBOutlet NSWindow* fWindow; +@property (assign) IBOutlet SkSampleNSView* fView; +@property (assign) IBOutlet SkOptionsTableView* fOptions; + +- (IBAction)toiPadSize:(id)sender; + +- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; + +@end diff --git a/example/mac/HelloWorldDelegate.mm b/example/mac/HelloWorldDelegate.mm new file mode 100644 index 0000000..f3c0810 --- /dev/null +++ b/example/mac/HelloWorldDelegate.mm @@ -0,0 +1,27 @@ +#import "HelloWorldDelegate.h" + +#include "SkApplication.h" + +@implementation HelloWorldDelegate +@synthesize fWindow, fView, fOptions; + +// for iOS +-(void) applicationDidFinishLaunching:(NSNotification *)aNotification { + //Load specified skia views after launching + fView.fOptionsDelegate = fOptions; + [fWindow setAcceptsMouseMovedEvents:YES]; + // [fOptions registerMenus:fView.fWind->getMenus()]; +} + +- (IBAction)toiPadSize:(id)sender { + NSRect frame = NSMakeRect(fWindow.frame.origin.x, fWindow.frame.origin.y, 768, 1024); + [fWindow setFrame:frame display:YES animate:YES]; +} + +- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { + [fView freeNativeWind]; + application_term(); + return NSTerminateNow; +} + +@end diff --git a/example/mac/HelloWorldNSView.h b/example/mac/HelloWorldNSView.h new file mode 100644 index 0000000..3de780f --- /dev/null +++ b/example/mac/HelloWorldNSView.h @@ -0,0 +1,13 @@ + +/* + * Copyright 2013 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#import "SkNSView.h" + +@interface HelloWorldNSView : SkNSView + +@end diff --git a/example/mac/HelloWorldNSView.mm b/example/mac/HelloWorldNSView.mm new file mode 100644 index 0000000..dcc82e3 --- /dev/null +++ b/example/mac/HelloWorldNSView.mm @@ -0,0 +1,27 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#import "HelloWorldNSView.h" + +#include "SkApplication.h" +#include + +@implementation HelloWorldNSView + +- (id)initWithDefaults { + if ((self = [super initWithDefaults])) { + fWind = create_sk_window(self, *_NSGetArgc(), *_NSGetArgv()); + } + return self; +} + +- (void)dealloc { + delete fWind; + [super dealloc]; +} + +@end diff --git a/gyp/example.gyp b/gyp/example.gyp new file mode 100644 index 0000000..34a7982 --- /dev/null +++ b/gyp/example.gyp @@ -0,0 +1,51 @@ +# GYP file to build hello world example. +{ + 'targets': [ + { + 'target_name': 'HelloWorld', + 'type': 'executable', + 'mac_bundle' : 1, + 'include_dirs' : [ + '../include/gpu', + ], + 'sources': [ + '../example/HelloWorld.h', + '../example/HelloWorld.cpp', + ], + 'dependencies': [ + 'skia_lib.gyp:skia_lib', + 'views.gyp:views', + ], + 'conditions' : [ + [ 'skia_os == "win"', { + 'sources' : [ + '../src/views/win/SkOSWindow_Win.cpp', + '../src/views/win/skia_win.cpp', + ], + }], + [ 'skia_os == "mac"', { + 'sources': [ + '../example/mac/HelloWorldNSView.mm', + '../example/mac/HelloWorldDelegate.mm', + + '../src/views/mac/SkEventNotifier.mm', + '../src/views/mac/skia_mac.mm', + '../src/views/mac/SkNSView.mm', + '../src/views/mac/SkOptionsTableView.mm', + '../src/views/mac/SkOSWindow_Mac.mm', + '../src/views/mac/SkTextFieldCell.m', + ], + 'include_dirs' : [ + '../src/views/mac/' + ], + 'xcode_settings' : { + 'INFOPLIST_FILE' : '../example/mac/HelloWorld-Info.plist', + }, + 'mac_bundle_resources' : [ + '../example/mac/HelloWorld.xib' + ], + }], + ], + }, + ], +} diff --git a/gyp/most.gyp b/gyp/most.gyp index b94bda4..c547901 100644 --- a/gyp/most.gyp +++ b/gyp/most.gyp @@ -16,6 +16,7 @@ 'skia_lib.gyp:skia_lib', 'bench.gyp:*', + 'example.gyp:HelloWorld', 'SampleApp.gyp:SampleApp', 'tools.gyp:tools', 'pathops_unittest.gyp:*', @@ -24,11 +25,19 @@ 'dm.gyp:dm', ], 'conditions': [ + [ 'skia_gpu == 0 or skia_os == "android"', { + 'dependencies!': [ + 'example.gyp:HelloWorld', + ], + }], ['skia_os == "android"', { 'dependencies': [ 'android_system.gyp:SampleApp_APK' ], }], ['skia_os == "ios"', { - 'dependencies!': [ 'SampleApp.gyp:SampleApp' ], + 'dependencies!': [ + 'example.gyp:HelloWorld', + 'SampleApp.gyp:SampleApp', + ], 'dependencies': ['iOSShell.gyp:iOSShell' ], }], ['skia_os == "mac" or skia_os == "linux"', { @@ -37,6 +46,7 @@ [ 'skia_skip_gui', { 'dependencies!': [ + 'example.gyp:HelloWorld', 'SampleApp.gyp:SampleApp', ] } -- 2.7.4