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

Side by Side Diff: samplecode/SampleApp.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « samplecode/SampleApp.h ('k') | samplecode/SampleArc.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SampleApp.h" 8 #include "SampleApp.h"
9 9
10 #include "OverView.h" 10 #include "OverView.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 static void post_event_to_sink(SkEvent* evt, SkEventSink* sink) { 104 static void post_event_to_sink(SkEvent* evt, SkEventSink* sink) {
105 evt->setTargetID(sink->getSinkID())->post(); 105 evt->setTargetID(sink->getSinkID())->post();
106 } 106 }
107 107
108 static SkAnimTimer gAnimTimer; 108 static SkAnimTimer gAnimTimer;
109 109
110 /////////////////////////////////////////////////////////////////////////////// 110 ///////////////////////////////////////////////////////////////////////////////
111 111
112 static const char* skip_until(const char* str, const char* skip) { 112 static const char* skip_until(const char* str, const char* skip) {
113 if (!str) { 113 if (!str) {
114 return NULL; 114 return nullptr;
115 } 115 }
116 return strstr(str, skip); 116 return strstr(str, skip);
117 } 117 }
118 118
119 static const char* skip_past(const char* str, const char* skip) { 119 static const char* skip_past(const char* str, const char* skip) {
120 const char* found = skip_until(str, skip); 120 const char* found = skip_until(str, skip);
121 if (!found) { 121 if (!found) {
122 return NULL; 122 return nullptr;
123 } 123 }
124 return found + strlen(skip); 124 return found + strlen(skip);
125 } 125 }
126 126
127 static const char* gPrefFileName = "sampleapp_prefs.txt"; 127 static const char* gPrefFileName = "sampleapp_prefs.txt";
128 128
129 static bool readTitleFromPrefs(SkString* title) { 129 static bool readTitleFromPrefs(SkString* title) {
130 SkFILEStream stream(gPrefFileName); 130 SkFILEStream stream(gPrefFileName);
131 if (!stream.isValid()) { 131 if (!stream.isValid()) {
132 return false; 132 return false;
(...skipping 22 matching lines...) Expand all
155 stream.write(data.c_str(), data.size()); 155 stream.write(data.c_str(), data.size());
156 } 156 }
157 157
158 /////////////////////////////////////////////////////////////////////////////// 158 ///////////////////////////////////////////////////////////////////////////////
159 159
160 class SampleWindow::DefaultDeviceManager : public SampleWindow::DeviceManager { 160 class SampleWindow::DefaultDeviceManager : public SampleWindow::DeviceManager {
161 public: 161 public:
162 162
163 DefaultDeviceManager() { 163 DefaultDeviceManager() {
164 #if SK_SUPPORT_GPU 164 #if SK_SUPPORT_GPU
165 fCurContext = NULL; 165 fCurContext = nullptr;
166 fCurIntf = NULL; 166 fCurIntf = nullptr;
167 fCurRenderTarget = NULL; 167 fCurRenderTarget = nullptr;
168 fMSAASampleCount = 0; 168 fMSAASampleCount = 0;
169 #endif 169 #endif
170 fBackend = kNone_BackEndType; 170 fBackend = kNone_BackEndType;
171 } 171 }
172 172
173 virtual ~DefaultDeviceManager() { 173 virtual ~DefaultDeviceManager() {
174 #if SK_SUPPORT_GPU 174 #if SK_SUPPORT_GPU
175 SkSafeUnref(fCurContext); 175 SkSafeUnref(fCurContext);
176 SkSafeUnref(fCurIntf); 176 SkSafeUnref(fCurIntf);
177 SkSafeUnref(fCurRenderTarget); 177 SkSafeUnref(fCurRenderTarget);
(...skipping 24 matching lines...) Expand all
202 break; 202 break;
203 } 203 }
204 AttachmentInfo attachmentInfo; 204 AttachmentInfo attachmentInfo;
205 bool result = win->attach(fBackend, msaaSampleCount, &attachmentInfo); 205 bool result = win->attach(fBackend, msaaSampleCount, &attachmentInfo);
206 if (!result) { 206 if (!result) {
207 SkDebugf("Failed to initialize GL"); 207 SkDebugf("Failed to initialize GL");
208 return; 208 return;
209 } 209 }
210 fMSAASampleCount = msaaSampleCount; 210 fMSAASampleCount = msaaSampleCount;
211 211
212 SkASSERT(NULL == fCurIntf); 212 SkASSERT(nullptr == fCurIntf);
213 SkAutoTUnref<const GrGLInterface> glInterface; 213 SkAutoTUnref<const GrGLInterface> glInterface;
214 switch (win->getDeviceType()) { 214 switch (win->getDeviceType()) {
215 case kRaster_DeviceType: // fallthrough 215 case kRaster_DeviceType: // fallthrough
216 case kPicture_DeviceType: // fallthrough 216 case kPicture_DeviceType: // fallthrough
217 case kGPU_DeviceType: 217 case kGPU_DeviceType:
218 // all these guys use the native interface 218 // all these guys use the native interface
219 glInterface.reset(GrGLCreateNativeInterface()); 219 glInterface.reset(GrGLCreateNativeInterface());
220 break; 220 break;
221 #if SK_ANGLE 221 #if SK_ANGLE
222 case kANGLE_DeviceType: 222 case kANGLE_DeviceType:
223 glInterface.reset(GrGLCreateANGLEInterface()); 223 glInterface.reset(GrGLCreateANGLEInterface());
224 break; 224 break;
225 #endif // SK_ANGLE 225 #endif // SK_ANGLE
226 default: 226 default:
227 SkASSERT(false); 227 SkASSERT(false);
228 break; 228 break;
229 } 229 }
230 230
231 // Currently SampleApp does not use NVPR. TODO: Provide an NVPR device t ype that is skipped 231 // Currently SampleApp does not use NVPR. TODO: Provide an NVPR device t ype that is skipped
232 // when the driver doesn't support NVPR. 232 // when the driver doesn't support NVPR.
233 fCurIntf = GrGLInterfaceRemoveNVPR(glInterface.get()); 233 fCurIntf = GrGLInterfaceRemoveNVPR(glInterface.get());
234 234
235 SkASSERT(NULL == fCurContext); 235 SkASSERT(nullptr == fCurContext);
236 fCurContext = GrContext::Create(kOpenGL_GrBackend, (GrBackendContext) fC urIntf); 236 fCurContext = GrContext::Create(kOpenGL_GrBackend, (GrBackendContext) fC urIntf);
237 237
238 if (NULL == fCurContext || NULL == fCurIntf) { 238 if (nullptr == fCurContext || nullptr == fCurIntf) {
239 // We need some context and interface to see results 239 // We need some context and interface to see results
240 SkSafeUnref(fCurContext); 240 SkSafeUnref(fCurContext);
241 SkSafeUnref(fCurIntf); 241 SkSafeUnref(fCurIntf);
242 fCurContext = NULL; 242 fCurContext = nullptr;
243 fCurIntf = NULL; 243 fCurIntf = nullptr;
244 SkDebugf("Failed to setup 3D"); 244 SkDebugf("Failed to setup 3D");
245 245
246 win->detach(); 246 win->detach();
247 } 247 }
248 #endif // SK_SUPPORT_GPU 248 #endif // SK_SUPPORT_GPU
249 // call windowSizeChanged to create the render target 249 // call windowSizeChanged to create the render target
250 this->windowSizeChanged(win); 250 this->windowSizeChanged(win);
251 } 251 }
252 252
253 void tearDownBackend(SampleWindow *win) override { 253 void tearDownBackend(SampleWindow *win) override {
254 #if SK_SUPPORT_GPU 254 #if SK_SUPPORT_GPU
255 if (fCurContext) { 255 if (fCurContext) {
256 // in case we have outstanding refs to this guy (lua?) 256 // in case we have outstanding refs to this guy (lua?)
257 fCurContext->abandonContext(); 257 fCurContext->abandonContext();
258 fCurContext->unref(); 258 fCurContext->unref();
259 fCurContext = NULL; 259 fCurContext = nullptr;
260 } 260 }
261 261
262 SkSafeUnref(fCurIntf); 262 SkSafeUnref(fCurIntf);
263 fCurIntf = NULL; 263 fCurIntf = nullptr;
264 264
265 SkSafeUnref(fCurRenderTarget); 265 SkSafeUnref(fCurRenderTarget);
266 fCurRenderTarget = NULL; 266 fCurRenderTarget = nullptr;
267 #endif 267 #endif
268 win->detach(); 268 win->detach();
269 fBackend = kNone_BackEndType; 269 fBackend = kNone_BackEndType;
270 } 270 }
271 271
272 SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindow* win) override { 272 SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindow* win) override {
273 #if SK_SUPPORT_GPU 273 #if SK_SUPPORT_GPU
274 if (IsGpuDeviceType(dType) && fCurContext) { 274 if (IsGpuDeviceType(dType) && fCurContext) {
275 SkSurfaceProps props(win->getSurfaceProps()); 275 SkSurfaceProps props(win->getSurfaceProps());
276 return SkSurface::NewRenderTargetDirect(fCurRenderTarget, &props); 276 return SkSurface::NewRenderTargetDirect(fCurRenderTarget, &props);
277 } 277 }
278 #endif 278 #endif
279 return NULL; 279 return nullptr;
280 } 280 }
281 281
282 void publishCanvas(SampleWindow::DeviceType dType, 282 void publishCanvas(SampleWindow::DeviceType dType,
283 SkCanvas* canvas, SampleWindow* win) override { 283 SkCanvas* canvas, SampleWindow* win) override {
284 #if SK_SUPPORT_GPU 284 #if SK_SUPPORT_GPU
285 if (fCurContext) { 285 if (fCurContext) {
286 // in case we have queued drawing calls 286 // in case we have queued drawing calls
287 fCurContext->flush(); 287 fCurContext->flush();
288 288
289 if (!IsGpuDeviceType(dType)) { 289 if (!IsGpuDeviceType(dType)) {
(...skipping 21 matching lines...) Expand all
311 SkSafeUnref(fCurRenderTarget); 311 SkSafeUnref(fCurRenderTarget);
312 fCurRenderTarget = win->renderTarget(attachmentInfo, fCurIntf, fCurC ontext); 312 fCurRenderTarget = win->renderTarget(attachmentInfo, fCurIntf, fCurC ontext);
313 } 313 }
314 #endif 314 #endif
315 } 315 }
316 316
317 GrContext* getGrContext() override { 317 GrContext* getGrContext() override {
318 #if SK_SUPPORT_GPU 318 #if SK_SUPPORT_GPU
319 return fCurContext; 319 return fCurContext;
320 #else 320 #else
321 return NULL; 321 return nullptr;
322 #endif 322 #endif
323 } 323 }
324 324
325 GrRenderTarget* getGrRenderTarget() override { 325 GrRenderTarget* getGrRenderTarget() override {
326 #if SK_SUPPORT_GPU 326 #if SK_SUPPORT_GPU
327 return fCurRenderTarget; 327 return fCurRenderTarget;
328 #else 328 #else
329 return NULL; 329 return nullptr;
330 #endif 330 #endif
331 } 331 }
332 332
333 private: 333 private:
334 334
335 #if SK_SUPPORT_GPU 335 #if SK_SUPPORT_GPU
336 GrContext* fCurContext; 336 GrContext* fCurContext;
337 const GrGLInterface* fCurIntf; 337 const GrGLInterface* fCurIntf;
338 GrRenderTarget* fCurRenderTarget; 338 GrRenderTarget* fCurRenderTarget;
339 int fMSAASampleCount; 339 int fMSAASampleCount;
(...skipping 24 matching lines...) Expand all
364 return (*fCreateFunc)(); 364 return (*fCreateFunc)();
365 } 365 }
366 366
367 #include "GMSampleView.h" 367 #include "GMSampleView.h"
368 368
369 SkGMSampleViewFactory::SkGMSampleViewFactory(GMFactoryFunc func) 369 SkGMSampleViewFactory::SkGMSampleViewFactory(GMFactoryFunc func)
370 : fFunc(func) { 370 : fFunc(func) {
371 } 371 }
372 372
373 SkView* SkGMSampleViewFactory::operator() () const { 373 SkView* SkGMSampleViewFactory::operator() () const {
374 skiagm::GM* gm = fFunc(NULL); 374 skiagm::GM* gm = fFunc(nullptr);
375 gm->setMode(skiagm::GM::kSample_Mode); 375 gm->setMode(skiagm::GM::kSample_Mode);
376 return new GMSampleView(gm); 376 return new GMSampleView(gm);
377 } 377 }
378 378
379 SkViewRegister* SkViewRegister::gHead; 379 SkViewRegister* SkViewRegister::gHead;
380 SkViewRegister::SkViewRegister(SkViewFactory* fact) : fFact(fact) { 380 SkViewRegister::SkViewRegister(SkViewFactory* fact) : fFact(fact) {
381 fFact->ref(); 381 fFact->ref();
382 fChain = gHead; 382 fChain = gHead;
383 gHead = this; 383 gHead = this;
384 } 384 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 }; 435 };
436 436
437 #include "SkDrawFilter.h" 437 #include "SkDrawFilter.h"
438 438
439 struct HintingState { 439 struct HintingState {
440 SkPaint::Hinting hinting; 440 SkPaint::Hinting hinting;
441 const char* name; 441 const char* name;
442 const char* label; 442 const char* label;
443 }; 443 };
444 static HintingState gHintingStates[] = { 444 static HintingState gHintingStates[] = {
445 {SkPaint::kNo_Hinting, "Mixed", NULL }, 445 {SkPaint::kNo_Hinting, "Mixed", nullptr },
446 {SkPaint::kNo_Hinting, "None", "H0 " }, 446 {SkPaint::kNo_Hinting, "None", "H0 " },
447 {SkPaint::kSlight_Hinting, "Slight", "Hs " }, 447 {SkPaint::kSlight_Hinting, "Slight", "Hs " },
448 {SkPaint::kNormal_Hinting, "Normal", "Hn " }, 448 {SkPaint::kNormal_Hinting, "Normal", "Hn " },
449 {SkPaint::kFull_Hinting, "Full", "Hf " }, 449 {SkPaint::kFull_Hinting, "Full", "Hf " },
450 }; 450 };
451 451
452 struct FilterQualityState { 452 struct FilterQualityState {
453 SkFilterQuality fQuality; 453 SkFilterQuality fQuality;
454 const char* fName; 454 const char* fName;
455 const char* fLabel; 455 const char* fLabel;
456 }; 456 };
457 static FilterQualityState gFilterQualityStates[] = { 457 static FilterQualityState gFilterQualityStates[] = {
458 { kNone_SkFilterQuality, "Mixed", NULL }, 458 { kNone_SkFilterQuality, "Mixed", nullptr },
459 { kNone_SkFilterQuality, "None", "F0 " }, 459 { kNone_SkFilterQuality, "None", "F0 " },
460 { kLow_SkFilterQuality, "Low", "F1 " }, 460 { kLow_SkFilterQuality, "Low", "F1 " },
461 { kMedium_SkFilterQuality, "Medium", "F2 " }, 461 { kMedium_SkFilterQuality, "Medium", "F2 " },
462 { kHigh_SkFilterQuality, "High", "F3 " }, 462 { kHigh_SkFilterQuality, "High", "F3 " },
463 }; 463 };
464 464
465 class FlagsFilterCanvas : public SkPaintFilterCanvas { 465 class FlagsFilterCanvas : public SkPaintFilterCanvas {
466 public: 466 public:
467 FlagsFilterCanvas(SkCanvas* canvas, SkOSMenu::TriState lcd, SkOSMenu::TriSta te aa, 467 FlagsFilterCanvas(SkCanvas* canvas, SkOSMenu::TriState lcd, SkOSMenu::TriSta te aa,
468 SkOSMenu::TriState subpixel, int hinting, int filterQualit y) 468 SkOSMenu::TriState subpixel, int hinting, int filterQualit y)
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 636
637 void SampleWindow::setZoomCenter(float x, float y) { 637 void SampleWindow::setZoomCenter(float x, float y) {
638 fZoomCenterX = x; 638 fZoomCenterX = x;
639 fZoomCenterY = y; 639 fZoomCenterY = y;
640 } 640 }
641 641
642 bool SampleWindow::zoomIn() { 642 bool SampleWindow::zoomIn() {
643 // Arbitrarily decided 643 // Arbitrarily decided
644 if (fFatBitsScale == kMaxFatBitsScale) return false; 644 if (fFatBitsScale == kMaxFatBitsScale) return false;
645 fFatBitsScale++; 645 fFatBitsScale++;
646 this->inval(NULL); 646 this->inval(nullptr);
647 return true; 647 return true;
648 } 648 }
649 649
650 bool SampleWindow::zoomOut() { 650 bool SampleWindow::zoomOut() {
651 if (fFatBitsScale == 1) return false; 651 if (fFatBitsScale == 1) return false;
652 fFatBitsScale--; 652 fFatBitsScale--;
653 this->inval(NULL); 653 this->inval(nullptr);
654 return true; 654 return true;
655 } 655 }
656 656
657 void SampleWindow::updatePointer(int x, int y) { 657 void SampleWindow::updatePointer(int x, int y) {
658 fMouseX = x; 658 fMouseX = x;
659 fMouseY = y; 659 fMouseY = y;
660 if (fShowZoomer) { 660 if (fShowZoomer) {
661 this->inval(NULL); 661 this->inval(nullptr);
662 } 662 }
663 } 663 }
664 664
665 static inline SampleWindow::DeviceType cycle_devicetype(SampleWindow::DeviceType ct) { 665 static inline SampleWindow::DeviceType cycle_devicetype(SampleWindow::DeviceType ct) {
666 static const SampleWindow::DeviceType gCT[] = { 666 static const SampleWindow::DeviceType gCT[] = {
667 SampleWindow::kPicture_DeviceType, 667 SampleWindow::kPicture_DeviceType,
668 #if SK_SUPPORT_GPU 668 #if SK_SUPPORT_GPU
669 SampleWindow::kGPU_DeviceType, 669 SampleWindow::kGPU_DeviceType,
670 #if SK_ANGLE 670 #if SK_ANGLE
671 SampleWindow::kANGLE_DeviceType, 671 SampleWindow::kANGLE_DeviceType,
(...skipping 25 matching lines...) Expand all
697 DEFINE_bool(list, false, "List samples?"); 697 DEFINE_bool(list, false, "List samples?");
698 DEFINE_string(key, "", ""); // dummy to enable gm tests that have platform-spec ific names 698 DEFINE_string(key, "", ""); // dummy to enable gm tests that have platform-spec ific names
699 #ifdef SAMPLE_PDF_FILE_VIEWER 699 #ifdef SAMPLE_PDF_FILE_VIEWER
700 DEFINE_string(pdfPath, "", "Path to direcotry of pdf files."); 700 DEFINE_string(pdfPath, "", "Path to direcotry of pdf files.");
701 #endif 701 #endif
702 702
703 #include "SkTaskGroup.h" 703 #include "SkTaskGroup.h"
704 704
705 SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev Manager) 705 SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev Manager)
706 : INHERITED(hwnd) 706 : INHERITED(hwnd)
707 , fDevManager(NULL) { 707 , fDevManager(nullptr) {
708 708
709 SkCommandLineFlags::Parse(argc, argv); 709 SkCommandLineFlags::Parse(argc, argv);
710 710
711 fCurrIndex = -1; 711 fCurrIndex = -1;
712 712
713 if (!FLAGS_pictureDir.isEmpty()) { 713 if (!FLAGS_pictureDir.isEmpty()) {
714 SkOSFile::Iter iter(FLAGS_pictureDir[0], "skp"); 714 SkOSFile::Iter iter(FLAGS_pictureDir[0], "skp");
715 SkString filename; 715 SkString filename;
716 while (iter.next(&filename)) { 716 while (iter.next(&filename)) {
717 *fSamples.append() = new PictFileFactory( 717 *fSamples.append() = new PictFileFactory(
(...skipping 20 matching lines...) Expand all
738 const SkViewRegister* reg = SkViewRegister::Head(); 738 const SkViewRegister* reg = SkViewRegister::Head();
739 while (reg) { 739 while (reg) {
740 *fSamples.append() = reg->factory(); 740 *fSamples.append() = reg->factory();
741 reg = reg->next(); 741 reg = reg->next();
742 } 742 }
743 } 743 }
744 744
745 if (FLAGS_sort) { 745 if (FLAGS_sort) {
746 // Sort samples, so foo.skp and foo.pdf are consecutive and we can quick ly spot where 746 // Sort samples, so foo.skp and foo.pdf are consecutive and we can quick ly spot where
747 // skp -> pdf -> png fails. 747 // skp -> pdf -> png fails.
748 SkTQSort(fSamples.begin(), fSamples.end() ? fSamples.end() - 1 : NULL, c ompareSampleTitle); 748 SkTQSort(fSamples.begin(), fSamples.end() ? fSamples.end() - 1 : nullptr , compareSampleTitle);
749 } 749 }
750 750
751 if (!FLAGS_slide.isEmpty()) { 751 if (!FLAGS_slide.isEmpty()) {
752 fCurrIndex = findByTitle(FLAGS_slide[0]); 752 fCurrIndex = findByTitle(FLAGS_slide[0]);
753 if (fCurrIndex < 0) { 753 if (fCurrIndex < 0) {
754 fprintf(stderr, "Unknown sample \"%s\"\n", FLAGS_slide[0]); 754 fprintf(stderr, "Unknown sample \"%s\"\n", FLAGS_slide[0]);
755 listTitles(); 755 listTitles();
756 } 756 }
757 } 757 }
758 758
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 fLCDState = SkOSMenu::kMixedState; 802 fLCDState = SkOSMenu::kMixedState;
803 fAAState = SkOSMenu::kMixedState; 803 fAAState = SkOSMenu::kMixedState;
804 fSubpixelState = SkOSMenu::kMixedState; 804 fSubpixelState = SkOSMenu::kMixedState;
805 fHintingState = 0; 805 fHintingState = 0;
806 fFilterQualityIndex = 0; 806 fFilterQualityIndex = 0;
807 fFlipAxis = 0; 807 fFlipAxis = 0;
808 fScrollTestX = fScrollTestY = 0; 808 fScrollTestX = fScrollTestY = 0;
809 809
810 fMouseX = fMouseY = 0; 810 fMouseX = fMouseY = 0;
811 fFatBitsScale = 8; 811 fFatBitsScale = 8;
812 fTypeface = SkTypeface::CreateFromTypeface(NULL, SkTypeface::kBold); 812 fTypeface = SkTypeface::CreateFromTypeface(nullptr, SkTypeface::kBold);
813 fShowZoomer = false; 813 fShowZoomer = false;
814 814
815 fZoomLevel = 0; 815 fZoomLevel = 0;
816 fZoomScale = SK_Scalar1; 816 fZoomScale = SK_Scalar1;
817 817
818 fMagnify = false; 818 fMagnify = false;
819 819
820 fSaveToPdf = false; 820 fSaveToPdf = false;
821 fSaveToSKP = false; 821 fSaveToSKP = false;
822 822
823 int sinkID = this->getSinkID(); 823 int sinkID = this->getSinkID();
824 fAppMenu = new SkOSMenu; 824 fAppMenu = new SkOSMenu;
825 fAppMenu->setTitle("Global Settings"); 825 fAppMenu->setTitle("Global Settings");
826 int itemID; 826 int itemID;
827 827
828 itemID =fAppMenu->appendList("Device Type", "Device Type", sinkID, 0, 828 itemID =fAppMenu->appendList("Device Type", "Device Type", sinkID, 0,
829 "Raster", "Picture", "OpenGL", 829 "Raster", "Picture", "OpenGL",
830 #if SK_ANGLE 830 #if SK_ANGLE
831 "ANGLE", 831 "ANGLE",
832 #endif 832 #endif
833 NULL); 833 nullptr);
834 fAppMenu->assignKeyEquivalentToItem(itemID, 'd'); 834 fAppMenu->assignKeyEquivalentToItem(itemID, 'd');
835 itemID = fAppMenu->appendTriState("AA", "AA", sinkID, fAAState); 835 itemID = fAppMenu->appendTriState("AA", "AA", sinkID, fAAState);
836 fAppMenu->assignKeyEquivalentToItem(itemID, 'b'); 836 fAppMenu->assignKeyEquivalentToItem(itemID, 'b');
837 itemID = fAppMenu->appendTriState("LCD", "LCD", sinkID, fLCDState); 837 itemID = fAppMenu->appendTriState("LCD", "LCD", sinkID, fLCDState);
838 fAppMenu->assignKeyEquivalentToItem(itemID, 'l'); 838 fAppMenu->assignKeyEquivalentToItem(itemID, 'l');
839 itemID = fAppMenu->appendList("FilterQuality", "FilterQuality", sinkID, fFil terQualityIndex, 839 itemID = fAppMenu->appendList("FilterQuality", "FilterQuality", sinkID, fFil terQualityIndex,
840 gFilterQualityStates[0].fName, 840 gFilterQualityStates[0].fName,
841 gFilterQualityStates[1].fName, 841 gFilterQualityStates[1].fName,
842 gFilterQualityStates[2].fName, 842 gFilterQualityStates[2].fName,
843 gFilterQualityStates[3].fName, 843 gFilterQualityStates[3].fName,
844 gFilterQualityStates[4].fName, 844 gFilterQualityStates[4].fName,
845 NULL); 845 nullptr);
846 fAppMenu->assignKeyEquivalentToItem(itemID, 'n'); 846 fAppMenu->assignKeyEquivalentToItem(itemID, 'n');
847 itemID = fAppMenu->appendTriState("Subpixel", "Subpixel", sinkID, fSubpixelS tate); 847 itemID = fAppMenu->appendTriState("Subpixel", "Subpixel", sinkID, fSubpixelS tate);
848 fAppMenu->assignKeyEquivalentToItem(itemID, 's'); 848 fAppMenu->assignKeyEquivalentToItem(itemID, 's');
849 itemID = fAppMenu->appendList("Hinting", "Hinting", sinkID, fHintingState, 849 itemID = fAppMenu->appendList("Hinting", "Hinting", sinkID, fHintingState,
850 gHintingStates[0].name, 850 gHintingStates[0].name,
851 gHintingStates[1].name, 851 gHintingStates[1].name,
852 gHintingStates[2].name, 852 gHintingStates[2].name,
853 gHintingStates[3].name, 853 gHintingStates[3].name,
854 gHintingStates[4].name, 854 gHintingStates[4].name,
855 NULL); 855 nullptr);
856 fAppMenu->assignKeyEquivalentToItem(itemID, 'h'); 856 fAppMenu->assignKeyEquivalentToItem(itemID, 'h');
857 857
858 fUsePipeMenuItemID = fAppMenu->appendTriState("Pipe", "Pipe" , sinkID, 858 fUsePipeMenuItemID = fAppMenu->appendTriState("Pipe", "Pipe" , sinkID,
859 fPipeState); 859 fPipeState);
860 fAppMenu->assignKeyEquivalentToItem(fUsePipeMenuItemID, 'P'); 860 fAppMenu->assignKeyEquivalentToItem(fUsePipeMenuItemID, 'P');
861 861
862 itemID =fAppMenu->appendList("Tiling", "Tiling", sinkID, fTilingMode, 862 itemID =fAppMenu->appendList("Tiling", "Tiling", sinkID, fTilingMode,
863 gTilingInfo[kNo_Tiling].label, 863 gTilingInfo[kNo_Tiling].label,
864 gTilingInfo[kAbs_128x128_Tiling].label, 864 gTilingInfo[kAbs_128x128_Tiling].label,
865 gTilingInfo[kAbs_256x256_Tiling].label, 865 gTilingInfo[kAbs_256x256_Tiling].label,
866 gTilingInfo[kRel_4x4_Tiling].label, 866 gTilingInfo[kRel_4x4_Tiling].label,
867 gTilingInfo[kRel_1x16_Tiling].label, 867 gTilingInfo[kRel_1x16_Tiling].label,
868 gTilingInfo[kRel_16x1_Tiling].label, 868 gTilingInfo[kRel_16x1_Tiling].label,
869 NULL); 869 nullptr);
870 fAppMenu->assignKeyEquivalentToItem(itemID, 't'); 870 fAppMenu->assignKeyEquivalentToItem(itemID, 't');
871 871
872 itemID = fAppMenu->appendSwitch("Slide Show", "Slide Show" , sinkID, false); 872 itemID = fAppMenu->appendSwitch("Slide Show", "Slide Show" , sinkID, false);
873 fAppMenu->assignKeyEquivalentToItem(itemID, 'a'); 873 fAppMenu->assignKeyEquivalentToItem(itemID, 'a');
874 itemID = fAppMenu->appendSwitch("Clip", "Clip" , sinkID, fUseClip); 874 itemID = fAppMenu->appendSwitch("Clip", "Clip" , sinkID, fUseClip);
875 fAppMenu->assignKeyEquivalentToItem(itemID, 'c'); 875 fAppMenu->assignKeyEquivalentToItem(itemID, 'c');
876 itemID = fAppMenu->appendSwitch("Flip X", "Flip X" , sinkID, false); 876 itemID = fAppMenu->appendSwitch("Flip X", "Flip X" , sinkID, false);
877 fAppMenu->assignKeyEquivalentToItem(itemID, 'x'); 877 fAppMenu->assignKeyEquivalentToItem(itemID, 'x');
878 itemID = fAppMenu->appendSwitch("Flip Y", "Flip Y" , sinkID, false); 878 itemID = fAppMenu->appendSwitch("Flip Y", "Flip Y" , sinkID, false);
879 fAppMenu->assignKeyEquivalentToItem(itemID, 'y'); 879 fAppMenu->assignKeyEquivalentToItem(itemID, 'y');
880 itemID = fAppMenu->appendSwitch("Zoomer", "Zoomer" , sinkID, fShowZoomer); 880 itemID = fAppMenu->appendSwitch("Zoomer", "Zoomer" , sinkID, fShowZoomer);
881 fAppMenu->assignKeyEquivalentToItem(itemID, 'z'); 881 fAppMenu->assignKeyEquivalentToItem(itemID, 'z');
882 itemID = fAppMenu->appendSwitch("Magnify", "Magnify" , sinkID, fMagnify); 882 itemID = fAppMenu->appendSwitch("Magnify", "Magnify" , sinkID, fMagnify);
883 fAppMenu->assignKeyEquivalentToItem(itemID, 'm'); 883 fAppMenu->assignKeyEquivalentToItem(itemID, 'm');
884 884
885 itemID = fAppMenu->appendAction("Save to PDF", sinkID); 885 itemID = fAppMenu->appendAction("Save to PDF", sinkID);
886 fAppMenu->assignKeyEquivalentToItem(itemID, 'e'); 886 fAppMenu->assignKeyEquivalentToItem(itemID, 'e');
887 887
888 this->addMenu(fAppMenu); 888 this->addMenu(fAppMenu);
889 fSlideMenu = new SkOSMenu; 889 fSlideMenu = new SkOSMenu;
890 this->addMenu(fSlideMenu); 890 this->addMenu(fSlideMenu);
891 891
892 this->setVisibleP(true); 892 this->setVisibleP(true);
893 this->setClipToBounds(false); 893 this->setClipToBounds(false);
894 894
895 this->loadView((*fSamples[fCurrIndex])()); 895 this->loadView((*fSamples[fCurrIndex])());
896 896
897 if (NULL == devManager) { 897 if (nullptr == devManager) {
898 fDevManager = new DefaultDeviceManager(); 898 fDevManager = new DefaultDeviceManager();
899 } else { 899 } else {
900 devManager->ref(); 900 devManager->ref();
901 fDevManager = devManager; 901 fDevManager = devManager;
902 } 902 }
903 fDevManager->setUpBackend(this, fMSAASampleCount); 903 fDevManager->setUpBackend(this, fMSAASampleCount);
904 904
905 // If another constructor set our dimensions, ensure that our 905 // If another constructor set our dimensions, ensure that our
906 // onSizeChange gets called. 906 // onSizeChange gets called.
907 if (this->height() && this->width()) { 907 if (this->height() && this->width()) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 SkImageInfo info = SkImageInfo::MakeN32Premul(w, h); 992 SkImageInfo info = SkImageInfo::MakeN32Premul(w, h);
993 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info)); 993 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
994 SkCanvas* tileCanvas = surface->getCanvas(); 994 SkCanvas* tileCanvas = surface->getCanvas();
995 995
996 for (SkScalar y = 0; y < height(); y += tile.height()) { 996 for (SkScalar y = 0; y < height(); y += tile.height()) {
997 for (SkScalar x = 0; x < width(); x += tile.width()) { 997 for (SkScalar x = 0; x < width(); x += tile.width()) {
998 SkAutoCanvasRestore acr(tileCanvas, true); 998 SkAutoCanvasRestore acr(tileCanvas, true);
999 tileCanvas->translate(-x, -y); 999 tileCanvas->translate(-x, -y);
1000 tileCanvas->clear(0); 1000 tileCanvas->clear(0);
1001 this->INHERITED::draw(tileCanvas); 1001 this->INHERITED::draw(tileCanvas);
1002 surface->draw(canvas, x, y, NULL); 1002 surface->draw(canvas, x, y, nullptr);
1003 } 1003 }
1004 } 1004 }
1005 1005
1006 // for drawing the borders between tiles 1006 // for drawing the borders between tiles
1007 SkPaint paint; 1007 SkPaint paint;
1008 paint.setColor(0x60FF00FF); 1008 paint.setColor(0x60FF00FF);
1009 paint.setStyle(SkPaint::kStroke_Style); 1009 paint.setStyle(SkPaint::kStroke_Style);
1010 1010
1011 for (SkScalar y = 0; y < height(); y += tile.height()) { 1011 for (SkScalar y = 0; y < height(); y += tile.height()) {
1012 for (SkScalar x = 0; x < width(); x += tile.width()) { 1012 for (SkScalar x = 0; x < width(); x += tile.width()) {
1013 canvas->drawRect(SkRect::MakeXYWH(x, y, tile.width(), tile.heigh t()), paint); 1013 canvas->drawRect(SkRect::MakeXYWH(x, y, tile.width(), tile.heigh t()), paint);
1014 } 1014 }
1015 } 1015 }
1016 } 1016 }
1017 1017
1018 if (fShowZoomer && !fSaveToPdf) { 1018 if (fShowZoomer && !fSaveToPdf) {
1019 showZoomer(canvas); 1019 showZoomer(canvas);
1020 } 1020 }
1021 if (fMagnify && !fSaveToPdf) { 1021 if (fMagnify && !fSaveToPdf) {
1022 magnify(canvas); 1022 magnify(canvas);
1023 } 1023 }
1024 1024
1025 if (fMeasureFPS && fMeasureFPS_Time) { 1025 if (fMeasureFPS && fMeasureFPS_Time) {
1026 this->updateTitle(); 1026 this->updateTitle();
1027 this->postInvalDelay(); 1027 this->postInvalDelay();
1028 } 1028 }
1029 1029
1030 if (this->sendAnimatePulse()) { 1030 if (this->sendAnimatePulse()) {
1031 this->inval(NULL); 1031 this->inval(nullptr);
1032 } 1032 }
1033 1033
1034 // do this last 1034 // do this last
1035 fDevManager->publishCanvas(fDeviceType, canvas, this); 1035 fDevManager->publishCanvas(fDeviceType, canvas, this);
1036 } 1036 }
1037 1037
1038 static float clipW = 200; 1038 static float clipW = 200;
1039 static float clipH = 200; 1039 static float clipH = 200;
1040 void SampleWindow::magnify(SkCanvas* canvas) { 1040 void SampleWindow::magnify(SkCanvas* canvas) {
1041 SkRect r; 1041 SkRect r;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 paint.setColor(SK_ColorWHITE); 1165 paint.setColor(SK_ColorWHITE);
1166 canvas->drawRect(dest, paint); 1166 canvas->drawRect(dest, paint);
1167 switch (fFatBitsScale) { 1167 switch (fFatBitsScale) {
1168 case kMaxFatBitsScale: 1168 case kMaxFatBitsScale:
1169 show_lcd_grid(canvas, bitmap, src, dest, show_lcd_box); 1169 show_lcd_grid(canvas, bitmap, src, dest, show_lcd_box);
1170 break; 1170 break;
1171 case kMaxFatBitsScale - 1: 1171 case kMaxFatBitsScale - 1:
1172 show_lcd_grid(canvas, bitmap, src, dest, show_lcd_circle); 1172 show_lcd_grid(canvas, bitmap, src, dest, show_lcd_circle);
1173 break; 1173 break;
1174 default: 1174 default:
1175 canvas->drawBitmapRect(bitmap, src, dest, NULL); 1175 canvas->drawBitmapRect(bitmap, src, dest, nullptr);
1176 break; 1176 break;
1177 } 1177 }
1178 1178
1179 paint.setColor(SK_ColorBLACK); 1179 paint.setColor(SK_ColorBLACK);
1180 paint.setStyle(SkPaint::kStroke_Style); 1180 paint.setStyle(SkPaint::kStroke_Style);
1181 // Draw a border around the pixel in the middle 1181 // Draw a border around the pixel in the middle
1182 SkRect originalPixel; 1182 SkRect originalPixel;
1183 originalPixel.set(SkIntToScalar(fMouseX), SkIntToScalar(fMouseY), SkIntToSca lar(fMouseX + 1), SkIntToScalar(fMouseY + 1)); 1183 originalPixel.set(SkIntToScalar(fMouseX), SkIntToScalar(fMouseY), SkIntToSca lar(fMouseX + 1), SkIntToScalar(fMouseY + 1));
1184 SkMatrix matrix; 1184 SkMatrix matrix;
1185 SkRect scalarSrc; 1185 SkRect scalarSrc;
1186 scalarSrc.set(src); 1186 scalarSrc.set(src);
1187 SkColor color = bitmap.getColor(fMouseX, fMouseY); 1187 SkColor color = bitmap.getColor(fMouseX, fMouseY);
1188 if (matrix.setRectToRect(scalarSrc, dest, SkMatrix::kFill_ScaleToFit)) { 1188 if (matrix.setRectToRect(scalarSrc, dest, SkMatrix::kFill_ScaleToFit)) {
1189 SkRect pixel; 1189 SkRect pixel;
1190 matrix.mapRect(&pixel, originalPixel); 1190 matrix.mapRect(&pixel, originalPixel);
1191 // TODO Perhaps measure the values and make the outline white if it's "d ark" 1191 // TODO Perhaps measure the values and make the outline white if it's "d ark"
1192 if (color == SK_ColorBLACK) { 1192 if (color == SK_ColorBLACK) {
1193 paint.setColor(SK_ColorWHITE); 1193 paint.setColor(SK_ColorWHITE);
1194 } 1194 }
1195 canvas->drawRect(pixel, paint); 1195 canvas->drawRect(pixel, paint);
1196 } 1196 }
1197 paint.setColor(SK_ColorBLACK); 1197 paint.setColor(SK_ColorBLACK);
1198 // Draw a border around the destination rectangle 1198 // Draw a border around the destination rectangle
1199 canvas->drawRect(dest, paint); 1199 canvas->drawRect(dest, paint);
1200 paint.setStyle(SkPaint::kStrokeAndFill_Style); 1200 paint.setStyle(SkPaint::kStrokeAndFill_Style);
1201 // Identify the pixel and its color on screen 1201 // Identify the pixel and its color on screen
1202 paint.setTypeface(fTypeface); 1202 paint.setTypeface(fTypeface);
1203 paint.setAntiAlias(true); 1203 paint.setAntiAlias(true);
1204 SkScalar lineHeight = paint.getFontMetrics(NULL); 1204 SkScalar lineHeight = paint.getFontMetrics(nullptr);
1205 SkString string; 1205 SkString string;
1206 string.appendf("(%i, %i)", fMouseX, fMouseY); 1206 string.appendf("(%i, %i)", fMouseX, fMouseY);
1207 SkScalar left = dest.fLeft + SkIntToScalar(3); 1207 SkScalar left = dest.fLeft + SkIntToScalar(3);
1208 SkScalar i = SK_Scalar1; 1208 SkScalar i = SK_Scalar1;
1209 drawText(canvas, string, left, SkScalarMulAdd(lineHeight, i, dest.fTop), pai nt); 1209 drawText(canvas, string, left, SkScalarMulAdd(lineHeight, i, dest.fTop), pai nt);
1210 // Alpha 1210 // Alpha
1211 i += SK_Scalar1; 1211 i += SK_Scalar1;
1212 string.reset(); 1212 string.reset();
1213 string.appendf("A: %X", SkColorGetA(color)); 1213 string.appendf("A: %X", SkColorGetA(color));
1214 drawText(canvas, string, left, SkScalarMulAdd(lineHeight, i, dest.fTop), pai nt); 1214 drawText(canvas, string, left, SkScalarMulAdd(lineHeight, i, dest.fTop), pai nt);
(...skipping 20 matching lines...) Expand all
1235 1235
1236 void SampleWindow::onDraw(SkCanvas* canvas) { 1236 void SampleWindow::onDraw(SkCanvas* canvas) {
1237 } 1237 }
1238 1238
1239 #include "SkColorPriv.h" 1239 #include "SkColorPriv.h"
1240 1240
1241 void SampleWindow::saveToPdf() 1241 void SampleWindow::saveToPdf()
1242 { 1242 {
1243 #if SK_SUPPORT_PDF 1243 #if SK_SUPPORT_PDF
1244 fSaveToPdf = true; 1244 fSaveToPdf = true;
1245 this->inval(NULL); 1245 this->inval(nullptr);
1246 #endif // SK_SUPPORT_PDF 1246 #endif // SK_SUPPORT_PDF
1247 } 1247 }
1248 1248
1249 SkCanvas* SampleWindow::beforeChildren(SkCanvas* canvas) { 1249 SkCanvas* SampleWindow::beforeChildren(SkCanvas* canvas) {
1250 if (fSaveToPdf) { 1250 if (fSaveToPdf) {
1251 SkString name; 1251 SkString name;
1252 if (!this->getRawTitle(&name)) { 1252 if (!this->getRawTitle(&name)) {
1253 name.set("unknown_sample"); 1253 name.set("unknown_sample");
1254 } 1254 }
1255 name.append(".pdf"); 1255 name.append(".pdf");
1256 #ifdef SK_BUILD_FOR_ANDROID 1256 #ifdef SK_BUILD_FOR_ANDROID
1257 name.prepend("/sdcard/"); 1257 name.prepend("/sdcard/");
1258 #endif 1258 #endif
1259 fPDFDocument.reset(SkDocument::CreatePDF(name.c_str())); 1259 fPDFDocument.reset(SkDocument::CreatePDF(name.c_str()));
1260 canvas = fPDFDocument->beginPage(this->width(), this->height()); 1260 canvas = fPDFDocument->beginPage(this->width(), this->height());
1261 } else if (kPicture_DeviceType == fDeviceType) { 1261 } else if (kPicture_DeviceType == fDeviceType) {
1262 canvas = fRecorder.beginRecording(9999, 9999, NULL, 0); 1262 canvas = fRecorder.beginRecording(9999, 9999, nullptr, 0);
1263 } else { 1263 } else {
1264 canvas = this->INHERITED::beforeChildren(canvas); 1264 canvas = this->INHERITED::beforeChildren(canvas);
1265 } 1265 }
1266 1266
1267 if (fUseClip) { 1267 if (fUseClip) {
1268 canvas->drawColor(0xFFFF88FF); 1268 canvas->drawColor(0xFFFF88FF);
1269 canvas->clipPath(fClipPath, SkRegion::kIntersect_Op, true); 1269 canvas->clipPath(fClipPath, SkRegion::kIntersect_Op, true);
1270 } 1270 }
1271 1271
1272 // Install a flags filter proxy canvas if needed 1272 // Install a flags filter proxy canvas if needed
1273 if (fLCDState != SkOSMenu::kMixedState || 1273 if (fLCDState != SkOSMenu::kMixedState ||
1274 fAAState != SkOSMenu::kMixedState || 1274 fAAState != SkOSMenu::kMixedState ||
1275 fSubpixelState != SkOSMenu::kMixedState || 1275 fSubpixelState != SkOSMenu::kMixedState ||
1276 fHintingState > 0 || 1276 fHintingState > 0 ||
1277 fFilterQualityIndex > 0) { 1277 fFilterQualityIndex > 0) {
1278 canvas = new FlagsFilterCanvas(canvas, fLCDState, fAAState, fSubpixelSta te, fHintingState, 1278 canvas = new FlagsFilterCanvas(canvas, fLCDState, fAAState, fSubpixelSta te, fHintingState,
1279 fFilterQualityIndex); 1279 fFilterQualityIndex);
1280 fFlagsFilterCanvas.reset(canvas); 1280 fFlagsFilterCanvas.reset(canvas);
1281 } 1281 }
1282 1282
1283 return canvas; 1283 return canvas;
1284 } 1284 }
1285 #include "SkMultiPictureDraw.h" 1285 #include "SkMultiPictureDraw.h"
1286 void SampleWindow::afterChildren(SkCanvas* orig) { 1286 void SampleWindow::afterChildren(SkCanvas* orig) {
1287 fFlagsFilterCanvas.reset(NULL); 1287 fFlagsFilterCanvas.reset(nullptr);
1288 1288
1289 if (fSaveToPdf) { 1289 if (fSaveToPdf) {
1290 fSaveToPdf = false; 1290 fSaveToPdf = false;
1291 fPDFDocument->endPage(); 1291 fPDFDocument->endPage();
1292 fPDFDocument.reset(NULL); 1292 fPDFDocument.reset(nullptr);
1293 // We took over the draw calls in order to create the PDF, so we need 1293 // We took over the draw calls in order to create the PDF, so we need
1294 // to redraw. 1294 // to redraw.
1295 this->inval(NULL); 1295 this->inval(nullptr);
1296 return; 1296 return;
1297 } 1297 }
1298 1298
1299 if (fRequestGrabImage) { 1299 if (fRequestGrabImage) {
1300 fRequestGrabImage = false; 1300 fRequestGrabImage = false;
1301 1301
1302 SkBitmap bmp = capture_bitmap(orig); 1302 SkBitmap bmp = capture_bitmap(orig);
1303 if (!bmp.isNull()) { 1303 if (!bmp.isNull()) {
1304 static int gSampleGrabCounter; 1304 static int gSampleGrabCounter;
1305 SkString name; 1305 SkString name;
(...skipping 27 matching lines...) Expand all
1333 for (int y = 0; y < 2; ++y) { 1333 for (int y = 0; y < 2; ++y) {
1334 for (int x = 0; x < 2; ++x) { 1334 for (int x = 0; x < 2; ++x) {
1335 char* p = (char*)addr; 1335 char* p = (char*)addr;
1336 p += y * n.height() * rowBytes; 1336 p += y * n.height() * rowBytes;
1337 p += x * n.width() * sizeof(SkPMColor); 1337 p += x * n.width() * sizeof(SkPMColor);
1338 surfs[index] = SkSurface::NewRasterDirect(n, p, rowB ytes); 1338 surfs[index] = SkSurface::NewRasterDirect(n, p, rowB ytes);
1339 SkCanvas* c = surfs[index]->getCanvas(); 1339 SkCanvas* c = surfs[index]->getCanvas();
1340 c->translate(SkIntToScalar(-x * n.width()), 1340 c->translate(SkIntToScalar(-x * n.width()),
1341 SkIntToScalar(-y * n.height())); 1341 SkIntToScalar(-y * n.height()));
1342 c->concat(orig->getTotalMatrix()); 1342 c->concat(orig->getTotalMatrix());
1343 md.add(c, picture, NULL, NULL); 1343 md.add(c, picture, nullptr, nullptr);
1344 index++; 1344 index++;
1345 } 1345 }
1346 } 1346 }
1347 md.draw(); 1347 md.draw();
1348 for (int i = 0; i < 4; ++i) { 1348 for (int i = 0; i < 4; ++i) {
1349 surfs[i]->unref(); 1349 surfs[i]->unref();
1350 } 1350 }
1351 } 1351 }
1352 } else { 1352 } else {
1353 orig->drawPicture(picture); 1353 orig->drawPicture(picture);
1354 } 1354 }
1355 } else if (true) { 1355 } else if (true) {
1356 SkDynamicMemoryWStream ostream; 1356 SkDynamicMemoryWStream ostream;
1357 picture->serialize(&ostream); 1357 picture->serialize(&ostream);
1358 1358
1359 SkAutoDataUnref data(ostream.copyToData()); 1359 SkAutoDataUnref data(ostream.copyToData());
1360 SkMemoryStream istream(data->data(), data->size()); 1360 SkMemoryStream istream(data->data(), data->size());
1361 SkAutoTUnref<SkPicture> pict(SkPicture::CreateFromStream(&istream)); 1361 SkAutoTUnref<SkPicture> pict(SkPicture::CreateFromStream(&istream));
1362 if (pict.get() != NULL) { 1362 if (pict.get() != nullptr) {
1363 orig->drawPicture(pict.get()); 1363 orig->drawPicture(pict.get());
1364 } 1364 }
1365 } else { 1365 } else {
1366 picture->playback(orig); 1366 picture->playback(orig);
1367 } 1367 }
1368 } 1368 }
1369 1369
1370 // Do this after presentGL and other finishing, rather than in afterChild 1370 // Do this after presentGL and other finishing, rather than in afterChild
1371 if (fMeasureFPS) { 1371 if (fMeasureFPS) {
1372 fTimer.end(); 1372 fTimer.end();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 canvas->concat(m); 1406 canvas->concat(m);
1407 } 1407 }
1408 1408
1409 if (fMeasureFPS) { 1409 if (fMeasureFPS) {
1410 (void)SampleView::SetRepeatDraw(child, FPS_REPEAT_COUNT); 1410 (void)SampleView::SetRepeatDraw(child, FPS_REPEAT_COUNT);
1411 fTimer.start(); 1411 fTimer.start();
1412 } else { 1412 } else {
1413 (void)SampleView::SetRepeatDraw(child, 1); 1413 (void)SampleView::SetRepeatDraw(child, 1);
1414 } 1414 }
1415 if (fPerspAnim || fRotate) { 1415 if (fPerspAnim || fRotate) {
1416 this->inval(NULL); 1416 this->inval(nullptr);
1417 } 1417 }
1418 } 1418 }
1419 1419
1420 void SampleWindow::changeZoomLevel(float delta) { 1420 void SampleWindow::changeZoomLevel(float delta) {
1421 fZoomLevel += delta; 1421 fZoomLevel += delta;
1422 if (fZoomLevel > 0) { 1422 if (fZoomLevel > 0) {
1423 fZoomLevel = SkMinScalar(fZoomLevel, MAX_ZOOM_LEVEL); 1423 fZoomLevel = SkMinScalar(fZoomLevel, MAX_ZOOM_LEVEL);
1424 fZoomScale = fZoomLevel + SK_Scalar1; 1424 fZoomScale = fZoomLevel + SK_Scalar1;
1425 } else if (fZoomLevel < 0) { 1425 } else if (fZoomLevel < 0) {
1426 fZoomLevel = SkMaxScalar(fZoomLevel, MIN_ZOOM_LEVEL); 1426 fZoomLevel = SkMaxScalar(fZoomLevel, MIN_ZOOM_LEVEL);
(...skipping 30 matching lines...) Expand all
1457 m.preTranslate(-fZoomCenterX, -fZoomCenterY); 1457 m.preTranslate(-fZoomCenterX, -fZoomCenterY);
1458 //canvas->concat(m); 1458 //canvas->concat(m);
1459 } 1459 }
1460 // Apply any gesture matrix 1460 // Apply any gesture matrix
1461 m.preConcat(fGesture.localM()); 1461 m.preConcat(fGesture.localM());
1462 m.preConcat(fGesture.globalM()); 1462 m.preConcat(fGesture.globalM());
1463 1463
1464 this->setLocalMatrix(m); 1464 this->setLocalMatrix(m);
1465 1465
1466 this->updateTitle(); 1466 this->updateTitle();
1467 this->inval(NULL); 1467 this->inval(nullptr);
1468 } 1468 }
1469 bool SampleWindow::previousSample() { 1469 bool SampleWindow::previousSample() {
1470 fCurrIndex = (fCurrIndex - 1 + fSamples.count()) % fSamples.count(); 1470 fCurrIndex = (fCurrIndex - 1 + fSamples.count()) % fSamples.count();
1471 this->loadView((*fSamples[fCurrIndex])()); 1471 this->loadView((*fSamples[fCurrIndex])());
1472 return true; 1472 return true;
1473 } 1473 }
1474 1474
1475 #include "SkResourceCache.h" 1475 #include "SkResourceCache.h"
1476 #include "SkGlyphCache.h" 1476 #include "SkGlyphCache.h"
1477 bool SampleWindow::nextSample() { 1477 bool SampleWindow::nextSample() {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 this->nextSample(); 1521 this->nextSample();
1522 this->postAnimatingEvent(); 1522 this->postAnimatingEvent();
1523 } 1523 }
1524 return true; 1524 return true;
1525 } 1525 }
1526 if (evt.isType("set-curr-index")) { 1526 if (evt.isType("set-curr-index")) {
1527 this->goToSample(evt.getFast32()); 1527 this->goToSample(evt.getFast32());
1528 return true; 1528 return true;
1529 } 1529 }
1530 if (isInvalEvent(evt)) { 1530 if (isInvalEvent(evt)) {
1531 this->inval(NULL); 1531 this->inval(nullptr);
1532 return true; 1532 return true;
1533 } 1533 }
1534 int selected = -1; 1534 int selected = -1;
1535 if (SkOSMenu::FindListIndex(evt, "Device Type", &selected)) { 1535 if (SkOSMenu::FindListIndex(evt, "Device Type", &selected)) {
1536 this->setDeviceType((DeviceType)selected); 1536 this->setDeviceType((DeviceType)selected);
1537 return true; 1537 return true;
1538 } 1538 }
1539 if (SkOSMenu::FindTriState(evt, "Pipe", &fPipeState)) { 1539 if (SkOSMenu::FindTriState(evt, "Pipe", &fPipeState)) {
1540 #ifdef PIPE_NET 1540 #ifdef PIPE_NET
1541 if (!fPipeState != SkOSMenu::kOnState) 1541 if (!fPipeState != SkOSMenu::kOnState)
1542 gServer.disconnectAll(); 1542 gServer.disconnectAll();
1543 #endif 1543 #endif
1544 (void)SampleView::SetUsePipe(curr_view(this), fPipeState); 1544 (void)SampleView::SetUsePipe(curr_view(this), fPipeState);
1545 this->updateTitle(); 1545 this->updateTitle();
1546 this->inval(NULL); 1546 this->inval(nullptr);
1547 return true; 1547 return true;
1548 } 1548 }
1549 if (SkOSMenu::FindSwitchState(evt, "Slide Show", NULL)) { 1549 if (SkOSMenu::FindSwitchState(evt, "Slide Show", nullptr)) {
1550 this->toggleSlideshow(); 1550 this->toggleSlideshow();
1551 return true; 1551 return true;
1552 } 1552 }
1553 if (SkOSMenu::FindTriState(evt, "AA", &fAAState) || 1553 if (SkOSMenu::FindTriState(evt, "AA", &fAAState) ||
1554 SkOSMenu::FindTriState(evt, "LCD", &fLCDState) || 1554 SkOSMenu::FindTriState(evt, "LCD", &fLCDState) ||
1555 SkOSMenu::FindListIndex(evt, "FilterQuality", &fFilterQualityIndex) || 1555 SkOSMenu::FindListIndex(evt, "FilterQuality", &fFilterQualityIndex) ||
1556 SkOSMenu::FindTriState(evt, "Subpixel", &fSubpixelState) || 1556 SkOSMenu::FindTriState(evt, "Subpixel", &fSubpixelState) ||
1557 SkOSMenu::FindListIndex(evt, "Hinting", &fHintingState) || 1557 SkOSMenu::FindListIndex(evt, "Hinting", &fHintingState) ||
1558 SkOSMenu::FindSwitchState(evt, "Clip", &fUseClip) || 1558 SkOSMenu::FindSwitchState(evt, "Clip", &fUseClip) ||
1559 SkOSMenu::FindSwitchState(evt, "Zoomer", &fShowZoomer) || 1559 SkOSMenu::FindSwitchState(evt, "Zoomer", &fShowZoomer) ||
1560 SkOSMenu::FindSwitchState(evt, "Magnify", &fMagnify)) 1560 SkOSMenu::FindSwitchState(evt, "Magnify", &fMagnify))
1561 { 1561 {
1562 this->inval(NULL); 1562 this->inval(nullptr);
1563 this->updateTitle(); 1563 this->updateTitle();
1564 return true; 1564 return true;
1565 } 1565 }
1566 if (SkOSMenu::FindListIndex(evt, "Tiling", &fTilingMode)) { 1566 if (SkOSMenu::FindListIndex(evt, "Tiling", &fTilingMode)) {
1567 if (SampleView::IsSampleView(curr_view(this))) { 1567 if (SampleView::IsSampleView(curr_view(this))) {
1568 ((SampleView*)curr_view(this))->onTileSizeChanged(this->tileSize()); 1568 ((SampleView*)curr_view(this))->onTileSizeChanged(this->tileSize());
1569 } 1569 }
1570 this->inval(NULL); 1570 this->inval(nullptr);
1571 this->updateTitle(); 1571 this->updateTitle();
1572 return true; 1572 return true;
1573 } 1573 }
1574 if (SkOSMenu::FindSwitchState(evt, "Flip X", NULL)) { 1574 if (SkOSMenu::FindSwitchState(evt, "Flip X", nullptr)) {
1575 fFlipAxis ^= kFlipAxis_X; 1575 fFlipAxis ^= kFlipAxis_X;
1576 this->updateMatrix(); 1576 this->updateMatrix();
1577 return true; 1577 return true;
1578 } 1578 }
1579 if (SkOSMenu::FindSwitchState(evt, "Flip Y", NULL)) { 1579 if (SkOSMenu::FindSwitchState(evt, "Flip Y", nullptr)) {
1580 fFlipAxis ^= kFlipAxis_Y; 1580 fFlipAxis ^= kFlipAxis_Y;
1581 this->updateMatrix(); 1581 this->updateMatrix();
1582 return true; 1582 return true;
1583 } 1583 }
1584 if (SkOSMenu::FindAction(evt,"Save to PDF")) { 1584 if (SkOSMenu::FindAction(evt,"Save to PDF")) {
1585 this->saveToPdf(); 1585 this->saveToPdf();
1586 return true; 1586 return true;
1587 } 1587 }
1588 return this->INHERITED::onEvent(evt); 1588 return this->INHERITED::onEvent(evt);
1589 } 1589 }
(...skipping 10 matching lines...) Expand all
1600 query->setString("title", evt.findString(gTitleEvtName)); 1600 query->setString("title", evt.findString(gTitleEvtName));
1601 } 1601 }
1602 SkSafeUnref(view); 1602 SkSafeUnref(view);
1603 return true; 1603 return true;
1604 } 1604 }
1605 if (query->isType("use-fast-text")) { 1605 if (query->isType("use-fast-text")) {
1606 SkEvent evt(gFastTextEvtName); 1606 SkEvent evt(gFastTextEvtName);
1607 return curr_view(this)->doQuery(&evt); 1607 return curr_view(this)->doQuery(&evt);
1608 } 1608 }
1609 if (query->isType("ignore-window-bitmap")) { 1609 if (query->isType("ignore-window-bitmap")) {
1610 query->setFast32(this->getGrContext() != NULL); 1610 query->setFast32(this->getGrContext() != nullptr);
1611 return true; 1611 return true;
1612 } 1612 }
1613 return this->INHERITED::onQuery(query); 1613 return this->INHERITED::onQuery(query);
1614 } 1614 }
1615 1615
1616 DECLARE_bool(portableFonts); 1616 DECLARE_bool(portableFonts);
1617 1617
1618 bool SampleWindow::onHandleChar(SkUnichar uni) { 1618 bool SampleWindow::onHandleChar(SkUnichar uni) {
1619 { 1619 {
1620 SkView* view = curr_view(this); 1620 SkView* view = curr_view(this);
(...skipping 24 matching lines...) Expand all
1645 break; 1645 break;
1646 } 1646 }
1647 1647
1648 if (0xFF != dx && 0xFF != dy) { 1648 if (0xFF != dx && 0xFF != dy) {
1649 if ((dx | dy) == 0) { 1649 if ((dx | dy) == 0) {
1650 fScrollTestX = fScrollTestY = 0; 1650 fScrollTestX = fScrollTestY = 0;
1651 } else { 1651 } else {
1652 fScrollTestX += dx; 1652 fScrollTestX += dx;
1653 fScrollTestY += dy; 1653 fScrollTestY += dy;
1654 } 1654 }
1655 this->inval(NULL); 1655 this->inval(nullptr);
1656 return true; 1656 return true;
1657 } 1657 }
1658 1658
1659 switch (uni) { 1659 switch (uni) {
1660 case 27: // ESC 1660 case 27: // ESC
1661 gAnimTimer.stop(); 1661 gAnimTimer.stop();
1662 if (this->sendAnimatePulse()) { 1662 if (this->sendAnimatePulse()) {
1663 this->inval(NULL); 1663 this->inval(nullptr);
1664 } 1664 }
1665 break; 1665 break;
1666 case ' ': 1666 case ' ':
1667 gAnimTimer.togglePauseResume(); 1667 gAnimTimer.togglePauseResume();
1668 if (this->sendAnimatePulse()) { 1668 if (this->sendAnimatePulse()) {
1669 this->inval(NULL); 1669 this->inval(nullptr);
1670 } 1670 }
1671 break; 1671 break;
1672 case 'B': 1672 case 'B':
1673 post_event_to_sink(new SkEvent("PictFileView::toggleBBox"), curr_vie w(this)); 1673 post_event_to_sink(new SkEvent("PictFileView::toggleBBox"), curr_vie w(this));
1674 // Cannot call updateTitle() synchronously, because the toggleBBox e vent is still in 1674 // Cannot call updateTitle() synchronously, because the toggleBBox e vent is still in
1675 // the queue. 1675 // the queue.
1676 post_event_to_sink(new SkEvent(gUpdateWindowTitleEvtName), this); 1676 post_event_to_sink(new SkEvent(gUpdateWindowTitleEvtName), this);
1677 this->inval(NULL); 1677 this->inval(nullptr);
1678 break; 1678 break;
1679 case 'D': 1679 case 'D':
1680 toggleDistanceFieldFonts(); 1680 toggleDistanceFieldFonts();
1681 break; 1681 break;
1682 case 'f': 1682 case 'f':
1683 // only 1683 // only
1684 toggleFPS(); 1684 toggleFPS();
1685 break; 1685 break;
1686 case 'F': 1686 case 'F':
1687 FLAGS_portableFonts ^= true; 1687 FLAGS_portableFonts ^= true;
1688 this->inval(NULL); 1688 this->inval(nullptr);
1689 break; 1689 break;
1690 case 'g': 1690 case 'g':
1691 fRequestGrabImage = true; 1691 fRequestGrabImage = true;
1692 this->inval(NULL); 1692 this->inval(nullptr);
1693 break; 1693 break;
1694 case 'G': 1694 case 'G':
1695 gShowGMBounds = !gShowGMBounds; 1695 gShowGMBounds = !gShowGMBounds;
1696 post_event_to_sink(GMSampleView::NewShowSizeEvt(gShowGMBounds), 1696 post_event_to_sink(GMSampleView::NewShowSizeEvt(gShowGMBounds),
1697 curr_view(this)); 1697 curr_view(this));
1698 this->inval(NULL); 1698 this->inval(nullptr);
1699 break; 1699 break;
1700 case 'i': 1700 case 'i':
1701 this->zoomIn(); 1701 this->zoomIn();
1702 break; 1702 break;
1703 case 'o': 1703 case 'o':
1704 this->zoomOut(); 1704 this->zoomOut();
1705 break; 1705 break;
1706 case 'r': 1706 case 'r':
1707 fRotate = !fRotate; 1707 fRotate = !fRotate;
1708 this->inval(NULL); 1708 this->inval(nullptr);
1709 this->updateTitle(); 1709 this->updateTitle();
1710 return true; 1710 return true;
1711 case 'k': 1711 case 'k':
1712 fPerspAnim = !fPerspAnim; 1712 fPerspAnim = !fPerspAnim;
1713 this->inval(NULL); 1713 this->inval(nullptr);
1714 this->updateTitle(); 1714 this->updateTitle();
1715 return true; 1715 return true;
1716 case 'K': 1716 case 'K':
1717 fSaveToSKP = true; 1717 fSaveToSKP = true;
1718 this->inval(NULL); 1718 this->inval(nullptr);
1719 return true; 1719 return true;
1720 #if SK_SUPPORT_GPU 1720 #if SK_SUPPORT_GPU
1721 case 'p': 1721 case 'p':
1722 { 1722 {
1723 GrContext* grContext = this->getGrContext(); 1723 GrContext* grContext = this->getGrContext();
1724 if (grContext) { 1724 if (grContext) {
1725 size_t cacheBytes; 1725 size_t cacheBytes;
1726 grContext->getResourceCacheUsage(NULL, &cacheBytes); 1726 grContext->getResourceCacheUsage(nullptr, &cacheBytes);
1727 grContext->freeGpuResources(); 1727 grContext->freeGpuResources();
1728 SkDebugf("Purged %d bytes from the GPU resource cache.\n", c acheBytes); 1728 SkDebugf("Purged %d bytes from the GPU resource cache.\n", c acheBytes);
1729 } 1729 }
1730 } 1730 }
1731 return true; 1731 return true;
1732 #endif 1732 #endif
1733 default: 1733 default:
1734 break; 1734 break;
1735 } 1735 }
1736 1736
1737 if (fAppMenu->handleKeyEquivalent(uni)|| fSlideMenu->handleKeyEquivalent(uni )) { 1737 if (fAppMenu->handleKeyEquivalent(uni)|| fSlideMenu->handleKeyEquivalent(uni )) {
1738 this->onUpdateMenu(fAppMenu); 1738 this->onUpdateMenu(fAppMenu);
1739 this->onUpdateMenu(fSlideMenu); 1739 this->onUpdateMenu(fSlideMenu);
1740 return true; 1740 return true;
1741 } 1741 }
1742 return this->INHERITED::onHandleChar(uni); 1742 return this->INHERITED::onHandleChar(uni);
1743 } 1743 }
1744 1744
1745 void SampleWindow::setDeviceType(DeviceType type) { 1745 void SampleWindow::setDeviceType(DeviceType type) {
1746 if (type == fDeviceType) 1746 if (type == fDeviceType)
1747 return; 1747 return;
1748 1748
1749 fDevManager->tearDownBackend(this); 1749 fDevManager->tearDownBackend(this);
1750 1750
1751 fDeviceType = type; 1751 fDeviceType = type;
1752 1752
1753 fDevManager->setUpBackend(this, fMSAASampleCount); 1753 fDevManager->setUpBackend(this, fMSAASampleCount);
1754 1754
1755 this->updateTitle(); 1755 this->updateTitle();
1756 this->inval(NULL); 1756 this->inval(nullptr);
1757 } 1757 }
1758 1758
1759 void SampleWindow::toggleSlideshow() { 1759 void SampleWindow::toggleSlideshow() {
1760 fAnimating = !fAnimating; 1760 fAnimating = !fAnimating;
1761 this->postAnimatingEvent(); 1761 this->postAnimatingEvent();
1762 this->updateTitle(); 1762 this->updateTitle();
1763 } 1763 }
1764 1764
1765 void SampleWindow::toggleRendering() { 1765 void SampleWindow::toggleRendering() {
1766 this->setDeviceType(cycle_devicetype(fDeviceType)); 1766 this->setDeviceType(cycle_devicetype(fDeviceType));
1767 this->updateTitle(); 1767 this->updateTitle();
1768 this->inval(NULL); 1768 this->inval(nullptr);
1769 } 1769 }
1770 1770
1771 void SampleWindow::toggleFPS() { 1771 void SampleWindow::toggleFPS() {
1772 fMeasureFPS = !fMeasureFPS; 1772 fMeasureFPS = !fMeasureFPS;
1773 this->updateTitle(); 1773 this->updateTitle();
1774 this->inval(NULL); 1774 this->inval(nullptr);
1775 } 1775 }
1776 1776
1777 void SampleWindow::toggleDistanceFieldFonts() { 1777 void SampleWindow::toggleDistanceFieldFonts() {
1778 SkSurfaceProps props = this->getSurfaceProps(); 1778 SkSurfaceProps props = this->getSurfaceProps();
1779 uint32_t flags = props.flags() ^ SkSurfaceProps::kUseDistanceFieldFonts_Flag ; 1779 uint32_t flags = props.flags() ^ SkSurfaceProps::kUseDistanceFieldFonts_Flag ;
1780 this->setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry())); 1780 this->setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry()));
1781 1781
1782 this->updateTitle(); 1782 this->updateTitle();
1783 this->inval(NULL); 1783 this->inval(nullptr);
1784 } 1784 }
1785 1785
1786 #include "SkDumpCanvas.h" 1786 #include "SkDumpCanvas.h"
1787 1787
1788 bool SampleWindow::onHandleKey(SkKey key) { 1788 bool SampleWindow::onHandleKey(SkKey key) {
1789 { 1789 {
1790 SkView* view = curr_view(this); 1790 SkView* view = curr_view(this);
1791 if (view) { 1791 if (view) {
1792 SkEvent evt(gKeyEvtName); 1792 SkEvent evt(gKeyEvtName);
1793 evt.setFast32(key); 1793 evt.setFast32(key);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 } 1840 }
1841 int w = SkScalarRoundToInt(this->width()); 1841 int w = SkScalarRoundToInt(this->width());
1842 int h = SkScalarRoundToInt(this->height()); 1842 int h = SkScalarRoundToInt(this->height());
1843 1843
1844 // check for the resize-box 1844 // check for the resize-box
1845 if (w - x < 16 && h - y < 16) { 1845 if (w - x < 16 && h - y < 16) {
1846 return false; // let the OS handle the click 1846 return false; // let the OS handle the click
1847 } 1847 }
1848 else if (fMagnify) { 1848 else if (fMagnify) {
1849 //it's only necessary to update the drawing if there's a click 1849 //it's only necessary to update the drawing if there's a click
1850 this->inval(NULL); 1850 this->inval(nullptr);
1851 return false; //prevent dragging while magnify is enabled 1851 return false; //prevent dragging while magnify is enabled
1852 } else { 1852 } else {
1853 // capture control+option, and trigger debugger 1853 // capture control+option, and trigger debugger
1854 if ((modi & kControl_SkModifierKey) && (modi & kOption_SkModifierKey)) { 1854 if ((modi & kControl_SkModifierKey) && (modi & kOption_SkModifierKey)) {
1855 if (Click::kDown_State == state) { 1855 if (Click::kDown_State == state) {
1856 SkEvent evt("debug-hit-test"); 1856 SkEvent evt("debug-hit-test");
1857 evt.setS32("debug-hit-test-x", x); 1857 evt.setS32("debug-hit-test-x", x);
1858 evt.setS32("debug-hit-test-y", y); 1858 evt.setS32("debug-hit-test-y", y);
1859 curr_view(this)->doEvent(evt); 1859 curr_view(this)->doEvent(evt);
1860 } 1860 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 static_assert(SK_ARRAY_COUNT(gDeviceTypePrefix) == SampleWindow::kDeviceTypeCnt, 1944 static_assert(SK_ARRAY_COUNT(gDeviceTypePrefix) == SampleWindow::kDeviceTypeCnt,
1945 "array_size_mismatch"); 1945 "array_size_mismatch");
1946 1946
1947 static const char* trystate_str(SkOSMenu::TriState state, 1947 static const char* trystate_str(SkOSMenu::TriState state,
1948 const char trueStr[], const char falseStr[]) { 1948 const char trueStr[], const char falseStr[]) {
1949 if (SkOSMenu::kOnState == state) { 1949 if (SkOSMenu::kOnState == state) {
1950 return trueStr; 1950 return trueStr;
1951 } else if (SkOSMenu::kOffState == state) { 1951 } else if (SkOSMenu::kOffState == state) {
1952 return falseStr; 1952 return falseStr;
1953 } 1953 }
1954 return NULL; 1954 return nullptr;
1955 } 1955 }
1956 1956
1957 bool SampleWindow::getRawTitle(SkString* title) { 1957 bool SampleWindow::getRawTitle(SkString* title) {
1958 return curr_title(this, title); 1958 return curr_title(this, title);
1959 } 1959 }
1960 1960
1961 void SampleWindow::updateTitle() { 1961 void SampleWindow::updateTitle() {
1962 SkString title; 1962 SkString title;
1963 if (!this->getRawTitle(&title)) { 1963 if (!this->getRawTitle(&title)) {
1964 title.set("<unknown>"); 1964 title.set("<unknown>");
(...skipping 17 matching lines...) Expand all
1982 title.prepend("<K> "); 1982 title.prepend("<K> ");
1983 } 1983 }
1984 if (this->getSurfaceProps().flags() & SkSurfaceProps::kUseDistanceFieldFonts _Flag) { 1984 if (this->getSurfaceProps().flags() & SkSurfaceProps::kUseDistanceFieldFonts _Flag) {
1985 title.prepend("<DFF> "); 1985 title.prepend("<DFF> ");
1986 } 1986 }
1987 1987
1988 title.prepend(trystate_str(fLCDState, "LCD ", "lcd ")); 1988 title.prepend(trystate_str(fLCDState, "LCD ", "lcd "));
1989 title.prepend(trystate_str(fAAState, "AA ", "aa ")); 1989 title.prepend(trystate_str(fAAState, "AA ", "aa "));
1990 title.prepend(gFilterQualityStates[fFilterQualityIndex].fLabel); 1990 title.prepend(gFilterQualityStates[fFilterQualityIndex].fLabel);
1991 title.prepend(trystate_str(fSubpixelState, "S ", "s ")); 1991 title.prepend(trystate_str(fSubpixelState, "S ", "s "));
1992 title.prepend(fFlipAxis & kFlipAxis_X ? "X " : NULL); 1992 title.prepend(fFlipAxis & kFlipAxis_X ? "X " : nullptr);
1993 title.prepend(fFlipAxis & kFlipAxis_Y ? "Y " : NULL); 1993 title.prepend(fFlipAxis & kFlipAxis_Y ? "Y " : nullptr);
1994 title.prepend(gHintingStates[fHintingState].label); 1994 title.prepend(gHintingStates[fHintingState].label);
1995 1995
1996 if (fZoomLevel) { 1996 if (fZoomLevel) {
1997 title.prependf("{%.2f} ", SkScalarToFloat(fZoomLevel)); 1997 title.prependf("{%.2f} ", SkScalarToFloat(fZoomLevel));
1998 } 1998 }
1999 1999
2000 if (fMeasureFPS) { 2000 if (fMeasureFPS) {
2001 title.appendf(" %8.4f ms", fMeasureFPS_Time / (float)FPS_REPEAT_COUNT); 2001 title.appendf(" %8.4f ms", fMeasureFPS_Time / (float)FPS_REPEAT_COUNT);
2002 } 2002 }
2003 2003
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2134 void* fBlock; 2134 void* fBlock;
2135 size_t fBlockSize; 2135 size_t fBlockSize;
2136 size_t fBytesWritten; 2136 size_t fBytesWritten;
2137 int fAtomsWritten; 2137 int fAtomsWritten;
2138 SkGPipeReader::Status fStatus; 2138 SkGPipeReader::Status fStatus;
2139 2139
2140 size_t fTotalWritten; 2140 size_t fTotalWritten;
2141 }; 2141 };
2142 2142
2143 SimplePC::SimplePC(SkCanvas* target) : fReader(target) { 2143 SimplePC::SimplePC(SkCanvas* target) : fReader(target) {
2144 fBlock = NULL; 2144 fBlock = nullptr;
2145 fBlockSize = fBytesWritten = 0; 2145 fBlockSize = fBytesWritten = 0;
2146 fStatus = SkGPipeReader::kDone_Status; 2146 fStatus = SkGPipeReader::kDone_Status;
2147 fTotalWritten = 0; 2147 fTotalWritten = 0;
2148 fAtomsWritten = 0; 2148 fAtomsWritten = 0;
2149 fReader.setBitmapDecoder(&SkImageDecoder::DecodeMemory); 2149 fReader.setBitmapDecoder(&SkImageDecoder::DecodeMemory);
2150 } 2150 }
2151 2151
2152 SimplePC::~SimplePC() { 2152 SimplePC::~SimplePC() {
2153 // SkASSERT(SkGPipeReader::kDone_Status == fStatus); 2153 // SkASSERT(SkGPipeReader::kDone_Status == fStatus);
2154 if (fTotalWritten) { 2154 if (fTotalWritten) {
2155 SkDebugf("--- %d bytes %d atoms, status %d\n", fTotalWritten, 2155 SkDebugf("--- %d bytes %d atoms, status %d\n", fTotalWritten,
2156 fAtomsWritten, fStatus); 2156 fAtomsWritten, fStatus);
2157 #ifdef PIPE_FILE 2157 #ifdef PIPE_FILE
2158 //File is open in append mode 2158 //File is open in append mode
2159 FILE* f = fopen(FILE_PATH, "ab"); 2159 FILE* f = fopen(FILE_PATH, "ab");
2160 SkASSERT(f != NULL); 2160 SkASSERT(f != nullptr);
2161 fwrite((const char*)fBlock + fBytesWritten, 1, bytes, f); 2161 fwrite((const char*)fBlock + fBytesWritten, 1, bytes, f);
2162 fclose(f); 2162 fclose(f);
2163 #endif 2163 #endif
2164 #ifdef PIPE_NET 2164 #ifdef PIPE_NET
2165 if (fAtomsWritten > 1 && fTotalWritten > 4) { //ignore done 2165 if (fAtomsWritten > 1 && fTotalWritten > 4) { //ignore done
2166 gServer.acceptConnections(); 2166 gServer.acceptConnections();
2167 gServer.writePacket(fBlock, fTotalWritten); 2167 gServer.writePacket(fBlock, fTotalWritten);
2168 } 2168 }
2169 #endif 2169 #endif
2170 } 2170 }
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 test_rects(rect, N); 2334 test_rects(rect, N);
2335 } 2335 }
2336 } 2336 }
2337 2337
2338 // FIXME: this should be in a header 2338 // FIXME: this should be in a header
2339 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv); 2339 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv);
2340 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { 2340 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) {
2341 if (false) { // avoid bit rot, suppress warning 2341 if (false) { // avoid bit rot, suppress warning
2342 test(); 2342 test();
2343 } 2343 }
2344 return new SampleWindow(hwnd, argc, argv, NULL); 2344 return new SampleWindow(hwnd, argc, argv, nullptr);
2345 } 2345 }
2346 2346
2347 // FIXME: this should be in a header 2347 // FIXME: this should be in a header
2348 void get_preferred_size(int* x, int* y, int* width, int* height); 2348 void get_preferred_size(int* x, int* y, int* width, int* height);
2349 void get_preferred_size(int* x, int* y, int* width, int* height) { 2349 void get_preferred_size(int* x, int* y, int* width, int* height) {
2350 *x = 10; 2350 *x = 10;
2351 *y = 50; 2351 *y = 50;
2352 *width = 640; 2352 *width = 640;
2353 *height = 480; 2353 *height = 480;
2354 } 2354 }
(...skipping 12 matching lines...) Expand all
2367 setenv("ANDROID_ROOT", "/android/device/data", 0); 2367 setenv("ANDROID_ROOT", "/android/device/data", 0);
2368 #endif 2368 #endif
2369 SkGraphics::Init(); 2369 SkGraphics::Init();
2370 SkEvent::Init(); 2370 SkEvent::Init();
2371 } 2371 }
2372 2372
2373 void application_term() { 2373 void application_term() {
2374 SkEvent::Term(); 2374 SkEvent::Term();
2375 SkGraphics::Term(); 2375 SkGraphics::Term();
2376 } 2376 }
OLDNEW
« no previous file with comments | « samplecode/SampleApp.h ('k') | samplecode/SampleArc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698