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

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

Issue 2382893002: Add a src rect to drawImageLattice() API (Closed)
Patch Set: Simplify impl Created 4 years, 2 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/SkPicturePlayback.cpp ('k') | src/core/SkRecordDraw.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 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 this->addIRect(center); 533 this->addIRect(center);
534 this->addRect(dst); 534 this->addRect(dst);
535 this->validate(initialOffset, size); 535 this->validate(initialOffset, size);
536 } 536 }
537 537
538 void SkPictureRecord::onDrawImageLattice(const SkImage* image, const Lattice& la ttice, 538 void SkPictureRecord::onDrawImageLattice(const SkImage* image, const Lattice& la ttice,
539 const SkRect& dst, const SkPaint* paint ) { 539 const SkRect& dst, const SkPaint* paint ) {
540 // xCount + xDivs + yCount+ yDivs 540 // xCount + xDivs + yCount+ yDivs
541 int flagCount = (nullptr == lattice.fFlags) ? 0 : (lattice.fXCount + 1) * (l attice.fYCount + 1); 541 int flagCount = (nullptr == lattice.fFlags) ? 0 : (lattice.fXCount + 1) * (l attice.fYCount + 1);
542 size_t latticeSize = (1 + lattice.fXCount + 1 + lattice.fYCount + 1) * kUInt 32Size + 542 size_t latticeSize = (1 + lattice.fXCount + 1 + lattice.fYCount + 1) * kUInt 32Size +
543 SkAlign4(flagCount * sizeof(SkCanvas::Lattice::Flags)); 543 SkAlign4(flagCount * sizeof(SkCanvas::Lattice::Flags)) + sizeof(SkIRect);
544 544
545 // op + paint index + image index + lattice + dst rect 545 // op + paint index + image index + lattice + dst rect
546 size_t size = 3 * kUInt32Size + latticeSize + sizeof(dst); 546 size_t size = 3 * kUInt32Size + latticeSize + sizeof(dst);
547 size_t initialOffset = this->addDraw(DRAW_IMAGE_LATTICE, &size); 547 size_t initialOffset = this->addDraw(DRAW_IMAGE_LATTICE, &size);
548 this->addPaintPtr(paint); 548 this->addPaintPtr(paint);
549 this->addImage(image); 549 this->addImage(image);
550 this->addInt(lattice.fXCount); 550 this->addInt(lattice.fXCount);
551 fWriter.writePad(lattice.fXDivs, lattice.fXCount * kUInt32Size); 551 fWriter.writePad(lattice.fXDivs, lattice.fXCount * kUInt32Size);
552 this->addInt(lattice.fYCount); 552 this->addInt(lattice.fYCount);
553 fWriter.writePad(lattice.fYDivs, lattice.fYCount * kUInt32Size); 553 fWriter.writePad(lattice.fYDivs, lattice.fYCount * kUInt32Size);
554 this->addInt(flagCount); 554 this->addInt(flagCount);
555 fWriter.writePad(lattice.fFlags, flagCount * sizeof(SkCanvas::Lattice::Flags )); 555 fWriter.writePad(lattice.fFlags, flagCount * sizeof(SkCanvas::Lattice::Flags ));
556 SkASSERT(lattice.fBounds);
557 this->addIRect(*lattice.fBounds);
556 this->addRect(dst); 558 this->addRect(dst);
557 this->validate(initialOffset, size); 559 this->validate(initialOffset, size);
558 } 560 }
559 561
560 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x , SkScalar y, 562 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x , SkScalar y,
561 const SkPaint& paint) { 563 const SkPaint& paint) {
562 // op + paint index + length + 'length' worth of chars + x + y 564 // op + paint index + length + 'length' worth of chars + x + y
563 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar); 565 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar);
564 566
565 DrawType op = DRAW_TEXT; 567 DrawType op = DRAW_TEXT;
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 addInt(SkToInt(byteLength)); 987 addInt(SkToInt(byteLength));
986 fWriter.writePad(text, byteLength); 988 fWriter.writePad(text, byteLength);
987 } 989 }
988 990
989 void SkPictureRecord::addTextBlob(const SkTextBlob* blob) { 991 void SkPictureRecord::addTextBlob(const SkTextBlob* blob) {
990 // follow the convention of recording a 1-based index 992 // follow the convention of recording a 1-based index
991 this->addInt(find_or_append_uniqueID(fTextBlobRefs, blob) + 1); 993 this->addInt(find_or_append_uniqueID(fTextBlobRefs, blob) + 1);
992 } 994 }
993 995
994 /////////////////////////////////////////////////////////////////////////////// 996 ///////////////////////////////////////////////////////////////////////////////
OLDNEW
« no previous file with comments | « src/core/SkPicturePlayback.cpp ('k') | src/core/SkRecordDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698