| OLD | NEW |
| 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 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 | 33 |
| 34 void application_term() { | 34 void application_term() { |
| 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->data()(this); |
| 43 | 43 |
| 44 if (FLAGS_match.count()) { | 44 if (FLAGS_match.count()) { |
| 45 // Start with the a matching sample if possible. | 45 // Start with the a matching sample if possible. |
| 46 bool found = this->findNextMatch(); | 46 bool found = this->findNextMatch(); |
| 47 if (!found) { | 47 if (!found) { |
| 48 SkDebugf("No matching SkExample found.\n"); | 48 SkDebugf("No matching SkExample found.\n"); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 bool SkExampleWindow::findNextMatch() { | 160 bool SkExampleWindow::findNextMatch() { |
| 161 bool found = false; | 161 bool found = false; |
| 162 // Avoid infinite loop by knowing where we started. | 162 // Avoid infinite loop by knowing where we started. |
| 163 const SkExample::Registry* begin = fRegistry; | 163 const SkExample::Registry* begin = fRegistry; |
| 164 while (!found) { | 164 while (!found) { |
| 165 fRegistry = fRegistry->next(); | 165 fRegistry = fRegistry->next(); |
| 166 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. |
| 167 fRegistry = SkExample::Registry::Head(); | 167 fRegistry = SkExample::Registry::Head(); |
| 168 } | 168 } |
| 169 SkExample* next = fRegistry->factory()(this); | 169 SkExample* next = fRegistry->data()(this); |
| 170 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, next->getName().c_str()
)) { | 170 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, next->getName().c_str()
)) { |
| 171 fCurrExample = next; | 171 fCurrExample = next; |
| 172 found = true; | 172 found = true; |
| 173 } | 173 } |
| 174 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. |
| 175 break; | 175 break; |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 return found; | 178 return found; |
| 179 } | 179 } |
| 180 | 180 |
| 181 bool SkExampleWindow::onHandleChar(SkUnichar unichar) { | 181 bool SkExampleWindow::onHandleChar(SkUnichar unichar) { |
| 182 if ('n' == unichar) { | 182 if ('n' == unichar) { |
| 183 bool found = findNextMatch(); | 183 bool found = findNextMatch(); |
| 184 if (!found) { | 184 if (!found) { |
| 185 SkDebugf("No SkExample that matches your query\n"); | 185 SkDebugf("No SkExample that matches your query\n"); |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 return true; | 188 return true; |
| 189 } | 189 } |
| 190 | 190 |
| 191 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { | 191 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { |
| 192 SkCommandLineFlags::Parse(argc, argv); | 192 SkCommandLineFlags::Parse(argc, argv); |
| 193 return new SkExampleWindow(hwnd); | 193 return new SkExampleWindow(hwnd); |
| 194 } | 194 } |
| OLD | NEW |