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

Side by Side Diff: src/core/SkPictureRecord.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 2011 Google Inc. 2 * Copyright 2011 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 "SkPictureRecord.h" 8 #include "SkPictureRecord.h"
9 #include "SkImage_Base.h" 9 #include "SkImage_Base.h"
10 #include "SkPatchUtils.h" 10 #include "SkPatchUtils.h"
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 // op + paint_index + image_index + x + y 473 // op + paint_index + image_index + x + y
474 size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar); 474 size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar);
475 size_t initialOffset = this->addDraw(DRAW_IMAGE, &size); 475 size_t initialOffset = this->addDraw(DRAW_IMAGE, &size);
476 this->addPaintPtr(paint); 476 this->addPaintPtr(paint);
477 this->addImage(image); 477 this->addImage(image);
478 this->addScalar(x); 478 this->addScalar(x);
479 this->addScalar(y); 479 this->addScalar(y);
480 this->validate(initialOffset, size); 480 this->validate(initialOffset, size);
481 } 481 }
482 482
483 void SkPictureRecord::onDrawImageLattice(const SkImage* image, const Lattice& la ttice,
484 const SkRect& dst, const SkPaint* paint ) {
485 // xCount + xDivs + yCount+ yDivs
486 size_t latticeSize = (1 + lattice.fXCount + 1 + lattice.fYCount) * kUInt32Si ze;
487
488 // op + paint index + image index + lattice + dst rect
489 size_t size = 3 * kUInt32Size + latticeSize + sizeof(dst);
490 size_t initialOffset = this->addDraw(DRAW_IMAGE_LATTICE, &size);
491 this->addPaintPtr(paint);
492 this->addImage(image);
493 this->addInt(lattice.fXCount);
494 fWriter.writePad(lattice.fXDivs, lattice.fXCount * kUInt32Size);
495 this->addInt(lattice.fYCount);
496 fWriter.writePad(lattice.fYDivs, lattice.fYCount * kUInt32Size);
497 this->addRect(dst);
498 this->validate(initialOffset, size);
499 }
500
501 void SkPictureRecord::onDrawImageRect(const SkImage* image, const SkRect* src, c onst SkRect& dst, 483 void SkPictureRecord::onDrawImageRect(const SkImage* image, const SkRect* src, c onst SkRect& dst,
502 const SkPaint* paint, SrcRectConstraint co nstraint) { 484 const SkPaint* paint, SrcRectConstraint co nstraint) {
503 // id + paint_index + image_index + bool_for_src + constraint 485 // id + paint_index + image_index + bool_for_src + constraint
504 size_t size = 5 * kUInt32Size; 486 size_t size = 5 * kUInt32Size;
505 if (src) { 487 if (src) {
506 size += sizeof(*src); // + rect 488 size += sizeof(*src); // + rect
507 } 489 }
508 size += sizeof(dst); // + rect 490 size += sizeof(dst); // + rect
509 491
510 size_t initialOffset = this->addDraw(DRAW_IMAGE_RECT, &size); 492 size_t initialOffset = this->addDraw(DRAW_IMAGE_RECT, &size);
(...skipping 11 matching lines...) Expand all
522 size_t size = 3 * kUInt32Size + sizeof(SkIRect) + sizeof(SkRect); 504 size_t size = 3 * kUInt32Size + sizeof(SkIRect) + sizeof(SkRect);
523 505
524 size_t initialOffset = this->addDraw(DRAW_IMAGE_NINE, &size); 506 size_t initialOffset = this->addDraw(DRAW_IMAGE_NINE, &size);
525 this->addPaintPtr(paint); 507 this->addPaintPtr(paint);
526 this->addImage(img); 508 this->addImage(img);
527 this->addIRect(center); 509 this->addIRect(center);
528 this->addRect(dst); 510 this->addRect(dst);
529 this->validate(initialOffset, size); 511 this->validate(initialOffset, size);
530 } 512 }
531 513
514 void SkPictureRecord::onDrawImageLattice(const SkImage* image, const Lattice& la ttice,
515 const SkRect& dst, const SkPaint* paint ) {
516 // xCount + xDivs + yCount+ yDivs
517 size_t latticeSize = (1 + lattice.fXCount + 1 + lattice.fYCount) * kUInt32Si ze;
518
519 // op + paint index + image index + lattice + dst rect
520 size_t size = 3 * kUInt32Size + latticeSize + sizeof(dst);
521 size_t initialOffset = this->addDraw(DRAW_IMAGE_LATTICE, &size);
522 this->addPaintPtr(paint);
523 this->addImage(image);
524 this->addInt(lattice.fXCount);
525 fWriter.writePad(lattice.fXDivs, lattice.fXCount * kUInt32Size);
526 this->addInt(lattice.fYCount);
527 fWriter.writePad(lattice.fYDivs, lattice.fYCount * kUInt32Size);
528 this->addRect(dst);
529 this->validate(initialOffset, size);
530 }
531
532 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x , SkScalar y, 532 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x , SkScalar y,
533 const SkPaint& paint) { 533 const SkPaint& paint) {
534 // op + paint index + length + 'length' worth of chars + x + y 534 // op + paint index + length + 'length' worth of chars + x + y
535 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar); 535 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar);
536 536
537 DrawType op = DRAW_TEXT; 537 DrawType op = DRAW_TEXT;
538 size_t initialOffset = this->addDraw(op, &size); 538 size_t initialOffset = this->addDraw(op, &size);
539 this->addPaint(paint); 539 this->addPaint(paint);
540 this->addText(text, byteLength); 540 this->addText(text, byteLength);
541 this->addScalar(x); 541 this->addScalar(x);
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 958
959 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { 959 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) {
960 int index = fTextBlobRefs.count(); 960 int index = fTextBlobRefs.count();
961 *fTextBlobRefs.append() = blob; 961 *fTextBlobRefs.append() = blob;
962 blob->ref(); 962 blob->ref();
963 // follow the convention of recording a 1-based index 963 // follow the convention of recording a 1-based index
964 this->addInt(index + 1); 964 this->addInt(index + 1);
965 } 965 }
966 966
967 /////////////////////////////////////////////////////////////////////////////// 967 ///////////////////////////////////////////////////////////////////////////////
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698