Chromium Code Reviews| 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 SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(bitmap)); | |
| 192 if (image) { | |
| 193 this->onDrawImageRect(image, src, dst, paint); | |
| 194 } | |
| 195 #else | |
| 181 TRY_MINIRECORDER(drawBitmapRectToRect, bitmap, src, dst, paint, flags); | 196 TRY_MINIRECORDER(drawBitmapRectToRect, bitmap, src, dst, paint, flags); |
|
robertphillips
2015/07/06 20:43:47
What happened to this code?
reed2
2015/07/07 01:18:03
Twas lost in a manual merge. Restored.
|
mtklein
2015/07/06 21:02:27
I support this approach both as a hack and a long
reed2
2015/07/07 01:18:03
Gotcha. Yes, this is just a testing-experiment for
|
| 182 if (kBleed_DrawBitmapRectFlag == flags) { | 197 #endif |
| 183 APPEND(DrawBitmapRectToRectBleed, | |
| 184 this->copy(paint), bitmap, this->copy(src), dst); | |
| 185 return; | |
| 186 } | |
| 187 SkASSERT(kNone_DrawBitmapRectFlag == flags); | |
| 188 APPEND(DrawBitmapRectToRect, | |
| 189 this->copy(paint), bitmap, this->copy(src), dst); | |
| 190 } | 198 } |
| 191 | 199 |
| 192 void SkRecorder::onDrawBitmapNine(const SkBitmap& bitmap, | 200 void SkRecorder::onDrawBitmapNine(const SkBitmap& bitmap, |
| 193 const SkIRect& center, | 201 const SkIRect& center, |
| 194 const SkRect& dst, | 202 const SkRect& dst, |
| 195 const SkPaint* paint) { | 203 const SkPaint* paint) { |
| 204 #ifdef WRAP_BITMAP_AS_IMAGE | |
| 205 SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(bitmap)); | |
| 206 if (image) { | |
| 207 this->onDrawImageNine(image, center, dst, paint); | |
| 208 } | |
| 209 #else | |
| 196 APPEND(DrawBitmapNine, this->copy(paint), bitmap, center, dst); | 210 APPEND(DrawBitmapNine, this->copy(paint), bitmap, center, dst); |
| 211 #endif | |
| 197 } | 212 } |
| 198 | 213 |
| 199 void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top, | 214 void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top, |
| 200 const SkPaint* paint) { | 215 const SkPaint* paint) { |
| 201 APPEND(DrawImage, this->copy(paint), image, left, top); | 216 APPEND(DrawImage, this->copy(paint), image, left, top); |
| 202 } | 217 } |
| 203 | 218 |
| 204 void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, | 219 void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, |
| 205 const SkRect& dst, | 220 const SkRect& dst, |
| 206 const SkPaint* paint) { | 221 const SkPaint* paint) { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 INHERITED(onClipPath, path, op, edgeStyle); | 367 INHERITED(onClipPath, path, op, edgeStyle); |
| 353 SkRecords::RegionOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle); | 368 SkRecords::RegionOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle); |
| 354 APPEND(ClipPath, this->devBounds(), path, opAA); | 369 APPEND(ClipPath, this->devBounds(), path, opAA); |
| 355 } | 370 } |
| 356 | 371 |
| 357 void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { | 372 void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { |
| 358 INHERITED(onClipRegion, deviceRgn, op); | 373 INHERITED(onClipRegion, deviceRgn, op); |
| 359 APPEND(ClipRegion, this->devBounds(), deviceRgn, op); | 374 APPEND(ClipRegion, this->devBounds(), deviceRgn, op); |
| 360 } | 375 } |
| 361 | 376 |
| OLD | NEW |