| OLD | NEW |
| 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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 this->recordedDrawCommand(); | 784 this->recordedDrawCommand(); |
| 785 } | 785 } |
| 786 | 786 |
| 787 void SkDeferredCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op)
{ | 787 void SkDeferredCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op)
{ |
| 788 this->drawingCanvas()->clipRegion(deviceRgn, op); | 788 this->drawingCanvas()->clipRegion(deviceRgn, op); |
| 789 this->INHERITED::onClipRegion(deviceRgn, op); | 789 this->INHERITED::onClipRegion(deviceRgn, op); |
| 790 this->recordedDrawCommand(); | 790 this->recordedDrawCommand(); |
| 791 } | 791 } |
| 792 | 792 |
| 793 void SkDeferredCanvas::onDrawPaint(const SkPaint& paint) { | 793 void SkDeferredCanvas::onDrawPaint(const SkPaint& paint) { |
| 794 if (fDeferredDrawing && this->isFullFrame(NULL, &paint) && | 794 if (fDeferredDrawing && this->isFullFrame(NULL, &paint) && SkPaintPriv::Over
writes(paint)) { |
| 795 isPaintOpaque(&paint)) { | |
| 796 this->getDeferredDevice()->skipPendingCommands(); | 795 this->getDeferredDevice()->skipPendingCommands(); |
| 797 } | 796 } |
| 798 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); | 797 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); |
| 799 this->drawingCanvas()->drawPaint(paint); | 798 this->drawingCanvas()->drawPaint(paint); |
| 800 this->recordedDrawCommand(); | 799 this->recordedDrawCommand(); |
| 801 } | 800 } |
| 802 | 801 |
| 803 void SkDeferredCanvas::onDrawPoints(PointMode mode, size_t count, | 802 void SkDeferredCanvas::onDrawPoints(PointMode mode, size_t count, |
| 804 const SkPoint pts[], const SkPaint& paint) { | 803 const SkPoint pts[], const SkPaint& paint) { |
| 805 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); | 804 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); |
| 806 this->drawingCanvas()->drawPoints(mode, count, pts, paint); | 805 this->drawingCanvas()->drawPoints(mode, count, pts, paint); |
| 807 this->recordedDrawCommand(); | 806 this->recordedDrawCommand(); |
| 808 } | 807 } |
| 809 | 808 |
| 810 void SkDeferredCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) { | 809 void SkDeferredCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) { |
| 811 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); | 810 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); |
| 812 this->drawingCanvas()->drawOval(rect, paint); | 811 this->drawingCanvas()->drawOval(rect, paint); |
| 813 this->recordedDrawCommand(); | 812 this->recordedDrawCommand(); |
| 814 } | 813 } |
| 815 | 814 |
| 816 void SkDeferredCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) { | 815 void SkDeferredCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) { |
| 817 if (fDeferredDrawing && this->isFullFrame(&rect, &paint) && | 816 if (fDeferredDrawing && this->isFullFrame(&rect, &paint) && SkPaintPriv::Ove
rwrites(paint)) { |
| 818 isPaintOpaque(&paint)) { | |
| 819 this->getDeferredDevice()->skipPendingCommands(); | 817 this->getDeferredDevice()->skipPendingCommands(); |
| 820 } | 818 } |
| 821 | 819 |
| 822 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); | 820 AutoImmediateDrawIfNeeded autoDraw(*this, &paint); |
| 823 this->drawingCanvas()->drawRect(rect, paint); | 821 this->drawingCanvas()->drawRect(rect, paint); |
| 824 this->recordedDrawCommand(); | 822 this->recordedDrawCommand(); |
| 825 } | 823 } |
| 826 | 824 |
| 827 void SkDeferredCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) { | 825 void SkDeferredCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) { |
| 828 if (rrect.isRect()) { | 826 if (rrect.isRect()) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 848 this->drawingCanvas()->drawPath(path, paint); | 846 this->drawingCanvas()->drawPath(path, paint); |
| 849 this->recordedDrawCommand(); | 847 this->recordedDrawCommand(); |
| 850 } | 848 } |
| 851 | 849 |
| 852 void SkDeferredCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar left, | 850 void SkDeferredCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar left, |
| 853 SkScalar top, const SkPaint* paint) { | 851 SkScalar top, const SkPaint* paint) { |
| 854 SkRect bitmapRect = SkRect::MakeXYWH(left, top, | 852 SkRect bitmapRect = SkRect::MakeXYWH(left, top, |
| 855 SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height())); | 853 SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height())); |
| 856 if (fDeferredDrawing && | 854 if (fDeferredDrawing && |
| 857 this->isFullFrame(&bitmapRect, paint) && | 855 this->isFullFrame(&bitmapRect, paint) && |
| 858 isPaintOpaque(paint, &bitmap)) { | 856 SkPaintPriv::Overwrites(bitmap, paint)) { |
| 859 this->getDeferredDevice()->skipPendingCommands(); | 857 this->getDeferredDevice()->skipPendingCommands(); |
| 860 } | 858 } |
| 861 | 859 |
| 862 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint); | 860 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint); |
| 863 this->drawingCanvas()->drawBitmap(bitmap, left, top, paint); | 861 this->drawingCanvas()->drawBitmap(bitmap, left, top, paint); |
| 864 this->recordedDrawCommand(); | 862 this->recordedDrawCommand(); |
| 865 } | 863 } |
| 866 | 864 |
| 867 void SkDeferredCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* sr
c, | 865 void SkDeferredCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* sr
c, |
| 868 const SkRect& dst, const SkPaint* paint, | 866 const SkRect& dst, const SkPaint* paint, |
| 869 SK_VIRTUAL_CONSTRAINT_TYPE constraint) { | 867 SK_VIRTUAL_CONSTRAINT_TYPE constraint) { |
| 870 if (fDeferredDrawing && | 868 if (fDeferredDrawing && |
| 871 this->isFullFrame(&dst, paint) && | 869 this->isFullFrame(&dst, paint) && |
| 872 isPaintOpaque(paint, &bitmap)) { | 870 SkPaintPriv::Overwrites(bitmap, paint)) { |
| 873 this->getDeferredDevice()->skipPendingCommands(); | 871 this->getDeferredDevice()->skipPendingCommands(); |
| 874 } | 872 } |
| 875 | 873 |
| 876 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint); | 874 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint); |
| 877 this->drawingCanvas()->drawBitmapRect(bitmap, src, dst, paint, (SrcRectConst
raint)constraint); | 875 this->drawingCanvas()->drawBitmapRect(bitmap, src, dst, paint, (SrcRectConst
raint)constraint); |
| 878 this->recordedDrawCommand(); | 876 this->recordedDrawCommand(); |
| 879 } | 877 } |
| 880 | 878 |
| 881 | 879 |
| 882 void SkDeferredCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, | 880 void SkDeferredCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, |
| 883 const SkPaint* paint) { | 881 const SkPaint* paint) { |
| 884 SkRect bounds = SkRect::MakeXYWH(x, y, | 882 SkRect bounds = SkRect::MakeXYWH(x, y, |
| 885 SkIntToScalar(image->width()), SkIntToScala
r(image->height())); | 883 SkIntToScalar(image->width()), SkIntToScala
r(image->height())); |
| 886 if (fDeferredDrawing && | 884 if (fDeferredDrawing && |
| 887 this->isFullFrame(&bounds, paint) && | 885 this->isFullFrame(&bounds, paint) && |
| 888 isPaintOpaque(paint, image)) { | 886 SkPaintPriv::Overwrites(image, paint)) { |
| 889 this->getDeferredDevice()->skipPendingCommands(); | 887 this->getDeferredDevice()->skipPendingCommands(); |
| 890 } | 888 } |
| 891 | 889 |
| 892 AutoImmediateDrawIfNeeded autoDraw(*this, image, paint); | 890 AutoImmediateDrawIfNeeded autoDraw(*this, image, paint); |
| 893 this->drawingCanvas()->drawImage(image, x, y, paint); | 891 this->drawingCanvas()->drawImage(image, x, y, paint); |
| 894 this->recordedDrawCommand(); | 892 this->recordedDrawCommand(); |
| 895 } | 893 } |
| 896 void SkDeferredCanvas::onDrawImageRect(const SkImage* image, const SkRect* src,
const SkRect& dst, | 894 void SkDeferredCanvas::onDrawImageRect(const SkImage* image, const SkRect* src,
const SkRect& dst, |
| 897 const SkPaint* paint SRC_RECT_CONSTRAINT_
PARAM(constraint)) { | 895 const SkPaint* paint SRC_RECT_CONSTRAINT_
PARAM(constraint)) { |
| 898 if (fDeferredDrawing && | 896 if (fDeferredDrawing && |
| 899 this->isFullFrame(&dst, paint) && | 897 this->isFullFrame(&dst, paint) && |
| 900 isPaintOpaque(paint, image)) { | 898 SkPaintPriv::Overwrites(image, paint)) { |
| 901 this->getDeferredDevice()->skipPendingCommands(); | 899 this->getDeferredDevice()->skipPendingCommands(); |
| 902 } | 900 } |
| 903 | 901 |
| 904 AutoImmediateDrawIfNeeded autoDraw(*this, image, paint); | 902 AutoImmediateDrawIfNeeded autoDraw(*this, image, paint); |
| 905 this->drawingCanvas()->drawImageRect(image, src, dst, paint | 903 this->drawingCanvas()->drawImageRect(image, src, dst, paint |
| 906 SRC_RECT_CONSTRAINT_ARG(constraint)); | 904 SRC_RECT_CONSTRAINT_ARG(constraint)); |
| 907 this->recordedDrawCommand(); | 905 this->recordedDrawCommand(); |
| 908 } | 906 } |
| 909 | 907 |
| 910 void SkDeferredCanvas::onDrawImageNine(const SkImage* image, const SkIRect& cent
er, | 908 void SkDeferredCanvas::onDrawImageNine(const SkImage* image, const SkIRect& cent
er, |
| 911 const SkRect& dst, const SkPaint* paint)
{ | 909 const SkRect& dst, const SkPaint* paint)
{ |
| 912 if (fDeferredDrawing && | 910 if (fDeferredDrawing && |
| 913 this->isFullFrame(&dst, paint) && | 911 this->isFullFrame(&dst, paint) && |
| 914 isPaintOpaque(paint, image)) { | 912 SkPaintPriv::Overwrites(image, paint)) { |
| 915 this->getDeferredDevice()->skipPendingCommands(); | 913 this->getDeferredDevice()->skipPendingCommands(); |
| 916 } | 914 } |
| 917 | 915 |
| 918 AutoImmediateDrawIfNeeded autoDraw(*this, image, paint); | 916 AutoImmediateDrawIfNeeded autoDraw(*this, image, paint); |
| 919 this->drawingCanvas()->drawImageNine(image, center, dst, paint); | 917 this->drawingCanvas()->drawImageNine(image, center, dst, paint); |
| 920 this->recordedDrawCommand(); | 918 this->recordedDrawCommand(); |
| 921 } | 919 } |
| 922 | 920 |
| 923 void SkDeferredCanvas::onDrawBitmapNine(const SkBitmap& bitmap, | 921 void SkDeferredCanvas::onDrawBitmapNine(const SkBitmap& bitmap, |
| 924 const SkIRect& center, const SkRect& dst
, | 922 const SkIRect& center, const SkRect& dst
, |
| 925 const SkPaint* paint) { | 923 const SkPaint* paint) { |
| 926 // TODO: reset recording canvas if paint+bitmap is opaque and clip rect | 924 // TODO: reset recording canvas if paint+bitmap is opaque and clip rect |
| 927 // covers canvas entirely and dst covers canvas entirely | 925 // covers canvas entirely and dst covers canvas entirely |
| 928 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint); | 926 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint); |
| 929 this->drawingCanvas()->drawBitmapNine(bitmap, center, dst, paint); | 927 this->drawingCanvas()->drawBitmapNine(bitmap, center, dst, paint); |
| 930 this->recordedDrawCommand(); | 928 this->recordedDrawCommand(); |
| 931 } | 929 } |
| 932 | 930 |
| 933 void SkDeferredCanvas::onDrawSprite(const SkBitmap& bitmap, int left, int top, | 931 void SkDeferredCanvas::onDrawSprite(const SkBitmap& bitmap, int left, int top, |
| 934 const SkPaint* paint) { | 932 const SkPaint* paint) { |
| 935 SkRect bitmapRect = SkRect::MakeXYWH( | 933 SkRect bitmapRect = SkRect::MakeXYWH( |
| 936 SkIntToScalar(left), | 934 SkIntToScalar(left), |
| 937 SkIntToScalar(top), | 935 SkIntToScalar(top), |
| 938 SkIntToScalar(bitmap.width()), | 936 SkIntToScalar(bitmap.width()), |
| 939 SkIntToScalar(bitmap.height())); | 937 SkIntToScalar(bitmap.height())); |
| 940 if (fDeferredDrawing && | 938 if (fDeferredDrawing && |
| 941 this->isFullFrame(&bitmapRect, paint) && | 939 this->isFullFrame(&bitmapRect, paint) && |
| 942 isPaintOpaque(paint, &bitmap)) { | 940 SkPaintPriv::Overwrites(bitmap, paint)) { |
| 943 this->getDeferredDevice()->skipPendingCommands(); | 941 this->getDeferredDevice()->skipPendingCommands(); |
| 944 } | 942 } |
| 945 | 943 |
| 946 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint); | 944 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint); |
| 947 this->drawingCanvas()->drawSprite(bitmap, left, top, paint); | 945 this->drawingCanvas()->drawSprite(bitmap, left, top, paint); |
| 948 this->recordedDrawCommand(); | 946 this->recordedDrawCommand(); |
| 949 } | 947 } |
| 950 | 948 |
| 951 void SkDeferredCanvas::onDrawText(const void* text, size_t byteLength, SkScalar
x, SkScalar y, | 949 void SkDeferredCanvas::onDrawText(const void* text, size_t byteLength, SkScalar
x, SkScalar y, |
| 952 const SkPaint& paint) { | 950 const SkPaint& paint) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { | 1019 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { |
| 1022 this->drawingCanvas()->setDrawFilter(filter); | 1020 this->drawingCanvas()->setDrawFilter(filter); |
| 1023 this->INHERITED::setDrawFilter(filter); | 1021 this->INHERITED::setDrawFilter(filter); |
| 1024 this->recordedDrawCommand(); | 1022 this->recordedDrawCommand(); |
| 1025 return filter; | 1023 return filter; |
| 1026 } | 1024 } |
| 1027 | 1025 |
| 1028 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { | 1026 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { |
| 1029 return this->drawingCanvas(); | 1027 return this->drawingCanvas(); |
| 1030 } | 1028 } |
| OLD | NEW |