OLD | NEW |
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 (*postOptPattern)[1] = SAVE; | 74 (*postOptPattern)[1] = SAVE; |
75 (*postOptPattern)[2] = SAVE_LAYER; | 75 (*postOptPattern)[2] = SAVE_LAYER; |
76 (*postOptPattern)[3] = DRAW_BITMAP_RECT_TO_RECT; | 76 (*postOptPattern)[3] = DRAW_BITMAP_RECT_TO_RECT; |
77 (*postOptPattern)[4] = RESTORE; | 77 (*postOptPattern)[4] = RESTORE; |
78 (*postOptPattern)[5] = RESTORE; | 78 (*postOptPattern)[5] = RESTORE; |
79 (*postOptPattern)[6] = RESTORE; | 79 (*postOptPattern)[6] = RESTORE; |
80 } | 80 } |
81 | 81 |
82 SkPictureRecorder recorder; | 82 SkPictureRecorder recorder; |
83 | 83 |
84 SkCanvas* canvas = recorder.beginRecording(100, 100); | 84 SkCanvas* canvas = recorder.beginRecording(100, 100, NULL, 0); |
85 // have to disable the optimizations while generating the picture | 85 // have to disable the optimizations while generating the picture |
86 recorder.internalOnly_EnableOpts(false); | 86 recorder.internalOnly_EnableOpts(false); |
87 | 87 |
88 SkPaint saveLayerPaint; | 88 SkPaint saveLayerPaint; |
89 saveLayerPaint.setColor(0xCC000000); | 89 saveLayerPaint.setColor(0xCC000000); |
90 | 90 |
91 // saveLayer's 'bounds' parameter must be NULL for this optimization | 91 // saveLayer's 'bounds' parameter must be NULL for this optimization |
92 if (saveLayerHasPaint) { | 92 if (saveLayerHasPaint) { |
93 canvas->saveLayer(NULL, &saveLayerPaint); | 93 canvas->saveLayer(NULL, &saveLayerPaint); |
94 } else { | 94 } else { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 (*postOptPattern)[4] = CLIP_RECT; | 208 (*postOptPattern)[4] = CLIP_RECT; |
209 (*postOptPattern)[5] = DRAW_BITMAP_RECT_TO_RECT; | 209 (*postOptPattern)[5] = DRAW_BITMAP_RECT_TO_RECT; |
210 (*postOptPattern)[6] = RESTORE; | 210 (*postOptPattern)[6] = RESTORE; |
211 (*postOptPattern)[7] = RESTORE; | 211 (*postOptPattern)[7] = RESTORE; |
212 (*postOptPattern)[8] = RESTORE; | 212 (*postOptPattern)[8] = RESTORE; |
213 (*postOptPattern)[9] = RESTORE; | 213 (*postOptPattern)[9] = RESTORE; |
214 } | 214 } |
215 | 215 |
216 SkPictureRecorder recorder; | 216 SkPictureRecorder recorder; |
217 | 217 |
218 SkCanvas* canvas = recorder.beginRecording(100, 100); | 218 SkCanvas* canvas = recorder.beginRecording(100, 100, NULL, 0); |
219 // have to disable the optimizations while generating the picture | 219 // have to disable the optimizations while generating the picture |
220 recorder.internalOnly_EnableOpts(false); | 220 recorder.internalOnly_EnableOpts(false); |
221 | 221 |
222 SkPaint saveLayerPaint; | 222 SkPaint saveLayerPaint; |
223 saveLayerPaint.setColor(0xCC000000); | 223 saveLayerPaint.setColor(0xCC000000); |
224 | 224 |
225 // saveLayer's 'bounds' parameter must be NULL for this optimization | 225 // saveLayer's 'bounds' parameter must be NULL for this optimization |
226 if (saveLayerHasPaint) { | 226 if (saveLayerHasPaint) { |
227 canvas->saveLayer(NULL, &saveLayerPaint); | 227 canvas->saveLayer(NULL, &saveLayerPaint); |
228 } else { | 228 } else { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 351 |
352 canvas->save(); | 352 canvas->save(); |
353 canvas->translate(SkIntToScalar(xPos), SkIntToScalar(yPos)); | 353 canvas->translate(SkIntToScalar(xPos), SkIntToScalar(yPos)); |
354 pre->draw(canvas); | 354 pre->draw(canvas); |
355 xPos += pre->width(); | 355 xPos += pre->width(); |
356 canvas->restore(); | 356 canvas->restore(); |
357 | 357 |
358 // re-render the 'pre' picture and thus 'apply' the optimization | 358 // re-render the 'pre' picture and thus 'apply' the optimization |
359 SkPictureRecorder recorder; | 359 SkPictureRecorder recorder; |
360 | 360 |
361 SkCanvas* recordCanvas = recorder.beginRecording(pre->width(), pre->
height()); | 361 SkCanvas* recordCanvas = recorder.beginRecording(pre->width(), pre->
height(), NULL, 0); |
362 | 362 |
363 pre->draw(recordCanvas); | 363 pre->draw(recordCanvas); |
364 | 364 |
365 SkAutoTUnref<SkPicture> post(recorder.endRecording()); | 365 SkAutoTUnref<SkPicture> post(recorder.endRecording()); |
366 | 366 |
367 if (!(check_pattern(*post, postPattern))) { | 367 if (!(check_pattern(*post, postPattern))) { |
368 WARN("Post optimization pattern mismatch"); | 368 WARN("Post optimization pattern mismatch"); |
369 SkASSERT(0); | 369 SkASSERT(0); |
370 } | 370 } |
371 | 371 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 } | 407 } |
408 | 408 |
409 SkBitmap fCheckerboard; | 409 SkBitmap fCheckerboard; |
410 | 410 |
411 typedef skiagm::GM INHERITED; | 411 typedef skiagm::GM INHERITED; |
412 }; | 412 }; |
413 | 413 |
414 ////////////////////////////////////////////////////////////////////////////// | 414 ////////////////////////////////////////////////////////////////////////////// |
415 | 415 |
416 DEF_GM( return new OptimizationsGM; ) | 416 DEF_GM( return new OptimizationsGM; ) |
OLD | NEW |