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

Side by Side Diff: samplecode/SampleSVGFile.cpp

Issue 2164193002: Initial SVG model (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: warning fix Created 4 years, 4 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 | « samplecode/SampleApp.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SampleCode.h"
9 #include "SkCanvas.h"
10 #include "SkDOM.h"
11 #include "SkStream.h"
12 #include "SkSVGDOM.h"
13 #include "SkView.h"
14
15 namespace {
16
17 class SVGFileView : public SampleView {
18 public:
19 SVGFileView(const char path[]) {
20 SkFILEStream svgStream(path);
21 if (!svgStream.isValid()) {
22 SkDebugf("file not found: \"path\"\n", path);
23 return;
24 }
25
26 SkDOM xmlDom;
27 if (!xmlDom.build(svgStream)) {
28 SkDebugf("XML parsing failed: \"path\"\n", path);
29 return;
30 }
31
32 fDom = SkSVGDOM::MakeFromDOM(xmlDom, SkSize::Make(this->width(), this->h eight()));
33 }
34
35 virtual ~SVGFileView() = default;
36
37 protected:
38 void onDrawContent(SkCanvas* canvas) override {
39 if (fDom) {
40 fDom->render(canvas);
41 }
42 }
43
44 void onSizeChange() override {
45 if (fDom) {
46 fDom->setContainerSize(SkSize::Make(this->width(), this->height()));
47 }
48
49 this->INHERITED::onSizeChange();
50 }
51
52 private:
53 sk_sp<SkSVGDOM> fDom;
54
55 typedef SampleView INHERITED;
56 };
57
58 } // anonymous namespace
59
60 SampleView* CreateSampleSVGFileView(const char filename[]);
61 SampleView* CreateSampleSVGFileView(const char filename[]) {
62 return new SVGFileView(filename);
63 }
OLDNEW
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698