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 "SkBigPicture.h" | 8 #include "SkBigPicture.h" |
9 #include "SkCanvasPriv.h" | 9 #include "SkCanvasPriv.h" |
10 #include "SkPatchUtils.h" | 10 #include "SkPatchUtils.h" |
11 #include "SkPicture.h" | 11 #include "SkPicture.h" |
12 #include "SkPictureUtils.h" | 12 #include "SkPictureUtils.h" |
13 #include "SkRecorder.h" | 13 #include "SkRecorder.h" |
14 | 14 |
| 15 //#define WRAP_BITMAP_AS_IMAGE |
| 16 |
15 SkDrawableList::~SkDrawableList() { | 17 SkDrawableList::~SkDrawableList() { |
16 fArray.unrefAll(); | 18 fArray.unrefAll(); |
17 } | 19 } |
18 | 20 |
19 SkBigPicture::SnapshotArray* SkDrawableList::newDrawableSnapshot() { | 21 SkBigPicture::SnapshotArray* SkDrawableList::newDrawableSnapshot() { |
20 const int count = fArray.count(); | 22 const int count = fArray.count(); |
21 if (0 == count) { | 23 if (0 == count) { |
22 return NULL; | 24 return NULL; |
23 } | 25 } |
24 SkAutoTMalloc<const SkPicture*> pics(count); | 26 SkAutoTMalloc<const SkPicture*> pics(count); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 165 |
164 void SkRecorder::onDrawPath(const SkPath& path, const SkPaint& paint) { | 166 void SkRecorder::onDrawPath(const SkPath& path, const SkPaint& paint) { |
165 TRY_MINIRECORDER(drawPath, path, paint); | 167 TRY_MINIRECORDER(drawPath, path, paint); |
166 APPEND(DrawPath, paint, path); | 168 APPEND(DrawPath, paint, path); |
167 } | 169 } |
168 | 170 |
169 void SkRecorder::onDrawBitmap(const SkBitmap& bitmap, | 171 void SkRecorder::onDrawBitmap(const SkBitmap& bitmap, |
170 SkScalar left, | 172 SkScalar left, |
171 SkScalar top, | 173 SkScalar top, |
172 const SkPaint* paint) { | 174 const SkPaint* paint) { |
| 175 #ifdef WRAP_BITMAP_AS_IMAGE |
| 176 SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(bitmap)); |
| 177 if (image) { |
| 178 this->onDrawImage(image, left, top, paint); |
| 179 } |
| 180 #else |
173 APPEND(DrawBitmap, this->copy(paint), bitmap, left, top); | 181 APPEND(DrawBitmap, this->copy(paint), bitmap, left, top); |
| 182 #endif |
174 } | 183 } |
175 | 184 |
176 void SkRecorder::onDrawBitmapRect(const SkBitmap& bitmap, | 185 void SkRecorder::onDrawBitmapRect(const SkBitmap& bitmap, |
177 const SkRect* src, | 186 const SkRect* src, |
178 const SkRect& dst, | 187 const SkRect& dst, |
179 const SkPaint* paint, | 188 const SkPaint* paint, |
180 DrawBitmapRectFlags flags) { | 189 DrawBitmapRectFlags flags) { |
| 190 #ifdef WRAP_BITMAP_AS_IMAGE |
| 191 // TODO: need a way to support the flags for images... |
| 192 SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(bitmap)); |
| 193 if (image) { |
| 194 this->onDrawImageRect(image, src, dst, paint); |
| 195 } |
| 196 #else |
181 TRY_MINIRECORDER(drawBitmapRectToRect, bitmap, src, dst, paint, flags); | 197 TRY_MINIRECORDER(drawBitmapRectToRect, bitmap, src, dst, paint, flags); |
182 if (kBleed_DrawBitmapRectFlag == flags) { | 198 if (kBleed_DrawBitmapRectFlag == flags) { |
183 APPEND(DrawBitmapRectToRectBleed, | 199 APPEND(DrawBitmapRectToRectBleed, |
184 this->copy(paint), bitmap, this->copy(src), dst); | 200 this->copy(paint), bitmap, this->copy(src), dst); |
185 return; | 201 return; |
186 } | 202 } |
187 SkASSERT(kNone_DrawBitmapRectFlag == flags); | 203 SkASSERT(kNone_DrawBitmapRectFlag == flags); |
188 APPEND(DrawBitmapRectToRect, | 204 APPEND(DrawBitmapRectToRect, |
189 this->copy(paint), bitmap, this->copy(src), dst); | 205 this->copy(paint), bitmap, this->copy(src), dst); |
| 206 #endif |
190 } | 207 } |
191 | 208 |
192 void SkRecorder::onDrawBitmapNine(const SkBitmap& bitmap, | 209 void SkRecorder::onDrawBitmapNine(const SkBitmap& bitmap, |
193 const SkIRect& center, | 210 const SkIRect& center, |
194 const SkRect& dst, | 211 const SkRect& dst, |
195 const SkPaint* paint) { | 212 const SkPaint* paint) { |
| 213 #ifdef WRAP_BITMAP_AS_IMAGE |
| 214 SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(bitmap)); |
| 215 if (image) { |
| 216 this->onDrawImageNine(image, center, dst, paint); |
| 217 } |
| 218 #else |
196 APPEND(DrawBitmapNine, this->copy(paint), bitmap, center, dst); | 219 APPEND(DrawBitmapNine, this->copy(paint), bitmap, center, dst); |
| 220 #endif |
197 } | 221 } |
198 | 222 |
199 void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top, | 223 void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top, |
200 const SkPaint* paint) { | 224 const SkPaint* paint) { |
201 APPEND(DrawImage, this->copy(paint), image, left, top); | 225 APPEND(DrawImage, this->copy(paint), image, left, top); |
202 } | 226 } |
203 | 227 |
204 void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, | 228 void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, |
205 const SkRect& dst, | 229 const SkRect& dst, |
206 const SkPaint* paint) { | 230 const SkPaint* paint) { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 INHERITED(onClipPath, path, op, edgeStyle); | 376 INHERITED(onClipPath, path, op, edgeStyle); |
353 SkRecords::RegionOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle); | 377 SkRecords::RegionOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle); |
354 APPEND(ClipPath, this->devBounds(), path, opAA); | 378 APPEND(ClipPath, this->devBounds(), path, opAA); |
355 } | 379 } |
356 | 380 |
357 void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { | 381 void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { |
358 INHERITED(onClipRegion, deviceRgn, op); | 382 INHERITED(onClipRegion, deviceRgn, op); |
359 APPEND(ClipRegion, this->devBounds(), deviceRgn, op); | 383 APPEND(ClipRegion, this->devBounds(), deviceRgn, op); |
360 } | 384 } |
361 | 385 |
OLD | NEW |