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

Side by Side Diff: samplecode/SamplePictFile.cpp

Issue 313613004: Alter SkCanvas::drawPicture (devirtualize, take const SkPicture, take pointer) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add staging entry point for Chromium and Android Created 6 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkDumpCanvas.h" 9 #include "SkDumpCanvas.h"
10 #include "SkView.h" 10 #include "SkView.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 virtual void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { 95 virtual void onDrawContent(SkCanvas* canvas) SK_OVERRIDE {
96 SkASSERT(static_cast<int>(fBBox) < kBBoxTypeCount); 96 SkASSERT(static_cast<int>(fBBox) < kBBoxTypeCount);
97 SkPicture** picture = fPictures + fBBox; 97 SkPicture** picture = fPictures + fBBox;
98 98
99 if (!*picture) { 99 if (!*picture) {
100 *picture = LoadPicture(fFilename.c_str(), fBBox); 100 *picture = LoadPicture(fFilename.c_str(), fBBox);
101 } 101 }
102 if (*picture) { 102 if (*picture) {
103 canvas->drawPicture(**picture); 103 canvas->drawPicture(*picture);
104 } 104 }
105 } 105 }
106 106
107 private: 107 private:
108 enum BBoxType { 108 enum BBoxType {
109 kNo_BBoxType, 109 kNo_BBoxType,
110 kQuadTree_BBoxType, 110 kQuadTree_BBoxType,
111 kRTree_BBoxType, 111 kRTree_BBoxType,
112 kTileGrid_BBoxType, 112 kTileGrid_BBoxType,
113 113
(...skipping 19 matching lines...) Expand all
133 } else { 133 } else {
134 SkFILEStream stream(path); 134 SkFILEStream stream(path);
135 if (stream.isValid()) { 135 if (stream.isValid()) {
136 pic.reset(SkPicture::CreateFromStream(&stream)); 136 pic.reset(SkPicture::CreateFromStream(&stream));
137 } else { 137 } else {
138 SkDebugf("coun't load picture at \"path\"\n", path); 138 SkDebugf("coun't load picture at \"path\"\n", path);
139 } 139 }
140 140
141 if (false) { 141 if (false) {
142 SkSurface* surf = SkSurface::NewRasterPMColor(pic->width(), pic- >height()); 142 SkSurface* surf = SkSurface::NewRasterPMColor(pic->width(), pic- >height());
143 surf->getCanvas()->drawPicture(*pic); 143 surf->getCanvas()->drawPicture(pic);
144 surf->unref(); 144 surf->unref();
145 } 145 }
146 if (false) { // re-record 146 if (false) { // re-record
147 SkPictureRecorder recorder; 147 SkPictureRecorder recorder;
148 pic->draw(recorder.beginRecording(pic->width(), pic->height(), N ULL, 0)); 148 pic->draw(recorder.beginRecording(pic->width(), pic->height(), N ULL, 0));
149 SkAutoTUnref<SkPicture> p2(recorder.endRecording()); 149 SkAutoTUnref<SkPicture> p2(recorder.endRecording());
150 150
151 SkString path2(path); 151 SkString path2(path);
152 path2.append(".new.skp"); 152 path2.append(".new.skp");
153 SkFILEWStream writer(path2.c_str()); 153 SkFILEWStream writer(path2.c_str());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 SampleView* CreateSamplePictFileView(const char filename[]) { 195 SampleView* CreateSamplePictFileView(const char filename[]) {
196 return new PictFileView(filename); 196 return new PictFileView(filename);
197 } 197 }
198 198
199 ////////////////////////////////////////////////////////////////////////////// 199 //////////////////////////////////////////////////////////////////////////////
200 200
201 #if 0 201 #if 0
202 static SkView* MyFactory() { return new PictFileView; } 202 static SkView* MyFactory() { return new PictFileView; }
203 static SkViewRegister reg(MyFactory); 203 static SkViewRegister reg(MyFactory);
204 #endif 204 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698