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

Side by Side Diff: src/core/SkCanvas.cpp

Issue 1124003002: Revert of Make drawImage a virtual on SkDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 | « include/utils/SkDeferredCanvas.h ('k') | src/core/SkDevice.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 * Copyright 2008 The Android Open Source Project 2 * Copyright 2008 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkCanvasPriv.h" 9 #include "SkCanvasPriv.h"
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 const SkPoint texs[], const SkColor colors[], SkXfer mode* xmode, 1727 const SkPoint texs[], const SkColor colors[], SkXfer mode* xmode,
1728 const uint16_t indices[], int indexCount, const SkPa int& paint) { 1728 const uint16_t indices[], int indexCount, const SkPa int& paint) {
1729 this->onDrawVertices(vmode, vertexCount, vertices, texs, colors, xmode, 1729 this->onDrawVertices(vmode, vertexCount, vertices, texs, colors, xmode,
1730 indices, indexCount, paint); 1730 indices, indexCount, paint);
1731 } 1731 }
1732 1732
1733 void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) { 1733 void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
1734 this->onDrawPath(path, paint); 1734 this->onDrawPath(path, paint);
1735 } 1735 }
1736 1736
1737 void SkCanvas::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkP aint* paint) { 1737 void SkCanvas::drawImage(const SkImage* image, SkScalar dx, SkScalar dy, const S kPaint* paint) {
1738 this->onDrawImage(image, x, y, paint); 1738 this->onDrawImage(image, dx, dy, paint);
1739 } 1739 }
1740 1740
1741 void SkCanvas::drawImageRect(const SkImage* image, const SkRect* src, const SkRe ct& dst, 1741 void SkCanvas::drawImageRect(const SkImage* image, const SkRect* src, const SkRe ct& dst,
1742 const SkPaint* paint) { 1742 const SkPaint* paint) {
1743 if (dst.isEmpty()) {
1744 return;
1745 }
1746 this->onDrawImageRect(image, src, dst, paint); 1743 this->onDrawImageRect(image, src, dst, paint);
1747 } 1744 }
1748 1745
1749 void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy, cons t SkPaint* paint) { 1746 void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy, cons t SkPaint* paint) {
1750 if (bitmap.empty()) { 1747 if (bitmap.empty()) {
1751 return; 1748 return;
1752 } 1749 }
1753 this->onDrawBitmap(bitmap, dx, dy, paint); 1750 this->onDrawBitmap(bitmap, dx, dy, paint);
1754 } 1751 }
1755 1752
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 1952
1956 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, bounds) 1953 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, bounds)
1957 1954
1958 while (iter.next()) { 1955 while (iter.next()) {
1959 iter.fDevice->drawPath(iter, path, looper.paint()); 1956 iter.fDevice->drawPath(iter, path, looper.paint());
1960 } 1957 }
1961 1958
1962 LOOPER_END 1959 LOOPER_END
1963 } 1960 }
1964 1961
1965 void SkCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const S kPaint* paint) { 1962 void SkCanvas::onDrawImage(const SkImage* image, SkScalar dx, SkScalar dy, const SkPaint* paint) {
1966 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImage()"); 1963 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImage()");
1967 SkRect bounds = SkRect::MakeXYWH(x, y, 1964 image->draw(this, dx, dy, paint);
1968 SkIntToScalar(image->width()), SkIntToScala r(image->height()));
1969 if (NULL == paint || paint->canComputeFastBounds()) {
1970 if (paint) {
1971 paint->computeFastBounds(bounds, &bounds);
1972 }
1973 if (this->quickReject(bounds)) {
1974 return;
1975 }
1976 }
1977
1978 SkLazyPaint lazy;
1979 if (NULL == paint) {
1980 paint = lazy.init();
1981 }
1982
1983 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &bounds)
1984
1985 while (iter.next()) {
1986 iter.fDevice->drawImage(iter, image, x, y, looper.paint());
1987 }
1988
1989 LOOPER_END
1990 } 1965 }
1991 1966
1992 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk Rect& dst, 1967 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk Rect& dst,
1993 const SkPaint* paint) { 1968 const SkPaint* paint) {
1994 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()"); 1969 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()");
1995 SkRect storage; 1970 image->drawRect(this, src, dst, paint);
1996 const SkRect* bounds = &dst;
1997 if (NULL == paint || paint->canComputeFastBounds()) {
1998 if (paint) {
1999 bounds = &paint->computeFastBounds(dst, &storage);
2000 }
2001 if (this->quickReject(*bounds)) {
2002 return;
2003 }
2004 }
2005 SkLazyPaint lazy;
2006 if (NULL == paint) {
2007 paint = lazy.init();
2008 }
2009
2010 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, bounds)
2011
2012 while (iter.next()) {
2013 iter.fDevice->drawImageRect(iter, image, src, dst, looper.paint());
2014 }
2015
2016 LOOPER_END
2017 } 1971 }
2018 1972
2019 void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons t SkPaint* paint) { 1973 void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons t SkPaint* paint) {
2020 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmap()"); 1974 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmap()");
2021 SkDEBUGCODE(bitmap.validate();) 1975 SkDEBUGCODE(bitmap.validate();)
2022 1976
2023 if (NULL == paint || paint->canComputeFastBounds()) { 1977 if (NULL == paint || paint->canComputeFastBounds()) {
2024 SkRect bounds = { 1978 SkRect bounds = {
2025 x, y, 1979 x, y,
2026 x + SkIntToScalar(bitmap.width()), 1980 x + SkIntToScalar(bitmap.width()),
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
2687 } 2641 }
2688 2642
2689 if (matrix) { 2643 if (matrix) {
2690 canvas->concat(*matrix); 2644 canvas->concat(*matrix);
2691 } 2645 }
2692 } 2646 }
2693 2647
2694 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2648 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2695 fCanvas->restoreToCount(fSaveCount); 2649 fCanvas->restoreToCount(fSaveCount);
2696 } 2650 }
OLDNEW
« no previous file with comments | « include/utils/SkDeferredCanvas.h ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698