OLD | NEW |
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" |
| 11 #include "SampleCode.h" |
| 12 #include "SamplePipeControllers.h" |
| 13 #include "SkCanvas.h" |
| 14 #include "SkCommandLineFlags.h" |
10 #include "SkData.h" | 15 #include "SkData.h" |
11 #include "SkCanvas.h" | |
12 #include "SkDevice.h" | 16 #include "SkDevice.h" |
| 17 #include "SkGPipe.h" |
13 #include "SkGraphics.h" | 18 #include "SkGraphics.h" |
14 #include "SkImageDecoder.h" | |
15 #include "SkImageEncoder.h" | 19 #include "SkImageEncoder.h" |
| 20 #include "SkOSFile.h" |
| 21 #include "SkPDFDevice.h" |
| 22 #include "SkPDFDocument.h" |
16 #include "SkPaint.h" | 23 #include "SkPaint.h" |
17 #include "SkPicture.h" | 24 #include "SkPicture.h" |
18 #include "SkPictureRecorder.h" | 25 #include "SkPictureRecorder.h" |
19 #include "SkStream.h" | 26 #include "SkStream.h" |
20 #include "SkSurface.h" | 27 #include "SkSurface.h" |
21 #include "SkTSort.h" | 28 #include "SkTSort.h" |
22 #include "SkTime.h" | 29 #include "SkTime.h" |
| 30 #include "SkTypeface.h" |
23 #include "SkWindow.h" | 31 #include "SkWindow.h" |
24 | 32 #include "TransitionView.h" |
25 #include "SampleCode.h" | 33 #include "sk_tool_utils.h" |
26 #include "SkTypeface.h" | |
27 | 34 |
28 #if SK_SUPPORT_GPU | 35 #if SK_SUPPORT_GPU |
29 #include "gl/GrGLInterface.h" | 36 #include "gl/GrGLInterface.h" |
30 #include "gl/GrGLUtil.h" | 37 #include "gl/GrGLUtil.h" |
31 #include "GrRenderTarget.h" | 38 #include "GrRenderTarget.h" |
32 #include "GrContext.h" | 39 #include "GrContext.h" |
33 #include "SkGpuDevice.h" | 40 #include "SkGpuDevice.h" |
34 #else | 41 #else |
35 class GrContext; | 42 class GrContext; |
36 #endif | 43 #endif |
37 | 44 |
38 #include "SkOSFile.h" | |
39 #include "SkPDFDevice.h" | |
40 #include "SkPDFDocument.h" | |
41 #include "SkStream.h" | |
42 | |
43 #include "SkGPipe.h" | |
44 #include "SamplePipeControllers.h" | |
45 #include "OverView.h" | |
46 #include "TransitionView.h" | |
47 #include "sk_tool_utils.h" | |
48 | |
49 extern SampleView* CreateSamplePictFileView(const char filename[]); | 45 extern SampleView* CreateSamplePictFileView(const char filename[]); |
50 | 46 |
51 class PictFileFactory : public SkViewFactory { | 47 class PictFileFactory : public SkViewFactory { |
52 SkString fFilename; | 48 SkString fFilename; |
53 public: | 49 public: |
54 PictFileFactory(const SkString& filename) : fFilename(filename) {} | 50 PictFileFactory(const SkString& filename) : fFilename(filename) {} |
55 virtual SkView* operator() () const SK_OVERRIDE { | 51 virtual SkView* operator() () const SK_OVERRIDE { |
56 return CreateSamplePictFileView(fFilename.c_str()); | 52 return CreateSamplePictFileView(fFilename.c_str()); |
57 } | 53 } |
58 }; | 54 }; |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 break; | 772 break; |
777 } | 773 } |
778 } | 774 } |
779 | 775 |
780 if (sort) { | 776 if (sort) { |
781 // Sort samples, so foo.skp and foo.pdf are consecutive and we can quick
ly spot where | 777 // Sort samples, so foo.skp and foo.pdf are consecutive and we can quick
ly spot where |
782 // skp -> pdf -> png fails. | 778 // skp -> pdf -> png fails. |
783 SkTQSort(fSamples.begin(), fSamples.end() ? fSamples.end() - 1 : NULL, c
ompareSampleTitle); | 779 SkTQSort(fSamples.begin(), fSamples.end() ? fSamples.end() - 1 : NULL, c
ompareSampleTitle); |
784 } | 780 } |
785 | 781 |
786 const char* resourcePath = "resources"; // same default as tests | |
787 fMSAASampleCount = 0; | 782 fMSAASampleCount = 0; |
788 | 783 |
| 784 SkCommandLineFlags::Parse(argc, argv); |
| 785 |
789 const char* const commandName = argv[0]; | 786 const char* const commandName = argv[0]; |
790 char* const* stop = argv + argc; | 787 char* const* stop = argv + argc; |
791 for (++argv; argv < stop; ++argv) { | 788 for (++argv; argv < stop; ++argv) { |
792 if (!strcmp(*argv, "-i") || !strcmp(*argv, "--resourcePath")) { | 789 if (strcmp(*argv, "--slide") == 0) { |
793 argv++; | |
794 if (argv < stop && **argv) { | |
795 resourcePath = *argv; | |
796 } | |
797 } else if (strcmp(*argv, "--slide") == 0) { | |
798 argv++; | 790 argv++; |
799 if (argv < stop && **argv) { | 791 if (argv < stop && **argv) { |
800 fCurrIndex = findByTitle(*argv); | 792 fCurrIndex = findByTitle(*argv); |
801 if (fCurrIndex < 0) { | 793 if (fCurrIndex < 0) { |
802 fprintf(stderr, "Unknown sample \"%s\"\n", *argv); | 794 fprintf(stderr, "Unknown sample \"%s\"\n", *argv); |
803 listTitles(); | 795 listTitles(); |
804 } | 796 } |
805 } | 797 } |
806 } else if (strcmp(*argv, "--msaa") == 0) { | 798 } else if (strcmp(*argv, "--msaa") == 0) { |
807 ++argv; | 799 ++argv; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 fAppMenu->assignKeyEquivalentToItem(itemID, 'e'); | 950 fAppMenu->assignKeyEquivalentToItem(itemID, 'e'); |
959 | 951 |
960 this->addMenu(fAppMenu); | 952 this->addMenu(fAppMenu); |
961 fSlideMenu = new SkOSMenu; | 953 fSlideMenu = new SkOSMenu; |
962 this->addMenu(fSlideMenu); | 954 this->addMenu(fSlideMenu); |
963 | 955 |
964 this->setColorType(kN32_SkColorType); | 956 this->setColorType(kN32_SkColorType); |
965 this->setVisibleP(true); | 957 this->setVisibleP(true); |
966 this->setClipToBounds(false); | 958 this->setClipToBounds(false); |
967 | 959 |
968 skiagm::GM::SetResourcePath(resourcePath); | |
969 | |
970 this->loadView((*fSamples[fCurrIndex])()); | 960 this->loadView((*fSamples[fCurrIndex])()); |
971 | 961 |
972 fPDFData = NULL; | 962 fPDFData = NULL; |
973 | 963 |
974 if (NULL == devManager) { | 964 if (NULL == devManager) { |
975 fDevManager = new DefaultDeviceManager(); | 965 fDevManager = new DefaultDeviceManager(); |
976 } else { | 966 } else { |
977 devManager->ref(); | 967 devManager->ref(); |
978 fDevManager = devManager; | 968 fDevManager = devManager; |
979 } | 969 } |
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2514 SkGraphics::Init(); | 2504 SkGraphics::Init(); |
2515 SkEvent::Init(); | 2505 SkEvent::Init(); |
2516 } | 2506 } |
2517 | 2507 |
2518 // FIXME: this should be in a header | 2508 // FIXME: this should be in a header |
2519 void application_term(); | 2509 void application_term(); |
2520 void application_term() { | 2510 void application_term() { |
2521 SkEvent::Term(); | 2511 SkEvent::Term(); |
2522 SkGraphics::Term(); | 2512 SkGraphics::Term(); |
2523 } | 2513 } |
OLD | NEW |