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

Side by Side Diff: bench/nanobench.cpp

Issue 2345533002: [SVGDom] Expose intrinsic size info (Closed)
Patch Set: private intrinsicSize() Created 4 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 | « no previous file | dm/DMSrcSink.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 2014 Google Inc. 2 * Copyright 2014 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 <ctype.h> 8 #include <ctype.h>
9 9
10 #include "nanobench.h" 10 #include "nanobench.h"
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 return SkPicture::MakeFromStream(stream.get()); 644 return SkPicture::MakeFromStream(stream.get());
645 } 645 }
646 646
647 static sk_sp<SkPicture> ReadSVGPicture(const char* path) { 647 static sk_sp<SkPicture> ReadSVGPicture(const char* path) {
648 SkFILEStream stream(path); 648 SkFILEStream stream(path);
649 if (!stream.isValid()) { 649 if (!stream.isValid()) {
650 SkDebugf("Could not read %s.\n", path); 650 SkDebugf("Could not read %s.\n", path);
651 return nullptr; 651 return nullptr;
652 } 652 }
653 653
654 // TODO: use intrinsic size? make tunable via flag? 654 sk_sp<SkSVGDOM> svgDom = SkSVGDOM::MakeFromStream(stream);
655 static const SkSize kContainerSize = SkSize::Make(128, 128);
656 sk_sp<SkSVGDOM> svgDom = SkSVGDOM::MakeFromStream(stream, kContainerSize );
657 if (!svgDom) { 655 if (!svgDom) {
658 SkDebugf("Could not parse %s.\n", path); 656 SkDebugf("Could not parse %s.\n", path);
659 return nullptr; 657 return nullptr;
660 } 658 }
661 659
660 // Use the intrinsic SVG size if available, otherwise fall back to a def ault value.
661 static const SkSize kDefaultContainerSize = SkSize::Make(128, 128);
662 if (svgDom->containerSize().isEmpty()) {
663 svgDom->setContainerSize(kDefaultContainerSize);
664 }
665
662 SkPictureRecorder recorder; 666 SkPictureRecorder recorder;
663 svgDom->render(recorder.beginRecording(kContainerSize.width(), kContaine rSize.height())); 667 svgDom->render(recorder.beginRecording(svgDom->containerSize().width(),
668 svgDom->containerSize().height()) );
664 return recorder.finishRecordingAsPicture(); 669 return recorder.finishRecordingAsPicture();
665 } 670 }
666 671
667 Benchmark* next() { 672 Benchmark* next() {
668 SkAutoTDelete<Benchmark> bench; 673 SkAutoTDelete<Benchmark> bench;
669 do { 674 do {
670 bench.reset(this->rawNext()); 675 bench.reset(this->rawNext());
671 if (!bench) { 676 if (!bench) {
672 return nullptr; 677 return nullptr;
673 } 678 }
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 1337
1333 return 0; 1338 return 0;
1334 } 1339 }
1335 1340
1336 #if !defined SK_BUILD_FOR_IOS 1341 #if !defined SK_BUILD_FOR_IOS
1337 int main(int argc, char** argv) { 1342 int main(int argc, char** argv) {
1338 SkCommandLineFlags::Parse(argc, argv); 1343 SkCommandLineFlags::Parse(argc, argv);
1339 return nanobench_main(); 1344 return nanobench_main();
1340 } 1345 }
1341 #endif 1346 #endif
OLDNEW
« no previous file with comments | « no previous file | dm/DMSrcSink.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698