| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 | 8 |
| 9 #include "VisualBench.h" | 9 #include "VisualBench.h" |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // load all SKPs | 49 // load all SKPs |
| 50 SkTArray<SkString> skps; | 50 SkTArray<SkString> skps; |
| 51 for (int i = 0; i < FLAGS_skps.count(); i++) { | 51 for (int i = 0; i < FLAGS_skps.count(); i++) { |
| 52 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { | 52 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { |
| 53 skps.push_back() = FLAGS_skps[i]; | 53 skps.push_back() = FLAGS_skps[i]; |
| 54 fTimings.push_back().fName = FLAGS_skps[i]; | 54 fTimings.push_back().fName = FLAGS_skps[i]; |
| 55 } else { | 55 } else { |
| 56 SkOSFile::Iter it(FLAGS_skps[i], ".skp"); | 56 SkOSFile::Iter it(FLAGS_skps[i], ".skp"); |
| 57 SkString path; | 57 SkString path; |
| 58 while (it.next(&path)) { | 58 while (it.next(&path)) { |
| 59 skps.push_back() = SkOSPath::Join(FLAGS_skps[0], path.c_str()); | 59 skps.push_back() = SkOSPath::Join(FLAGS_skps[i], path.c_str()); |
| 60 fTimings.push_back().fName = path.c_str(); | 60 fTimings.push_back().fName = path.c_str(); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 for (int i = 0; i < skps.count(); i++) { | 65 for (int i = 0; i < skps.count(); i++) { |
| 66 SkFILEStream stream(skps[i].c_str()); | 66 SkFILEStream stream(skps[i].c_str()); |
| 67 if (stream.isValid()) { | 67 if (stream.isValid()) { |
| 68 fPictures.push_back(SkPicture::CreateFromStream(&stream)); | 68 fPictures.push_back(SkPicture::CreateFromStream(&stream)); |
| 69 } else { | 69 } else { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 // setup contexts | 120 // setup contexts |
| 121 fContext.reset(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)fInter
face.get())); | 121 fContext.reset(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)fInter
face.get())); |
| 122 SkASSERT(fContext); | 122 SkASSERT(fContext); |
| 123 | 123 |
| 124 // setup rendertargets | 124 // setup rendertargets |
| 125 this->setupRenderTarget(); | 125 this->setupRenderTarget(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void VisualBench::setupRenderTarget() { | 128 void VisualBench::setupRenderTarget() { |
| 129 fRenderTarget.reset(this->renderTarget(fAttachmentInfo, fInterface, fContext
)); | 129 if (fContext) { |
| 130 fRenderTarget.reset(this->renderTarget(fAttachmentInfo, fInterface, fCon
text)); |
| 131 } |
| 130 } | 132 } |
| 131 | 133 |
| 132 inline void VisualBench::renderFrame(SkCanvas* canvas) { | 134 inline void VisualBench::renderFrame(SkCanvas* canvas) { |
| 133 canvas->drawPicture(fPictures[fCurrentPicture]); | 135 canvas->drawPicture(fPictures[fCurrentPicture]); |
| 134 fContext->flush(); | 136 fContext->flush(); |
| 135 INHERITED::present(); | 137 INHERITED::present(); |
| 136 } | 138 } |
| 137 | 139 |
| 138 void VisualBench::printStats() { | 140 void VisualBench::printStats() { |
| 139 const SkTArray<double>& measurements = fTimings[fCurrentPicture].fMeasuremen
ts; | 141 const SkTArray<double>& measurements = fTimings[fCurrentPicture].fMeasuremen
ts; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 224 |
| 223 void application_term() { | 225 void application_term() { |
| 224 SkEvent::Term(); | 226 SkEvent::Term(); |
| 225 SkGraphics::Term(); | 227 SkGraphics::Term(); |
| 226 } | 228 } |
| 227 | 229 |
| 228 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { | 230 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { |
| 229 return new VisualBench(hwnd, argc, argv); | 231 return new VisualBench(hwnd, argc, argv); |
| 230 } | 232 } |
| 231 | 233 |
| OLD | NEW |