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

Side by Side Diff: src/utils/SkDeferredCanvas.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/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::onDrawPaint(const SkPaint& paint) { 757 void SkDeferredCanvas::drawPaint(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::onDrawPoints(PointMode mode, size_t count, 767 void SkDeferredCanvas::drawPoints(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::onDrawOval(const SkRect& rect, const SkPaint& paint) { 774 void SkDeferredCanvas::drawOval(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::onDrawRect(const SkRect& rect, const SkPaint& paint) { 780 void SkDeferredCanvas::drawRect(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::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) { 791 void SkDeferredCanvas::drawRRect(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::onDrawPath(const SkPath& path, const SkPaint& paint) { 810 void SkDeferredCanvas::drawPath(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::onDrawBitmap(const SkBitmap& bitmap, SkScalar left, 816 void SkDeferredCanvas::drawBitmap(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::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* sr c, 831 void SkDeferredCanvas::drawBitmapRectToRect(const SkBitmap& bitmap,
832 const SkRect& dst, 832 const SkRect* src,
833 const SkPaint* paint, DrawBitmapRectFlag s flags) { 833 const SkRect& dst,
834 const SkPaint* paint,
835 DrawBitmapRectFlags flags) {
834 if (fDeferredDrawing && 836 if (fDeferredDrawing &&
835 this->isFullFrame(&dst, paint) && 837 this->isFullFrame(&dst, paint) &&
836 isPaintOpaque(paint, &bitmap)) { 838 isPaintOpaque(paint, &bitmap)) {
837 this->getDeferredDevice()->skipPendingCommands(); 839 this->getDeferredDevice()->skipPendingCommands();
838 } 840 }
839 841
840 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint); 842 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint);
841 this->drawingCanvas()->drawBitmapRectToRect(bitmap, src, dst, paint, flags); 843 this->drawingCanvas()->drawBitmapRectToRect(bitmap, src, dst, paint, flags);
842 this->recordedDrawCommand(); 844 this->recordedDrawCommand();
843 } 845 }
844 846
845 void SkDeferredCanvas::onDrawBitmapNine(const SkBitmap& bitmap, 847 void SkDeferredCanvas::drawBitmapNine(const SkBitmap& bitmap,
846 const SkIRect& center, const SkRect& dst , 848 const SkIRect& center, const SkRect& dst,
847 const SkPaint* paint) { 849 const SkPaint* paint) {
848 // TODO: reset recording canvas if paint+bitmap is opaque and clip rect 850 // TODO: reset recording canvas if paint+bitmap is opaque and clip rect
849 // covers canvas entirely and dst covers canvas entirely 851 // covers canvas entirely and dst covers canvas entirely
850 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint); 852 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint);
851 this->drawingCanvas()->drawBitmapNine(bitmap, center, dst, paint); 853 this->drawingCanvas()->drawBitmapNine(bitmap, center, dst, paint);
852 this->recordedDrawCommand(); 854 this->recordedDrawCommand();
853 } 855 }
854 856
855 void SkDeferredCanvas::onDrawSprite(const SkBitmap& bitmap, int left, int top, 857 void SkDeferredCanvas::drawSprite(const SkBitmap& bitmap, int left, int top,
856 const SkPaint* paint) { 858 const SkPaint* paint) {
857 SkRect bitmapRect = SkRect::MakeXYWH( 859 SkRect bitmapRect = SkRect::MakeXYWH(
858 SkIntToScalar(left), 860 SkIntToScalar(left),
859 SkIntToScalar(top), 861 SkIntToScalar(top),
860 SkIntToScalar(bitmap.width()), 862 SkIntToScalar(bitmap.width()),
861 SkIntToScalar(bitmap.height())); 863 SkIntToScalar(bitmap.height()));
862 if (fDeferredDrawing && 864 if (fDeferredDrawing &&
863 this->isFullFrame(&bitmapRect, paint) && 865 this->isFullFrame(&bitmapRect, paint) &&
864 isPaintOpaque(paint, &bitmap)) { 866 isPaintOpaque(paint, &bitmap)) {
865 this->getDeferredDevice()->skipPendingCommands(); 867 this->getDeferredDevice()->skipPendingCommands();
866 } 868 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 this->drawingCanvas()->drawTextBlob(blob, x, y, paint); 906 this->drawingCanvas()->drawTextBlob(blob, x, y, paint);
905 this->recordedDrawCommand(); 907 this->recordedDrawCommand();
906 } 908 }
907 909
908 void SkDeferredCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* m atrix, 910 void SkDeferredCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* m atrix,
909 const SkPaint* paint) { 911 const SkPaint* paint) {
910 this->drawingCanvas()->drawPicture(picture, matrix, paint); 912 this->drawingCanvas()->drawPicture(picture, matrix, paint);
911 this->recordedDrawCommand(); 913 this->recordedDrawCommand();
912 } 914 }
913 915
914 void SkDeferredCanvas::onDrawVertices(VertexMode vmode, int vertexCount, 916 void SkDeferredCanvas::drawVertices(VertexMode vmode, int vertexCount,
915 const SkPoint vertices[], 917 const SkPoint vertices[],
916 const SkPoint texs[], 918 const SkPoint texs[],
917 const SkColor colors[], SkXfermode* xmode, 919 const SkColor colors[], SkXfermode* xmode,
918 const uint16_t indices[], int indexCount, 920 const uint16_t indices[], int indexCount,
919 const SkPaint& paint) { 921 const SkPaint& paint) {
920 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); 922 AutoImmediateDrawIfNeeded autoDraw(*this, &paint);
921 this->drawingCanvas()->drawVertices(vmode, vertexCount, vertices, texs, colo rs, xmode, 923 this->drawingCanvas()->drawVertices(vmode, vertexCount, vertices, texs, colo rs, xmode,
922 indices, indexCount, paint); 924 indices, indexCount, paint);
923 this->recordedDrawCommand(); 925 this->recordedDrawCommand();
924 } 926 }
925 927
926 void SkDeferredCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor color s[4], 928 void SkDeferredCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor color s[4],
927 const SkPoint texCoords[4], SkXfermode* xmode , 929 const SkPoint texCoords[4], SkXfermode* xmode ,
928 const SkPaint& paint) { 930 const SkPaint& paint) {
929 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); 931 AutoImmediateDrawIfNeeded autoDraw(*this, &paint);
930 this->drawingCanvas()->drawPatch(cubics, colors, texCoords, xmode, paint); 932 this->drawingCanvas()->drawPatch(cubics, colors, texCoords, xmode, paint);
931 this->recordedDrawCommand(); 933 this->recordedDrawCommand();
932 } 934 }
933 935
934 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { 936 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) {
935 this->drawingCanvas()->setDrawFilter(filter); 937 this->drawingCanvas()->setDrawFilter(filter);
936 this->INHERITED::setDrawFilter(filter); 938 this->INHERITED::setDrawFilter(filter);
937 this->recordedDrawCommand(); 939 this->recordedDrawCommand();
938 return filter; 940 return filter;
939 } 941 }
940 942
941 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { 943 SkCanvas* SkDeferredCanvas::canvasForDrawIter() {
942 return this->drawingCanvas(); 944 return this->drawingCanvas();
943 } 945 }
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