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

Side by Side Diff: src/pipe/SkGPipeWrite.cpp

Issue 835913002: Revert of move remaining virtual draw methods to onDraw (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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/SkRecorder.cpp ('k') | src/utils/SkDeferredCanvas.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkAnnotation.h" 9 #include "SkAnnotation.h"
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 fDone = true; 224 fDone = true;
225 } 225 }
226 226
227 void flushRecording(bool detachCurrentBlock); 227 void flushRecording(bool detachCurrentBlock);
228 size_t freeMemoryIfPossible(size_t bytesToFree); 228 size_t freeMemoryIfPossible(size_t bytesToFree);
229 229
230 size_t storageAllocatedForRecording() { 230 size_t storageAllocatedForRecording() {
231 return (NULL == fBitmapHeap) ? 0 : fBitmapHeap->bytesAllocated(); 231 return (NULL == fBitmapHeap) ? 0 : fBitmapHeap->bytesAllocated();
232 } 232 }
233 233
234 // overrides from SkCanvas
235 virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
236 virtual void drawPoints(PointMode, size_t count, const SkPoint pts[],
237 const SkPaint&) SK_OVERRIDE;
238 virtual void drawOval(const SkRect&, const SkPaint&) SK_OVERRIDE;
239 virtual void drawRect(const SkRect& rect, const SkPaint&) SK_OVERRIDE;
240 virtual void drawRRect(const SkRRect&, const SkPaint&) SK_OVERRIDE;
241 virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE;
242 virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top,
243 const SkPaint*) SK_OVERRIDE;
244 virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src,
245 const SkRect& dst, const SkPaint* paint,
246 DrawBitmapRectFlags flags) SK_OVERRIDE;
247 virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
248 const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE;
249 virtual void drawSprite(const SkBitmap&, int left, int top,
250 const SkPaint*) SK_OVERRIDE;
251 virtual void drawVertices(VertexMode, int vertexCount,
252 const SkPoint vertices[], const SkPoint texs[],
253 const SkColor colors[], SkXfermode*,
254 const uint16_t indices[], int indexCount,
255 const SkPaint&) SK_OVERRIDE;
234 virtual void beginCommentGroup(const char* description) SK_OVERRIDE; 256 virtual void beginCommentGroup(const char* description) SK_OVERRIDE;
235 virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE; 257 virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE;
236 virtual void endCommentGroup() SK_OVERRIDE; 258 virtual void endCommentGroup() SK_OVERRIDE;
237 259
238 /** 260 /**
239 * Flatten an SkBitmap to send to the reader, where it will be referenced 261 * Flatten an SkBitmap to send to the reader, where it will be referenced
240 * according to slot. 262 * according to slot.
241 */ 263 */
242 bool shuttleBitmap(const SkBitmap&, int32_t slot); 264 bool shuttleBitmap(const SkBitmap&, int32_t slot);
243 265
(...skipping 12 matching lines...) Expand all
256 const SkPaint&) SK_OVERRIDE; 278 const SkPaint&) SK_OVERRIDE;
257 virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkSca lar xpos[], 279 virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkSca lar xpos[],
258 SkScalar constY, const SkPaint&) SK_OVERRIDE; 280 SkScalar constY, const SkPaint&) SK_OVERRIDE;
259 virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkP ath& path, 281 virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkP ath& path,
260 const SkMatrix* matrix, const SkPaint&) SK_OVE RRIDE; 282 const SkMatrix* matrix, const SkPaint&) SK_OVE RRIDE;
261 virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, 283 virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
262 const SkPaint& paint) SK_OVERRIDE; 284 const SkPaint& paint) SK_OVERRIDE;
263 virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], 285 virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
264 const SkPoint texCoords[4], SkXfermode* xmode, 286 const SkPoint texCoords[4], SkXfermode* xmode,
265 const SkPaint& paint) SK_OVERRIDE; 287 const SkPaint& paint) SK_OVERRIDE;
266 void onDrawPaint(const SkPaint&) SK_OVERRIDE;
267 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPain t&) SK_OVERRIDE;
268 void onDrawRect(const SkRect&, const SkPaint&) SK_OVERRIDE;
269 void onDrawOval(const SkRect&, const SkPaint&) SK_OVERRIDE;
270 void onDrawRRect(const SkRRect&, const SkPaint&) SK_OVERRIDE;
271 void onDrawPath(const SkPath&, const SkPaint&) SK_OVERRIDE;
272 void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPain t*) SK_OVERRIDE;
273 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
274 DrawBitmapRectFlags flags) SK_OVERRIDE;
275 #if 0
276 // rely on decomposition into bitmap (for now)
277 void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint* ) SK_OVERRIDE;
278 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
279 const SkPaint*) SK_OVERRIDE;
280 #endif
281 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
282 const SkPaint*) SK_OVERRIDE;
283 void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) SK_OVE RRIDE;
284 void onDrawVertices(VertexMode vmode, int vertexCount,
285 const SkPoint vertices[], const SkPoint texs[],
286 const SkColor colors[], SkXfermode* xmode,
287 const uint16_t indices[], int indexCount,
288 const SkPaint&) SK_OVERRIDE;
289 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERR IDE; 288 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERR IDE;
290 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVE RRIDE; 289 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVE RRIDE;
291 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERR IDE; 290 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERR IDE;
292 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; 291 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
293 292
294 virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint* ) SK_OVERRIDE; 293 virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint* ) SK_OVERRIDE;
295 294
296 private: 295 private:
297 void recordTranslate(const SkMatrix&); 296 void recordTranslate(const SkMatrix&);
298 void recordScale(const SkMatrix&); 297 void recordScale(const SkMatrix&);
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 NOTIFY_SETUP(this); 661 NOTIFY_SETUP(this);
663 if (this->needOpBytes(region.writeToMemory(NULL))) { 662 if (this->needOpBytes(region.writeToMemory(NULL))) {
664 this->writeOp(kClipRegion_DrawOp, 0, rgnOp); 663 this->writeOp(kClipRegion_DrawOp, 0, rgnOp);
665 fWriter.writeRegion(region); 664 fWriter.writeRegion(region);
666 } 665 }
667 this->INHERITED::onClipRegion(region, rgnOp); 666 this->INHERITED::onClipRegion(region, rgnOp);
668 } 667 }
669 668
670 /////////////////////////////////////////////////////////////////////////////// 669 ///////////////////////////////////////////////////////////////////////////////
671 670
672 void SkGPipeCanvas::onDrawPaint(const SkPaint& paint) { 671 void SkGPipeCanvas::drawPaint(const SkPaint& paint) {
673 NOTIFY_SETUP(this); 672 NOTIFY_SETUP(this);
674 this->writePaint(paint); 673 this->writePaint(paint);
675 if (this->needOpBytes()) { 674 if (this->needOpBytes()) {
676 this->writeOp(kDrawPaint_DrawOp); 675 this->writeOp(kDrawPaint_DrawOp);
677 } 676 }
678 } 677 }
679 678
680 void SkGPipeCanvas::onDrawPoints(PointMode mode, size_t count, 679 void SkGPipeCanvas::drawPoints(PointMode mode, size_t count,
681 const SkPoint pts[], const SkPaint& paint) { 680 const SkPoint pts[], const SkPaint& paint) {
682 if (count) { 681 if (count) {
683 NOTIFY_SETUP(this); 682 NOTIFY_SETUP(this);
684 this->writePaint(paint); 683 this->writePaint(paint);
685 if (this->needOpBytes(4 + count * sizeof(SkPoint))) { 684 if (this->needOpBytes(4 + count * sizeof(SkPoint))) {
686 this->writeOp(kDrawPoints_DrawOp, mode, 0); 685 this->writeOp(kDrawPoints_DrawOp, mode, 0);
687 fWriter.write32(SkToU32(count)); 686 fWriter.write32(SkToU32(count));
688 fWriter.write(pts, count * sizeof(SkPoint)); 687 fWriter.write(pts, count * sizeof(SkPoint));
689 } 688 }
690 } 689 }
691 } 690 }
692 691
693 void SkGPipeCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) { 692 void SkGPipeCanvas::drawOval(const SkRect& rect, const SkPaint& paint) {
694 NOTIFY_SETUP(this); 693 NOTIFY_SETUP(this);
695 this->writePaint(paint); 694 this->writePaint(paint);
696 if (this->needOpBytes(sizeof(SkRect))) { 695 if (this->needOpBytes(sizeof(SkRect))) {
697 this->writeOp(kDrawOval_DrawOp); 696 this->writeOp(kDrawOval_DrawOp);
698 fWriter.writeRect(rect); 697 fWriter.writeRect(rect);
699 } 698 }
700 } 699 }
701 700
702 void SkGPipeCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) { 701 void SkGPipeCanvas::drawRect(const SkRect& rect, const SkPaint& paint) {
703 NOTIFY_SETUP(this); 702 NOTIFY_SETUP(this);
704 this->writePaint(paint); 703 this->writePaint(paint);
705 if (this->needOpBytes(sizeof(SkRect))) { 704 if (this->needOpBytes(sizeof(SkRect))) {
706 this->writeOp(kDrawRect_DrawOp); 705 this->writeOp(kDrawRect_DrawOp);
707 fWriter.writeRect(rect); 706 fWriter.writeRect(rect);
708 } 707 }
709 } 708 }
710 709
711 void SkGPipeCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) { 710 void SkGPipeCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
712 NOTIFY_SETUP(this); 711 NOTIFY_SETUP(this);
713 this->writePaint(paint); 712 this->writePaint(paint);
714 if (this->needOpBytes(kSizeOfFlatRRect)) { 713 if (this->needOpBytes(kSizeOfFlatRRect)) {
715 this->writeOp(kDrawRRect_DrawOp); 714 this->writeOp(kDrawRRect_DrawOp);
716 fWriter.writeRRect(rrect); 715 fWriter.writeRRect(rrect);
717 } 716 }
718 } 717 }
719 718
720 void SkGPipeCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, 719 void SkGPipeCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
721 const SkPaint& paint) { 720 const SkPaint& paint) {
722 NOTIFY_SETUP(this); 721 NOTIFY_SETUP(this);
723 this->writePaint(paint); 722 this->writePaint(paint);
724 if (this->needOpBytes(kSizeOfFlatRRect * 2)) { 723 if (this->needOpBytes(kSizeOfFlatRRect * 2)) {
725 this->writeOp(kDrawDRRect_DrawOp); 724 this->writeOp(kDrawDRRect_DrawOp);
726 fWriter.writeRRect(outer); 725 fWriter.writeRRect(outer);
727 fWriter.writeRRect(inner); 726 fWriter.writeRRect(inner);
728 } 727 }
729 } 728 }
730 729
731 void SkGPipeCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) { 730 void SkGPipeCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
732 NOTIFY_SETUP(this); 731 NOTIFY_SETUP(this);
733 this->writePaint(paint); 732 this->writePaint(paint);
734 if (this->needOpBytes(path.writeToMemory(NULL))) { 733 if (this->needOpBytes(path.writeToMemory(NULL))) {
735 this->writeOp(kDrawPath_DrawOp); 734 this->writeOp(kDrawPath_DrawOp);
736 fWriter.writePath(path); 735 fWriter.writePath(path);
737 } 736 }
738 } 737 }
739 738
740 bool SkGPipeCanvas::commonDrawBitmap(const SkBitmap& bm, DrawOps op, 739 bool SkGPipeCanvas::commonDrawBitmap(const SkBitmap& bm, DrawOps op,
741 unsigned flags, 740 unsigned flags,
(...skipping 15 matching lines...) Expand all
757 return false; 756 return false;
758 } 757 }
759 758
760 if (this->needOpBytes(opBytesNeeded)) { 759 if (this->needOpBytes(opBytesNeeded)) {
761 this->writeOp(op, flags, bitmapIndex); 760 this->writeOp(op, flags, bitmapIndex);
762 return true; 761 return true;
763 } 762 }
764 return false; 763 return false;
765 } 764 }
766 765
767 void SkGPipeCanvas::onDrawBitmap(const SkBitmap& bm, SkScalar left, SkScalar top , 766 void SkGPipeCanvas::drawBitmap(const SkBitmap& bm, SkScalar left, SkScalar top,
768 const SkPaint* paint) { 767 const SkPaint* paint) {
769 NOTIFY_SETUP(this); 768 NOTIFY_SETUP(this);
770 size_t opBytesNeeded = sizeof(SkScalar) * 2; 769 size_t opBytesNeeded = sizeof(SkScalar) * 2;
771 770
772 if (this->commonDrawBitmap(bm, kDrawBitmap_DrawOp, 0, opBytesNeeded, paint)) { 771 if (this->commonDrawBitmap(bm, kDrawBitmap_DrawOp, 0, opBytesNeeded, paint)) {
773 fWriter.writeScalar(left); 772 fWriter.writeScalar(left);
774 fWriter.writeScalar(top); 773 fWriter.writeScalar(top);
775 } 774 }
776 } 775 }
777 776
778 void SkGPipeCanvas::onDrawBitmapRect(const SkBitmap& bm, const SkRect* src, cons t SkRect& dst, 777 void SkGPipeCanvas::drawBitmapRectToRect(const SkBitmap& bm, const SkRect* src,
779 const SkPaint* paint, DrawBitmapRectFlags d bmrFlags) { 778 const SkRect& dst, const SkPaint* paint ,
779 DrawBitmapRectFlags dbmrFlags) {
780 NOTIFY_SETUP(this); 780 NOTIFY_SETUP(this);
781 size_t opBytesNeeded = sizeof(SkRect); 781 size_t opBytesNeeded = sizeof(SkRect);
782 bool hasSrc = src != NULL; 782 bool hasSrc = src != NULL;
783 unsigned flags; 783 unsigned flags;
784 if (hasSrc) { 784 if (hasSrc) {
785 flags = kDrawBitmap_HasSrcRect_DrawOpFlag; 785 flags = kDrawBitmap_HasSrcRect_DrawOpFlag;
786 opBytesNeeded += sizeof(int32_t) * 4; 786 opBytesNeeded += sizeof(int32_t) * 4;
787 } else { 787 } else {
788 flags = 0; 788 flags = 0;
789 } 789 }
790 if (dbmrFlags & kBleed_DrawBitmapRectFlag) { 790 if (dbmrFlags & kBleed_DrawBitmapRectFlag) {
791 flags |= kDrawBitmap_Bleed_DrawOpFlag; 791 flags |= kDrawBitmap_Bleed_DrawOpFlag;
792 } 792 }
793 793
794 if (this->commonDrawBitmap(bm, kDrawBitmapRectToRect_DrawOp, flags, opBytesN eeded, paint)) { 794 if (this->commonDrawBitmap(bm, kDrawBitmapRectToRect_DrawOp, flags, opBytesN eeded, paint)) {
795 if (hasSrc) { 795 if (hasSrc) {
796 fWriter.writeRect(*src); 796 fWriter.writeRect(*src);
797 } 797 }
798 fWriter.writeRect(dst); 798 fWriter.writeRect(dst);
799 } 799 }
800 } 800 }
801 801
802 void SkGPipeCanvas::onDrawBitmapNine(const SkBitmap& bm, const SkIRect& center, 802 void SkGPipeCanvas::drawBitmapNine(const SkBitmap& bm, const SkIRect& center,
803 const SkRect& dst, const SkPaint* paint) { 803 const SkRect& dst, const SkPaint* paint) {
804 NOTIFY_SETUP(this); 804 NOTIFY_SETUP(this);
805 size_t opBytesNeeded = sizeof(int32_t) * 4 + sizeof(SkRect); 805 size_t opBytesNeeded = sizeof(int32_t) * 4 + sizeof(SkRect);
806 806
807 if (this->commonDrawBitmap(bm, kDrawBitmapNine_DrawOp, 0, opBytesNeeded, pai nt)) { 807 if (this->commonDrawBitmap(bm, kDrawBitmapNine_DrawOp, 0, opBytesNeeded, pai nt)) {
808 fWriter.write32(center.fLeft); 808 fWriter.write32(center.fLeft);
809 fWriter.write32(center.fTop); 809 fWriter.write32(center.fTop);
810 fWriter.write32(center.fRight); 810 fWriter.write32(center.fRight);
811 fWriter.write32(center.fBottom); 811 fWriter.write32(center.fBottom);
812 fWriter.writeRect(dst); 812 fWriter.writeRect(dst);
813 } 813 }
814 } 814 }
815 815
816 void SkGPipeCanvas::onDrawSprite(const SkBitmap& bm, int left, int top, const Sk Paint* paint) { 816 void SkGPipeCanvas::drawSprite(const SkBitmap& bm, int left, int top,
817 const SkPaint* paint) {
817 NOTIFY_SETUP(this); 818 NOTIFY_SETUP(this);
818 size_t opBytesNeeded = sizeof(int32_t) * 2; 819 size_t opBytesNeeded = sizeof(int32_t) * 2;
819 820
820 if (this->commonDrawBitmap(bm, kDrawSprite_DrawOp, 0, opBytesNeeded, paint)) { 821 if (this->commonDrawBitmap(bm, kDrawSprite_DrawOp, 0, opBytesNeeded, paint)) {
821 fWriter.write32(left); 822 fWriter.write32(left);
822 fWriter.write32(top); 823 fWriter.write32(top);
823 } 824 }
824 } 825 }
825 826
826 void SkGPipeCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, 827 void SkGPipeCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 void SkGPipeCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matr ix, 973 void SkGPipeCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matr ix,
973 const SkPaint* paint) { 974 const SkPaint* paint) {
974 // we want to playback the picture into individual draw calls 975 // we want to playback the picture into individual draw calls
975 // 976 //
976 // todo: do we always have to unroll? If the pipe is not cross-process, seem s like 977 // todo: do we always have to unroll? If the pipe is not cross-process, seem s like
977 // we could just ref the picture and move on...? <reed, scroggo> 978 // we could just ref the picture and move on...? <reed, scroggo>
978 // 979 //
979 this->INHERITED::onDrawPicture(picture, matrix, paint); 980 this->INHERITED::onDrawPicture(picture, matrix, paint);
980 } 981 }
981 982
982 void SkGPipeCanvas::onDrawVertices(VertexMode vmode, int vertexCount, 983 void SkGPipeCanvas::drawVertices(VertexMode vmode, int vertexCount,
983 const SkPoint vertices[], const SkPoint texs[ ], 984 const SkPoint vertices[], const SkPoint texs[],
984 const SkColor colors[], SkXfermode* xfer, 985 const SkColor colors[], SkXfermode* xfer,
985 const uint16_t indices[], int indexCount, 986 const uint16_t indices[], int indexCount,
986 const SkPaint& paint) { 987 const SkPaint& paint) {
987 if (0 == vertexCount) { 988 if (0 == vertexCount) {
988 return; 989 return;
989 } 990 }
990 991
991 NOTIFY_SETUP(this); 992 NOTIFY_SETUP(this);
992 this->writePaint(paint); 993 this->writePaint(paint);
993 994
994 unsigned flags = 0; // packs with the op, so needs no extra space 995 unsigned flags = 0; // packs with the op, so needs no extra space
995 996
996 size_t size = 0; 997 size_t size = 0;
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 return fCanvas->shuttleBitmap(bitmap, slot); 1331 return fCanvas->shuttleBitmap(bitmap, slot);
1331 } 1332 }
1332 1333
1333 void BitmapShuttle::removeCanvas() { 1334 void BitmapShuttle::removeCanvas() {
1334 if (NULL == fCanvas) { 1335 if (NULL == fCanvas) {
1335 return; 1336 return;
1336 } 1337 }
1337 fCanvas->unref(); 1338 fCanvas->unref();
1338 fCanvas = NULL; 1339 fCanvas = NULL;
1339 } 1340 }
OLDNEW
« no previous file with comments | « src/core/SkRecorder.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698