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

Side by Side Diff: gm/optimizations.cpp

Issue 492023002: Install a hook to swap between SkPicture backends with a single define. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comment Created 6 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 | « dm/DMUtil.cpp ('k') | gyp/common_conditions.gypi » ('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 2013 Google Inc. 2 * Copyright 2013 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 "gm.h" 8 #include "gm.h"
9 #include "SkDebugCanvas.h" 9 #include "SkDebugCanvas.h"
10 #include "SkPictureFlat.h" 10 #include "SkPictureFlat.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 (*postOptPattern)[1] = SAVE; 75 (*postOptPattern)[1] = SAVE;
76 (*postOptPattern)[2] = SAVE_LAYER; 76 (*postOptPattern)[2] = SAVE_LAYER;
77 (*postOptPattern)[3] = DRAW_BITMAP_RECT_TO_RECT; 77 (*postOptPattern)[3] = DRAW_BITMAP_RECT_TO_RECT;
78 (*postOptPattern)[4] = RESTORE; 78 (*postOptPattern)[4] = RESTORE;
79 (*postOptPattern)[5] = RESTORE; 79 (*postOptPattern)[5] = RESTORE;
80 (*postOptPattern)[6] = RESTORE; 80 (*postOptPattern)[6] = RESTORE;
81 } 81 }
82 82
83 SkPictureRecorder recorder; 83 SkPictureRecorder recorder;
84 84
85 SkCanvas* canvas = recorder.beginRecording(100, 100, NULL, 0); 85 SkCanvas* canvas = recorder.DEPRECATED_beginRecording(100, 100, NULL, 0);
86 // have to disable the optimizations while generating the picture 86 // have to disable the optimizations while generating the picture
87 recorder.internalOnly_EnableOpts(false); 87 recorder.internalOnly_EnableOpts(false);
88 88
89 SkPaint saveLayerPaint; 89 SkPaint saveLayerPaint;
90 saveLayerPaint.setColor(0xCC000000); 90 saveLayerPaint.setColor(0xCC000000);
91 91
92 // saveLayer's 'bounds' parameter must be NULL for this optimization 92 // saveLayer's 'bounds' parameter must be NULL for this optimization
93 if (saveLayerHasPaint) { 93 if (saveLayerHasPaint) {
94 canvas->saveLayer(NULL, &saveLayerPaint); 94 canvas->saveLayer(NULL, &saveLayerPaint);
95 } else { 95 } else {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 (*postOptPattern)[4] = CLIP_RECT; 209 (*postOptPattern)[4] = CLIP_RECT;
210 (*postOptPattern)[5] = DRAW_BITMAP_RECT_TO_RECT; 210 (*postOptPattern)[5] = DRAW_BITMAP_RECT_TO_RECT;
211 (*postOptPattern)[6] = RESTORE; 211 (*postOptPattern)[6] = RESTORE;
212 (*postOptPattern)[7] = RESTORE; 212 (*postOptPattern)[7] = RESTORE;
213 (*postOptPattern)[8] = RESTORE; 213 (*postOptPattern)[8] = RESTORE;
214 (*postOptPattern)[9] = RESTORE; 214 (*postOptPattern)[9] = RESTORE;
215 } 215 }
216 216
217 SkPictureRecorder recorder; 217 SkPictureRecorder recorder;
218 218
219 SkCanvas* canvas = recorder.beginRecording(100, 100, NULL, 0); 219 SkCanvas* canvas = recorder.DEPRECATED_beginRecording(100, 100, NULL, 0);
220 // have to disable the optimizations while generating the picture 220 // have to disable the optimizations while generating the picture
221 recorder.internalOnly_EnableOpts(false); 221 recorder.internalOnly_EnableOpts(false);
222 222
223 SkPaint saveLayerPaint; 223 SkPaint saveLayerPaint;
224 saveLayerPaint.setColor(0xCC000000); 224 saveLayerPaint.setColor(0xCC000000);
225 225
226 // saveLayer's 'bounds' parameter must be NULL for this optimization 226 // saveLayer's 'bounds' parameter must be NULL for this optimization
227 if (saveLayerHasPaint) { 227 if (saveLayerHasPaint) {
228 canvas->saveLayer(NULL, &saveLayerPaint); 228 canvas->saveLayer(NULL, &saveLayerPaint);
229 } else { 229 } else {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 352
353 canvas->save(); 353 canvas->save();
354 canvas->translate(SkIntToScalar(xPos), SkIntToScalar(yPos)); 354 canvas->translate(SkIntToScalar(xPos), SkIntToScalar(yPos));
355 pre->draw(canvas); 355 pre->draw(canvas);
356 xPos += pre->width(); 356 xPos += pre->width();
357 canvas->restore(); 357 canvas->restore();
358 358
359 // re-render the 'pre' picture and thus 'apply' the optimization 359 // re-render the 'pre' picture and thus 'apply' the optimization
360 SkPictureRecorder recorder; 360 SkPictureRecorder recorder;
361 361
362 SkCanvas* recordCanvas = recorder.beginRecording(pre->width(), pre-> height(), NULL, 0); 362 SkCanvas* recordCanvas =
363 recorder.DEPRECATED_beginRecording(pre->width(), pre->height(), NULL, 0);
363 364
364 pre->draw(recordCanvas); 365 pre->draw(recordCanvas);
365 366
366 SkAutoTUnref<SkPicture> post(recorder.endRecording()); 367 SkAutoTUnref<SkPicture> post(recorder.endRecording());
367 368
368 if (!(check_pattern(*post, postPattern))) { 369 if (!(check_pattern(*post, postPattern))) {
369 WARN("Post optimization pattern mismatch"); 370 WARN("Post optimization pattern mismatch");
370 SkASSERT(0); 371 SkASSERT(0);
371 } 372 }
372 373
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 } 409 }
409 410
410 SkBitmap fCheckerboard; 411 SkBitmap fCheckerboard;
411 412
412 typedef skiagm::GM INHERITED; 413 typedef skiagm::GM INHERITED;
413 }; 414 };
414 415
415 ////////////////////////////////////////////////////////////////////////////// 416 //////////////////////////////////////////////////////////////////////////////
416 417
417 DEF_GM( return new OptimizationsGM; ) 418 DEF_GM( return new OptimizationsGM; )
OLDNEW
« no previous file with comments | « dm/DMUtil.cpp ('k') | gyp/common_conditions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698