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

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

Issue 2205273003: Add onDrawBitmapLattice(), avoid unnecessary bitmap->image copy (Closed) Base URL: https://skia.googlesource.com/skia.git@copypaste
Patch Set: Add support for SkLiteRecorder 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
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 "SkImage.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 void SkRecorder::onDrawBitmapNine(const SkBitmap& bitmap, 199 void SkRecorder::onDrawBitmapNine(const SkBitmap& bitmap,
200 const SkIRect& center, 200 const SkIRect& center,
201 const SkRect& dst, 201 const SkRect& dst,
202 const SkPaint* paint) { 202 const SkPaint* paint) {
203 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap); 203 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
204 if (image) { 204 if (image) {
205 this->onDrawImageNine(image.get(), center, dst, paint); 205 this->onDrawImageNine(image.get(), center, dst, paint);
206 } 206 }
207 } 207 }
208 208
209 void SkRecorder::onDrawBitmapLattice(const SkBitmap& bitmap, const Lattice& latt ice,
210 const SkRect& dst, const SkPaint* paint) {
211 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
212 this->onDrawImageLattice(image.get(), lattice, dst, paint);
213 }
214
209 void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top, 215 void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
210 const SkPaint* paint) { 216 const SkPaint* paint) {
211 APPEND(DrawImage, this->copy(paint), sk_ref_sp(image), left, top); 217 APPEND(DrawImage, this->copy(paint), sk_ref_sp(image), left, top);
212 } 218 }
213 219
214 void SkRecorder::onDrawImageLattice(const SkImage* image,
215 const Lattice& lattice,
216 const SkRect& dst,
217 const SkPaint* paint) {
218 APPEND(DrawImageLattice, this->copy(paint), sk_ref_sp(image),
219 lattice.fXCount, this->copy(lattice.fXDivs, lattice.fXCount),
220 lattice.fYCount, this->copy(lattice.fYDivs, lattice.fYCount), dst);
221 }
222
223
224 void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst, 220 void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
225 const SkPaint* paint, SrcRectConstraint constra int) { 221 const SkPaint* paint, SrcRectConstraint constra int) {
226 APPEND(DrawImageRect, this->copy(paint), sk_ref_sp(image), this->copy(src), dst, constraint); 222 APPEND(DrawImageRect, this->copy(paint), sk_ref_sp(image), this->copy(src), dst, constraint);
227 } 223 }
228 224
229 void SkRecorder::onDrawImageNine(const SkImage* image, const SkIRect& center, 225 void SkRecorder::onDrawImageNine(const SkImage* image, const SkIRect& center,
230 const SkRect& dst, const SkPaint* paint) { 226 const SkRect& dst, const SkPaint* paint) {
231 APPEND(DrawImageNine, this->copy(paint), sk_ref_sp(image), center, dst); 227 APPEND(DrawImageNine, this->copy(paint), sk_ref_sp(image), center, dst);
232 } 228 }
233 229
230 void SkRecorder::onDrawImageLattice(const SkImage* image, const Lattice& lattice , const SkRect& dst,
231 const SkPaint* paint) {
232 APPEND(DrawImageLattice, this->copy(paint), sk_ref_sp(image),
233 lattice.fXCount, this->copy(lattice.fXDivs, lattice.fXCount),
234 lattice.fYCount, this->copy(lattice.fYDivs, lattice.fYCount), dst);
235 }
236
234 void SkRecorder::onDrawText(const void* text, size_t byteLength, 237 void SkRecorder::onDrawText(const void* text, size_t byteLength,
235 SkScalar x, SkScalar y, const SkPaint& paint) { 238 SkScalar x, SkScalar y, const SkPaint& paint) {
236 APPEND(DrawText, 239 APPEND(DrawText,
237 paint, this->copy((const char*)text, byteLength), byteLength, x, y); 240 paint, this->copy((const char*)text, byteLength), byteLength, x, y);
238 } 241 }
239 242
240 void SkRecorder::onDrawPosText(const void* text, size_t byteLength, 243 void SkRecorder::onDrawPosText(const void* text, size_t byteLength,
241 const SkPoint pos[], const SkPaint& paint) { 244 const SkPoint pos[], const SkPaint& paint) {
242 const int points = paint.countText(text, byteLength); 245 const int points = paint.countText(text, byteLength);
243 APPEND(DrawPosText, 246 APPEND(DrawPosText,
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 405 }
403 406
404 void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { 407 void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
405 INHERITED(onClipRegion, deviceRgn, op); 408 INHERITED(onClipRegion, deviceRgn, op);
406 APPEND(ClipRegion, this->devBounds(), deviceRgn, op); 409 APPEND(ClipRegion, this->devBounds(), deviceRgn, op);
407 } 410 }
408 411
409 sk_sp<SkSurface> SkRecorder::onNewSurface(const SkImageInfo&, const SkSurfacePro ps&) { 412 sk_sp<SkSurface> SkRecorder::onNewSurface(const SkImageInfo&, const SkSurfacePro ps&) {
410 return nullptr; 413 return nullptr;
411 } 414 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698