| 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 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 void SkDeferredCanvas::drawBitmapNine(const SkBitmap& bitmap, | 859 void SkDeferredCanvas::drawBitmapNine(const SkBitmap& bitmap, |
| 860 const SkIRect& center, const SkRect& dst, | 860 const SkIRect& center, const SkRect& dst, |
| 861 const SkPaint* paint) { | 861 const SkPaint* paint) { |
| 862 // TODO: reset recording canvas if paint+bitmap is opaque and clip rect | 862 // TODO: reset recording canvas if paint+bitmap is opaque and clip rect |
| 863 // covers canvas entirely and dst covers canvas entirely | 863 // covers canvas entirely and dst covers canvas entirely |
| 864 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint); | 864 AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint); |
| 865 this->drawingCanvas()->drawBitmapNine(bitmap, center, dst, paint); | 865 this->drawingCanvas()->drawBitmapNine(bitmap, center, dst, paint); |
| 866 this->recordedDrawCommand(); | 866 this->recordedDrawCommand(); |
| 867 } | 867 } |
| 868 | 868 |
| 869 void SkDeferredCanvas::drawImage(const SkImage* image, SkScalar left, SkScalar t
op, | |
| 870 const SkPaint* paint) { | |
| 871 SkRect imageRect = SkRect::MakeXYWH(left, top, | |
| 872 SkIntToScalar(image->width()), SkIntToScalar(image->height())); | |
| 873 bool isImageOpaque = image->isOpaque(); | |
| 874 SkPaintBitmapOpacity pct = isImageOpaque | |
| 875 ? kOpaque_SkPaintBitmapOpacity : kUnknown_SkPaintBitmapOpacity; | |
| 876 | |
| 877 if (fDeferredDrawing && | |
| 878 this->isFullFrame(&imageRect, paint) && | |
| 879 (isImageOpaque ||isPaintOpaque(paint, pct))) { | |
| 880 this->getDeferredDevice()->skipPendingCommands(); | |
| 881 } | |
| 882 | |
| 883 AutoImmediateDrawIfNeeded autoDraw(*this, paint); | |
| 884 this->drawingCanvas()->drawImage(image, left, top, paint); | |
| 885 this->recordedDrawCommand(); | |
| 886 } | |
| 887 | |
| 888 void SkDeferredCanvas::drawImageRect(const SkImage* image, const SkRect* src, | |
| 889 const SkRect& dst, | |
| 890 const SkPaint* paint) { | |
| 891 bool isImageOpaque = image->isOpaque(); | |
| 892 SkPaintBitmapOpacity pct = isImageOpaque | |
| 893 ? kOpaque_SkPaintBitmapOpacity : kUnknown_SkPaintBitmapOpacity; | |
| 894 | |
| 895 if (fDeferredDrawing && | |
| 896 this->isFullFrame(&dst, paint) && | |
| 897 (isImageOpaque || isPaintOpaque(paint, pct))) { | |
| 898 this->getDeferredDevice()->skipPendingCommands(); | |
| 899 } | |
| 900 | |
| 901 AutoImmediateDrawIfNeeded autoDraw(*this, paint); | |
| 902 this->drawingCanvas()->drawImageRect(image, src, dst, paint); | |
| 903 this->recordedDrawCommand(); | |
| 904 } | |
| 905 | |
| 906 void SkDeferredCanvas::drawSprite(const SkBitmap& bitmap, int left, int top, | 869 void SkDeferredCanvas::drawSprite(const SkBitmap& bitmap, int left, int top, |
| 907 const SkPaint* paint) { | 870 const SkPaint* paint) { |
| 908 SkRect bitmapRect = SkRect::MakeXYWH( | 871 SkRect bitmapRect = SkRect::MakeXYWH( |
| 909 SkIntToScalar(left), | 872 SkIntToScalar(left), |
| 910 SkIntToScalar(top), | 873 SkIntToScalar(top), |
| 911 SkIntToScalar(bitmap.width()), | 874 SkIntToScalar(bitmap.width()), |
| 912 SkIntToScalar(bitmap.height())); | 875 SkIntToScalar(bitmap.height())); |
| 913 if (fDeferredDrawing && | 876 if (fDeferredDrawing && |
| 914 this->isFullFrame(&bitmapRect, paint) && | 877 this->isFullFrame(&bitmapRect, paint) && |
| 915 isPaintOpaque(paint, &bitmap)) { | 878 isPaintOpaque(paint, &bitmap)) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { | 948 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { |
| 986 this->drawingCanvas()->setDrawFilter(filter); | 949 this->drawingCanvas()->setDrawFilter(filter); |
| 987 this->INHERITED::setDrawFilter(filter); | 950 this->INHERITED::setDrawFilter(filter); |
| 988 this->recordedDrawCommand(); | 951 this->recordedDrawCommand(); |
| 989 return filter; | 952 return filter; |
| 990 } | 953 } |
| 991 | 954 |
| 992 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { | 955 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { |
| 993 return this->drawingCanvas(); | 956 return this->drawingCanvas(); |
| 994 } | 957 } |
| OLD | NEW |