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

Side by Side Diff: experimental/SkiaExamples/SkExample.cpp

Issue 23708009: Add ShouldSkip variant that can read a --match flag directly. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: reupload Created 7 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 | Annotate | Revision Log
« no previous file with comments | « experimental/SkiaExamples/SkExample.h ('k') | gm/gmmain.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 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 * 7 *
8 */ 8 */
9 9
10 #include "SkExample.h" 10 #include "SkExample.h"
(...skipping 24 matching lines...) Expand all
35 SkEvent::Term(); 35 SkEvent::Term();
36 SkGraphics::Term(); 36 SkGraphics::Term();
37 } 37 }
38 38
39 SkExampleWindow::SkExampleWindow(void* hwnd) 39 SkExampleWindow::SkExampleWindow(void* hwnd)
40 : INHERITED(hwnd) { 40 : INHERITED(hwnd) {
41 fRegistry = SkExample::Registry::Head(); 41 fRegistry = SkExample::Registry::Head();
42 fCurrExample = fRegistry->factory()(this); 42 fCurrExample = fRegistry->factory()(this);
43 43
44 if (FLAGS_match.count()) { 44 if (FLAGS_match.count()) {
45 for(int i = 0; i < FLAGS_match.count(); ++i) {
46 fMatchStrs.push(FLAGS_match[i]);
47 }
48 // Start with the a matching sample if possible. 45 // Start with the a matching sample if possible.
49 bool found = this->findNextMatch(); 46 bool found = this->findNextMatch();
50 if (!found) { 47 if (!found) {
51 SkDebugf("No matching SkExample found.\n"); 48 SkDebugf("No matching SkExample found.\n");
52 } 49 }
53 } 50 }
54 } 51 }
55 52
56 void SkExampleWindow::tearDownBackend() { 53 void SkExampleWindow::tearDownBackend() {
57 if (kGPU_DeviceType == fType) { 54 if (kGPU_DeviceType == fType) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 bool SkExampleWindow::findNextMatch() { 160 bool SkExampleWindow::findNextMatch() {
164 bool found = false; 161 bool found = false;
165 // Avoid infinite loop by knowing where we started. 162 // Avoid infinite loop by knowing where we started.
166 const SkExample::Registry* begin = fRegistry; 163 const SkExample::Registry* begin = fRegistry;
167 while (!found) { 164 while (!found) {
168 fRegistry = fRegistry->next(); 165 fRegistry = fRegistry->next();
169 if (NULL == fRegistry) { // Reached the end of the registered samples. GOTO head. 166 if (NULL == fRegistry) { // Reached the end of the registered samples. GOTO head.
170 fRegistry = SkExample::Registry::Head(); 167 fRegistry = SkExample::Registry::Head();
171 } 168 }
172 SkExample* next = fRegistry->factory()(this); 169 SkExample* next = fRegistry->factory()(this);
173 if (!SkCommandLineFlags::ShouldSkip(fMatchStrs, next->getName().c_str()) ) { 170 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, next->getName().c_str() )) {
174 fCurrExample = next; 171 fCurrExample = next;
175 found = true; 172 found = true;
176 } 173 }
177 if (begin == fRegistry) { // We looped through every sample without fin ding anything. 174 if (begin == fRegistry) { // We looped through every sample without fin ding anything.
178 break; 175 break;
179 } 176 }
180 } 177 }
181 return found; 178 return found;
182 } 179 }
183 180
184 bool SkExampleWindow::onHandleChar(SkUnichar unichar) { 181 bool SkExampleWindow::onHandleChar(SkUnichar unichar) {
185 if ('n' == unichar) { 182 if ('n' == unichar) {
186 bool found = findNextMatch(); 183 bool found = findNextMatch();
187 if (!found) { 184 if (!found) {
188 SkDebugf("No SkExample that matches your query\n"); 185 SkDebugf("No SkExample that matches your query\n");
189 } 186 }
190 } 187 }
191 return true; 188 return true;
192 } 189 }
193 190
194 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { 191 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) {
195 SkCommandLineFlags::Parse(argc, argv); 192 SkCommandLineFlags::Parse(argc, argv);
196 return new SkExampleWindow(hwnd); 193 return new SkExampleWindow(hwnd);
197 } 194 }
OLDNEW
« no previous file with comments | « experimental/SkiaExamples/SkExample.h ('k') | gm/gmmain.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698