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 "SkImageGenerator.h" | 8 #include "SkImageGenerator.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkMatrix.h" | 10 #include "SkMatrix.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 typedef SkImageGenerator INHERITED; | 35 typedef SkImageGenerator INHERITED; |
36 }; | 36 }; |
37 | 37 |
38 SkImageGenerator* SkPictureImageGenerator::Create(const SkISize& size, const SkP
icture* picture, | 38 SkImageGenerator* SkPictureImageGenerator::Create(const SkISize& size, const SkP
icture* picture, |
39 const SkMatrix* matrix, const SkPaint* paint) { | 39 const SkMatrix* matrix, const SkPaint* paint) { |
40 if (!picture || size.isEmpty()) { | 40 if (!picture || size.isEmpty()) { |
41 return nullptr; | 41 return nullptr; |
42 } | 42 } |
43 | 43 |
44 return SkNEW_ARGS(SkPictureImageGenerator, (size, picture, matrix, paint)); | 44 return new SkPictureImageGenerator(size, picture, matrix, paint); |
45 } | 45 } |
46 | 46 |
47 SkPictureImageGenerator::SkPictureImageGenerator(const SkISize& size, const SkPi
cture* picture, | 47 SkPictureImageGenerator::SkPictureImageGenerator(const SkISize& size, const SkPi
cture* picture, |
48 const SkMatrix* matrix, const S
kPaint* paint) | 48 const SkMatrix* matrix, const S
kPaint* paint) |
49 : INHERITED(SkImageInfo::MakeN32Premul(size)) | 49 : INHERITED(SkImageInfo::MakeN32Premul(size)) |
50 , fPicture(SkRef(picture)) { | 50 , fPicture(SkRef(picture)) { |
51 | 51 |
52 if (matrix) { | 52 if (matrix) { |
53 fMatrix = *matrix; | 53 fMatrix = *matrix; |
54 } else { | 54 } else { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
110 surface->getCanvas()->clear(0); // does NewRenderTarget promise to do this f
or us? | 110 surface->getCanvas()->clear(0); // does NewRenderTarget promise to do this f
or us? |
111 surface->getCanvas()->drawPicture(fPicture, &matrix, fPaint.getMaybeNull()); | 111 surface->getCanvas()->drawPicture(fPicture, &matrix, fPaint.getMaybeNull()); |
112 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); | 112 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); |
113 if (!image.get()) { | 113 if (!image.get()) { |
114 return nullptr; | 114 return nullptr; |
115 } | 115 } |
116 return SkSafeRef(image->getTexture()); | 116 return SkSafeRef(image->getTexture()); |
117 } | 117 } |
118 #endif | 118 #endif |
OLD | NEW |