| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 | 9 |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 class PictureShaderGM : public skiagm::GM { | 25 class PictureShaderGM : public skiagm::GM { |
| 26 public: | 26 public: |
| 27 PictureShaderGM(SkScalar tileSize, SkScalar sceneSize) | 27 PictureShaderGM(SkScalar tileSize, SkScalar sceneSize) |
| 28 : fTileSize(tileSize) | 28 : fTileSize(tileSize) |
| 29 , fSceneSize(sceneSize) { | 29 , fSceneSize(sceneSize) { |
| 30 | 30 |
| 31 // Build the picture. | 31 // Build the picture. |
| 32 SkPictureRecorder recorder; | 32 SkPictureRecorder recorder; |
| 33 SkCanvas* pictureCanvas = recorder.beginRecording(SkScalarRoundToInt(til
eSize), | 33 SkCanvas* pictureCanvas = recorder.beginRecording(tileSize, tileSize, NU
LL, 0); |
| 34 SkScalarRoundToInt(til
eSize), | |
| 35 NULL, 0); | |
| 36 this->drawTile(pictureCanvas); | 34 this->drawTile(pictureCanvas); |
| 37 fPicture.reset(recorder.endRecording()); | 35 fPicture.reset(recorder.endRecording()); |
| 38 | 36 |
| 39 // Build a reference bitmap. | 37 // Build a reference bitmap. |
| 40 fBitmap.allocN32Pixels(SkScalarRoundToInt(tileSize), SkScalarRoundToInt(
tileSize)); | 38 fBitmap.allocN32Pixels(SkScalarCeilToInt(tileSize), SkScalarCeilToInt(ti
leSize)); |
| 41 fBitmap.eraseColor(SK_ColorTRANSPARENT); | 39 fBitmap.eraseColor(SK_ColorTRANSPARENT); |
| 42 SkCanvas bitmapCanvas(fBitmap); | 40 SkCanvas bitmapCanvas(fBitmap); |
| 43 this->drawTile(&bitmapCanvas); | 41 this->drawTile(&bitmapCanvas); |
| 44 } | 42 } |
| 45 | 43 |
| 46 protected: | 44 protected: |
| 47 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 45 virtual uint32_t onGetFlags() const SK_OVERRIDE { |
| 48 return kSkipTiled_Flag; | 46 return kSkipTiled_Flag; |
| 49 } | 47 } |
| 50 | 48 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 SkScalar fTileSize; | 154 SkScalar fTileSize; |
| 157 SkScalar fSceneSize; | 155 SkScalar fSceneSize; |
| 158 | 156 |
| 159 SkAutoTUnref<SkPicture> fPicture; | 157 SkAutoTUnref<SkPicture> fPicture; |
| 160 SkBitmap fBitmap; | 158 SkBitmap fBitmap; |
| 161 | 159 |
| 162 typedef GM INHERITED; | 160 typedef GM INHERITED; |
| 163 }; | 161 }; |
| 164 | 162 |
| 165 DEF_GM( return SkNEW_ARGS(PictureShaderGM, (50, 100)); ) | 163 DEF_GM( return SkNEW_ARGS(PictureShaderGM, (50, 100)); ) |
| OLD | NEW |