| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkImage.h" | 10 #include "SkImage.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 const SkRect bounds = SkRect::MakeXYWH(100, 100, 100, 100); | 121 const SkRect bounds = SkRect::MakeXYWH(100, 100, 100, 100); |
| 122 SkPictureRecorder recorder; | 122 SkPictureRecorder recorder; |
| 123 draw_something(recorder.beginRecording(bounds), bounds); | 123 draw_something(recorder.beginRecording(bounds), bounds); |
| 124 fPicture.reset(recorder.endRecording()); | 124 fPicture.reset(recorder.endRecording()); |
| 125 | 125 |
| 126 // extract enough just for the oval. | 126 // extract enough just for the oval. |
| 127 const SkISize size = SkISize::Make(100, 100); | 127 const SkISize size = SkISize::Make(100, 100); |
| 128 | 128 |
| 129 SkMatrix matrix; | 129 SkMatrix matrix; |
| 130 matrix.setTranslate(-100, -100); | 130 matrix.setTranslate(-100, -100); |
| 131 fCache.reset(new SkImageCacherator(SkImageGenerator::NewFromPicture(size
, | 131 auto gen = SkImageGenerator::NewFromPicture(size, fPicture, &matrix, nul
lptr); |
| 132 fPic
ture, | 132 fCache.reset(SkImageCacherator::NewFromGenerator(gen)); |
| 133 &mat
rix, | |
| 134 null
ptr))); | |
| 135 } | 133 } |
| 136 | 134 |
| 137 void drawSet(SkCanvas* canvas) const { | 135 void drawSet(SkCanvas* canvas) const { |
| 138 SkMatrix matrix = SkMatrix::MakeTrans(-100, -100); | 136 SkMatrix matrix = SkMatrix::MakeTrans(-100, -100); |
| 139 canvas->drawPicture(fPicture, &matrix, nullptr); | 137 canvas->drawPicture(fPicture, &matrix, nullptr); |
| 140 | 138 |
| 141 { | 139 { |
| 142 SkBitmap bitmap; | 140 SkBitmap bitmap; |
| 143 fCache->lockAsBitmap(&bitmap); | 141 fCache->lockAsBitmap(&bitmap); |
| 144 canvas->drawBitmap(bitmap, 150, 0); | 142 canvas->drawBitmap(bitmap, 150, 0); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 canvas->restore(); | 175 canvas->restore(); |
| 178 } | 176 } |
| 179 | 177 |
| 180 private: | 178 private: |
| 181 typedef skiagm::GM INHERITED; | 179 typedef skiagm::GM INHERITED; |
| 182 }; | 180 }; |
| 183 DEF_GM( return new ImageCacheratorGM; ) | 181 DEF_GM( return new ImageCacheratorGM; ) |
| 184 | 182 |
| 185 | 183 |
| 186 | 184 |
| OLD | NEW |