Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: src/core/SkRecorder.cpp

Issue 2185563003: turn bitmaps into images during recording (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: exlucde serialize bleed, remove ImmutableBitmap for records Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | src/core/SkRecords.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkImage.h"
10 #include "SkPatchUtils.h" 11 #include "SkPatchUtils.h"
11 #include "SkPicture.h" 12 #include "SkPicture.h"
12 #include "SkPictureUtils.h" 13 #include "SkPictureUtils.h"
13 #include "SkRecorder.h" 14 #include "SkRecorder.h"
14 #include "SkSurface.h" 15 #include "SkSurface.h"
15 16
16 //#define WRAP_BITMAP_AS_IMAGE
17
18 SkDrawableList::~SkDrawableList() { 17 SkDrawableList::~SkDrawableList() {
19 fArray.unrefAll(); 18 fArray.unrefAll();
20 } 19 }
21 20
22 SkBigPicture::SnapshotArray* SkDrawableList::newDrawableSnapshot() { 21 SkBigPicture::SnapshotArray* SkDrawableList::newDrawableSnapshot() {
23 const int count = fArray.count(); 22 const int count = fArray.count();
24 if (0 == count) { 23 if (0 == count) {
25 return nullptr; 24 return nullptr;
26 } 25 }
27 SkAutoTMalloc<const SkPicture*> pics(count); 26 SkAutoTMalloc<const SkPicture*> pics(count);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 172
174 void SkRecorder::onDrawPath(const SkPath& path, const SkPaint& paint) { 173 void SkRecorder::onDrawPath(const SkPath& path, const SkPaint& paint) {
175 TRY_MINIRECORDER(drawPath, path, paint); 174 TRY_MINIRECORDER(drawPath, path, paint);
176 APPEND(DrawPath, paint, path); 175 APPEND(DrawPath, paint, path);
177 } 176 }
178 177
179 void SkRecorder::onDrawBitmap(const SkBitmap& bitmap, 178 void SkRecorder::onDrawBitmap(const SkBitmap& bitmap,
180 SkScalar left, 179 SkScalar left,
181 SkScalar top, 180 SkScalar top,
182 const SkPaint* paint) { 181 const SkPaint* paint) {
183 #ifdef WRAP_BITMAP_AS_IMAGE 182 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
184 SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(bitmap));
185 if (image) { 183 if (image) {
186 this->onDrawImage(image, left, top, paint); 184 this->onDrawImage(image.get(), left, top, paint);
187 } 185 }
188 #else
189 APPEND(DrawBitmap, this->copy(paint), bitmap, left, top);
190 #endif
191 } 186 }
192 187
193 void SkRecorder::onDrawBitmapRect(const SkBitmap& bitmap, 188 void SkRecorder::onDrawBitmapRect(const SkBitmap& bitmap,
194 const SkRect* src, 189 const SkRect* src,
195 const SkRect& dst, 190 const SkRect& dst,
196 const SkPaint* paint, 191 const SkPaint* paint,
197 SrcRectConstraint constraint) { 192 SrcRectConstraint constraint) {
198 #ifdef WRAP_BITMAP_AS_IMAGE 193 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
199 // TODO: need a way to support the flags for images...
200 SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(bitmap));
201 if (image) { 194 if (image) {
202 this->onDrawImageRect(image, src, dst, paint); 195 this->onDrawImageRect(image.get(), src, dst, paint, constraint);
203 } 196 }
204 #else
205 if (kFast_SrcRectConstraint == constraint) {
206 APPEND(DrawBitmapRectFast, this->copy(paint), bitmap, this->copy(src), d st);
207 return;
208 }
209 SkASSERT(kStrict_SrcRectConstraint == constraint);
210 APPEND(DrawBitmapRect, this->copy(paint), bitmap, this->copy(src), dst);
211 #endif
212 } 197 }
213 198
214 void SkRecorder::onDrawBitmapNine(const SkBitmap& bitmap, 199 void SkRecorder::onDrawBitmapNine(const SkBitmap& bitmap,
215 const SkIRect& center, 200 const SkIRect& center,
216 const SkRect& dst, 201 const SkRect& dst,
217 const SkPaint* paint) { 202 const SkPaint* paint) {
218 #ifdef WRAP_BITMAP_AS_IMAGE 203 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
219 SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(bitmap));
220 if (image) { 204 if (image) {
221 this->onDrawImageNine(image, center, dst, paint); 205 this->onDrawImageNine(image.get(), center, dst, paint);
222 } 206 }
223 #else
224 APPEND(DrawBitmapNine, this->copy(paint), bitmap, center, dst);
225 #endif
226 } 207 }
227 208
228 void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top, 209 void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
229 const SkPaint* paint) { 210 const SkPaint* paint) {
230 APPEND(DrawImage, this->copy(paint), image, left, top); 211 APPEND(DrawImage, this->copy(paint), image, left, top);
231 } 212 }
232 213
233 void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst, 214 void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
234 const SkPaint* paint, SrcRectConstraint constra int) { 215 const SkPaint* paint, SrcRectConstraint constra int) {
235 APPEND(DrawImageRect, this->copy(paint), image, this->copy(src), dst, constr aint); 216 APPEND(DrawImageRect, this->copy(paint), image, this->copy(src), dst, constr aint);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 388 }
408 389
409 void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { 390 void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
410 INHERITED(onClipRegion, deviceRgn, op); 391 INHERITED(onClipRegion, deviceRgn, op);
411 APPEND(ClipRegion, this->devBounds(), deviceRgn, op); 392 APPEND(ClipRegion, this->devBounds(), deviceRgn, op);
412 } 393 }
413 394
414 sk_sp<SkSurface> SkRecorder::onNewSurface(const SkImageInfo&, const SkSurfacePro ps&) { 395 sk_sp<SkSurface> SkRecorder::onNewSurface(const SkImageInfo&, const SkSurfacePro ps&) {
415 return nullptr; 396 return nullptr;
416 } 397 }
OLDNEW
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | src/core/SkRecords.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698