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

Side by Side Diff: src/utils/SkDeferredCanvas.cpp

Issue 817723005: 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/pipe/SkGPipeWrite.cpp ('k') | src/utils/SkDumpCanvas.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 2013 Google Inc. 3 * Copyright 2013 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 "SkDeferredCanvas.h" 9 #include "SkDeferredCanvas.h"
10 10
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 this->INHERITED::onClipPath(path, op, edgeStyle); 747 this->INHERITED::onClipPath(path, op, edgeStyle);
748 this->recordedDrawCommand(); 748 this->recordedDrawCommand();
749 } 749 }
750 750
751 void SkDeferredCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { 751 void SkDeferredCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
752 this->drawingCanvas()->clipRegion(deviceRgn, op); 752 this->drawingCanvas()->clipRegion(deviceRgn, op);
753 this->INHERITED::onClipRegion(deviceRgn, op); 753 this->INHERITED::onClipRegion(deviceRgn, op);
754 this->recordedDrawCommand(); 754 this->recordedDrawCommand();
755 } 755 }
756 756
757 void SkDeferredCanvas::drawPaint(const SkPaint& paint) { 757 void SkDeferredCanvas::onDrawPaint(const SkPaint& paint) {
758 if (fDeferredDrawing && this->isFullFrame(NULL, &paint) && 758 if (fDeferredDrawing && this->isFullFrame(NULL, &paint) &&
759 isPaintOpaque(&paint)) { 759 isPaintOpaque(&paint)) {
760 this->getDeferredDevice()->skipPendingCommands(); 760 this->getDeferredDevice()->skipPendingCommands();
761 } 761 }
762 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); 762 AutoImmediateDrawIfNeeded autoDraw(*this, &paint);
763 this->drawingCanvas()->drawPaint(paint); 763 this->drawingCanvas()->drawPaint(paint);
764 this->recordedDrawCommand(); 764 this->recordedDrawCommand();
765 } 765 }
766 766
767 void SkDeferredCanvas::drawPoints(PointMode mode, size_t count, 767 void SkDeferredCanvas::onDrawPoints(PointMode mode, size_t count,
768 const SkPoint pts[], const SkPaint& paint) { 768 const SkPoint pts[], const SkPaint& paint) {
769 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); 769 AutoImmediateDrawIfNeeded autoDraw(*this, &paint);
770 this->drawingCanvas()->drawPoints(mode, count, pts, paint); 770 this->drawingCanvas()->drawPoints(mode, count, pts, paint);
771 this->recordedDrawCommand(); 771 this->recordedDrawCommand();
772 } 772 }
773 773
774 void SkDeferredCanvas::drawOval(const SkRect& rect, const SkPaint& paint) { 774 void SkDeferredCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) {
775 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); 775 AutoImmediateDrawIfNeeded autoDraw(*this, &paint);
776 this->drawingCanvas()->drawOval(rect, paint); 776 this->drawingCanvas()->drawOval(rect, paint);
777 this->recordedDrawCommand(); 777 this->recordedDrawCommand();
778 } 778 }
779 779
780 void SkDeferredCanvas::drawRect(const SkRect& rect, const SkPaint& paint) { 780 void SkDeferredCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) {
781 if (fDeferredDrawing && this->isFullFrame(&rect, &paint) && 781 if (fDeferredDrawing && this->isFullFrame(&rect, &paint) &&
782 isPaintOpaque(&paint)) { 782 isPaintOpaque(&paint)) {
783 this->getDeferredDevice()->skipPendingCommands(); 783 this->getDeferredDevice()->skipPendingCommands();
784 } 784 }
785 785
786 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); 786 AutoImmediateDrawIfNeeded autoDraw(*this, &paint);
787 this->drawingCanvas()->drawRect(rect, paint); 787 this->drawingCanvas()->drawRect(rect, paint);
788 this->recordedDrawCommand(); 788 this->recordedDrawCommand();
789 } 789 }
790 790
791 void SkDeferredCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) { 791 void SkDeferredCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
792 if (rrect.isRect()) { 792 if (rrect.isRect()) {
793 this->SkDeferredCanvas::drawRect(rrect.getBounds(), paint); 793 this->SkDeferredCanvas::drawRect(rrect.getBounds(), paint);
794 } else if (rrect.isOval()) { 794 } else if (rrect.isOval()) {
795 this->SkDeferredCanvas::drawOval(rrect.getBounds(), paint); 795 this->SkDeferredCanvas::drawOval(rrect.getBounds(), paint);
796 } else { 796 } else {
797 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); 797 AutoImmediateDrawIfNeeded autoDraw(*this, &paint);
798 this->drawingCanvas()->drawRRect(rrect, paint); 798 this->drawingCanvas()->drawRRect(rrect, paint);
799 this->recordedDrawCommand(); 799 this->recordedDrawCommand();
800 } 800 }
801 } 801 }
802 802
803 void SkDeferredCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, 803 void SkDeferredCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
804 const SkPaint& paint) { 804 const SkPaint& paint) {
805 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); 805 AutoImmediateDrawIfNeeded autoDraw(*this, &paint);
806 this->drawingCanvas()->drawDRRect(outer, inner, paint); 806 this->drawingCanvas()->drawDRRect(outer, inner, paint);
807 this->recordedDrawCommand(); 807 this->recordedDrawCommand();
808 } 808 }
809 809
810 void SkDeferredCanvas::drawPath(const SkPath& path, const SkPaint& paint) { 810 void SkDeferredCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
811 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); 811 AutoImmediateDrawIfNeeded autoDraw(*this, &paint);
812 this->drawingCanvas()->drawPath(path, paint); 812 this->drawingCanvas()->drawPath(path, paint);
813 this->recordedDrawCommand(); 813 this->recordedDrawCommand();
814 } 814 }
815 815
816 void SkDeferredCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar left, 816 void SkDeferredCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar left,
817 SkScalar top, const SkPaint* paint) { 817 SkScalar top, const SkPaint* paint) {
818 SkRect bitmapRect = SkRect::MakeXYWH(left, top, 818 SkRect bitmapRect = SkRect::MakeXYWH(left, top,
819 SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height())); 819 SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height()));
820 if (fDeferredDrawing && 820 if (fDeferredDrawing &&
821 this->isFullFrame(&bitmapRect, paint) && 821 this->isFullFrame(&bitmapRect, paint) &&
822 isPaintOpaque(paint, &bitmap)) { 822 isPaintOpaque(paint, &bitmap)) {
823 this->getDeferredDevice()->skipPendingCommands(); 823 this->getDeferredDevice()->skipPendingCommands();
824 } 824 }
825 825
826 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint); 826 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint);
827 this->drawingCanvas()->drawBitmap(bitmap, left, top, paint); 827 this->drawingCanvas()->drawBitmap(bitmap, left, top, paint);
828 this->recordedDrawCommand(); 828 this->recordedDrawCommand();
829 } 829 }
830 830
831 void SkDeferredCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, 831 void SkDeferredCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* sr c,
832 const SkRect* src, 832 const SkRect& dst,
833 const SkRect& dst, 833 const SkPaint* paint, DrawBitmapRectFlag s flags) {
834 const SkPaint* paint,
835 DrawBitmapRectFlags flags) {
836 if (fDeferredDrawing && 834 if (fDeferredDrawing &&
837 this->isFullFrame(&dst, paint) && 835 this->isFullFrame(&dst, paint) &&
838 isPaintOpaque(paint, &bitmap)) { 836 isPaintOpaque(paint, &bitmap)) {
839 this->getDeferredDevice()->skipPendingCommands(); 837 this->getDeferredDevice()->skipPendingCommands();
840 } 838 }
841 839
842 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint); 840 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint);
843 this->drawingCanvas()->drawBitmapRectToRect(bitmap, src, dst, paint, flags); 841 this->drawingCanvas()->drawBitmapRectToRect(bitmap, src, dst, paint, flags);
844 this->recordedDrawCommand(); 842 this->recordedDrawCommand();
845 } 843 }
846 844
847 void SkDeferredCanvas::drawBitmapNine(const SkBitmap& bitmap, 845 void SkDeferredCanvas::onDrawBitmapNine(const SkBitmap& bitmap,
848 const SkIRect& center, const SkRect& dst, 846 const SkIRect& center, const SkRect& dst ,
849 const SkPaint* paint) { 847 const SkPaint* paint) {
850 // TODO: reset recording canvas if paint+bitmap is opaque and clip rect 848 // TODO: reset recording canvas if paint+bitmap is opaque and clip rect
851 // covers canvas entirely and dst covers canvas entirely 849 // covers canvas entirely and dst covers canvas entirely
852 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint); 850 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint);
853 this->drawingCanvas()->drawBitmapNine(bitmap, center, dst, paint); 851 this->drawingCanvas()->drawBitmapNine(bitmap, center, dst, paint);
854 this->recordedDrawCommand(); 852 this->recordedDrawCommand();
855 } 853 }
856 854
857 void SkDeferredCanvas::drawSprite(const SkBitmap& bitmap, int left, int top, 855 void SkDeferredCanvas::onDrawSprite(const SkBitmap& bitmap, int left, int top,
858 const SkPaint* paint) { 856 const SkPaint* paint) {
859 SkRect bitmapRect = SkRect::MakeXYWH( 857 SkRect bitmapRect = SkRect::MakeXYWH(
860 SkIntToScalar(left), 858 SkIntToScalar(left),
861 SkIntToScalar(top), 859 SkIntToScalar(top),
862 SkIntToScalar(bitmap.width()), 860 SkIntToScalar(bitmap.width()),
863 SkIntToScalar(bitmap.height())); 861 SkIntToScalar(bitmap.height()));
864 if (fDeferredDrawing && 862 if (fDeferredDrawing &&
865 this->isFullFrame(&bitmapRect, paint) && 863 this->isFullFrame(&bitmapRect, paint) &&
866 isPaintOpaque(paint, &bitmap)) { 864 isPaintOpaque(paint, &bitmap)) {
867 this->getDeferredDevice()->skipPendingCommands(); 865 this->getDeferredDevice()->skipPendingCommands();
868 } 866 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 this->drawingCanvas()->drawTextBlob(blob, x, y, paint); 904 this->drawingCanvas()->drawTextBlob(blob, x, y, paint);
907 this->recordedDrawCommand(); 905 this->recordedDrawCommand();
908 } 906 }
909 907
910 void SkDeferredCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* m atrix, 908 void SkDeferredCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* m atrix,
911 const SkPaint* paint) { 909 const SkPaint* paint) {
912 this->drawingCanvas()->drawPicture(picture, matrix, paint); 910 this->drawingCanvas()->drawPicture(picture, matrix, paint);
913 this->recordedDrawCommand(); 911 this->recordedDrawCommand();
914 } 912 }
915 913
916 void SkDeferredCanvas::drawVertices(VertexMode vmode, int vertexCount, 914 void SkDeferredCanvas::onDrawVertices(VertexMode vmode, int vertexCount,
917 const SkPoint vertices[], 915 const SkPoint vertices[],
918 const SkPoint texs[], 916 const SkPoint texs[],
919 const SkColor colors[], SkXfermode* xmode, 917 const SkColor colors[], SkXfermode* xmode,
920 const uint16_t indices[], int indexCount, 918 const uint16_t indices[], int indexCount,
921 const SkPaint& paint) { 919 const SkPaint& paint) {
922 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); 920 AutoImmediateDrawIfNeeded autoDraw(*this, &paint);
923 this->drawingCanvas()->drawVertices(vmode, vertexCount, vertices, texs, colo rs, xmode, 921 this->drawingCanvas()->drawVertices(vmode, vertexCount, vertices, texs, colo rs, xmode,
924 indices, indexCount, paint); 922 indices, indexCount, paint);
925 this->recordedDrawCommand(); 923 this->recordedDrawCommand();
926 } 924 }
927 925
928 void SkDeferredCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor color s[4], 926 void SkDeferredCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor color s[4],
929 const SkPoint texCoords[4], SkXfermode* xmode , 927 const SkPoint texCoords[4], SkXfermode* xmode ,
930 const SkPaint& paint) { 928 const SkPaint& paint) {
931 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); 929 AutoImmediateDrawIfNeeded autoDraw(*this, &paint);
932 this->drawingCanvas()->drawPatch(cubics, colors, texCoords, xmode, paint); 930 this->drawingCanvas()->drawPatch(cubics, colors, texCoords, xmode, paint);
933 this->recordedDrawCommand(); 931 this->recordedDrawCommand();
934 } 932 }
935 933
936 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { 934 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) {
937 this->drawingCanvas()->setDrawFilter(filter); 935 this->drawingCanvas()->setDrawFilter(filter);
938 this->INHERITED::setDrawFilter(filter); 936 this->INHERITED::setDrawFilter(filter);
939 this->recordedDrawCommand(); 937 this->recordedDrawCommand();
940 return filter; 938 return filter;
941 } 939 }
942 940
943 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { 941 SkCanvas* SkDeferredCanvas::canvasForDrawIter() {
944 return this->drawingCanvas(); 942 return this->drawingCanvas();
945 } 943 }
OLDNEW
« no previous file with comments | « src/pipe/SkGPipeWrite.cpp ('k') | src/utils/SkDumpCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698