| 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 if (fDeferredDrawing && |
| 874 this->isFullFrame(&imageRect, paint) && |
| 875 (image->isOpaque() || isPaintOpaque(paint, 0))) { |
| 876 this->getDeferredDevice()->skipPendingCommands(); |
| 877 } |
| 878 |
| 879 AutoImmediateDrawIfNeeded autoDraw(*this, paint); |
| 880 this->drawingCanvas()->drawImage(image, left, top, paint); |
| 881 this->recordedDrawCommand(); |
| 882 } |
| 883 |
| 884 void SkDeferredCanvas::drawImageRect(const SkImage* image, const SkRect* src, |
| 885 const SkRect& dst, |
| 886 const SkPaint* paint) { |
| 887 if (fDeferredDrawing && |
| 888 this->isFullFrame(&dst, paint) && |
| 889 (image->isOpaque() || isPaintOpaque(paint, 0))) { |
| 890 this->getDeferredDevice()->skipPendingCommands(); |
| 891 } |
| 892 |
| 893 AutoImmediateDrawIfNeeded autoDraw(*this, paint); |
| 894 this->drawingCanvas()->drawImageRect(image, src, dst, paint); |
| 895 this->recordedDrawCommand(); |
| 896 } |
| 897 |
| 869 void SkDeferredCanvas::drawSprite(const SkBitmap& bitmap, int left, int top, | 898 void SkDeferredCanvas::drawSprite(const SkBitmap& bitmap, int left, int top, |
| 870 const SkPaint* paint) { | 899 const SkPaint* paint) { |
| 871 SkRect bitmapRect = SkRect::MakeXYWH( | 900 SkRect bitmapRect = SkRect::MakeXYWH( |
| 872 SkIntToScalar(left), | 901 SkIntToScalar(left), |
| 873 SkIntToScalar(top), | 902 SkIntToScalar(top), |
| 874 SkIntToScalar(bitmap.width()), | 903 SkIntToScalar(bitmap.width()), |
| 875 SkIntToScalar(bitmap.height())); | 904 SkIntToScalar(bitmap.height())); |
| 876 if (fDeferredDrawing && | 905 if (fDeferredDrawing && |
| 877 this->isFullFrame(&bitmapRect, paint) && | 906 this->isFullFrame(&bitmapRect, paint) && |
| 878 isPaintOpaque(paint, &bitmap)) { | 907 isPaintOpaque(paint, &bitmap)) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { | 977 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { |
| 949 this->drawingCanvas()->setDrawFilter(filter); | 978 this->drawingCanvas()->setDrawFilter(filter); |
| 950 this->INHERITED::setDrawFilter(filter); | 979 this->INHERITED::setDrawFilter(filter); |
| 951 this->recordedDrawCommand(); | 980 this->recordedDrawCommand(); |
| 952 return filter; | 981 return filter; |
| 953 } | 982 } |
| 954 | 983 |
| 955 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { | 984 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { |
| 956 return this->drawingCanvas(); | 985 return this->drawingCanvas(); |
| 957 } | 986 } |
| OLD | NEW |