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

Unified Diff: samplecode/SampleSVGFile.cpp

Issue 2245993002: [SVGDom] Deferred SampleApp parsing (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleSVGFile.cpp
diff --git a/samplecode/SampleSVGFile.cpp b/samplecode/SampleSVGFile.cpp
index 12c91a95fe1055f878d79eba41e6fdb2b791f7ae..a4b5b34d7d0d52a6fbb28628d886b7e97d1de6e3 100644
--- a/samplecode/SampleSVGFile.cpp
+++ b/samplecode/SampleSVGFile.cpp
@@ -17,26 +17,27 @@ namespace {
class SVGFileView : public SampleView {
public:
- SVGFileView(const char path[])
- : fLabel(SkStringPrintf("[%s]", SkOSPath::Basename(path).c_str())) {
- SkFILEStream svgStream(path);
+ SVGFileView(const SkString& path)
+ : fPath(path), fLabel(SkStringPrintf("[%s]", SkOSPath::Basename(path.c_str()).c_str())) {}
+ virtual ~SVGFileView() = default;
+
+protected:
+ void onOnceBeforeDraw() override {
+ SkFILEStream svgStream(fPath.c_str());
if (!svgStream.isValid()) {
- SkDebugf("file not found: \"path\"\n", path);
+ SkDebugf("file not found: \"path\"\n", fPath.c_str());
return;
}
SkDOM xmlDom;
if (!xmlDom.build(svgStream)) {
- SkDebugf("XML parsing failed: \"path\"\n", path);
+ SkDebugf("XML parsing failed: \"path\"\n", fPath.c_str());
return;
}
fDom = SkSVGDOM::MakeFromDOM(xmlDom, SkSize::Make(this->width(), this->height()));
}
- virtual ~SVGFileView() = default;
-
-protected:
void onDrawContent(SkCanvas* canvas) override {
if (fDom) {
fDom->render(canvas);
@@ -61,6 +62,7 @@ protected:
}
private:
sk_sp<SkSVGDOM> fDom;
+ SkString fPath;
SkString fLabel;
typedef SampleView INHERITED;
@@ -68,7 +70,7 @@ private:
} // anonymous namespace
-SampleView* CreateSampleSVGFileView(const char filename[]);
-SampleView* CreateSampleSVGFileView(const char filename[]) {
+SampleView* CreateSampleSVGFileView(const SkString& filename);
+SampleView* CreateSampleSVGFileView(const SkString& filename) {
return new SVGFileView(filename);
}
« 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