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

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

Issue 1529803004: Revert of remove drawSprite from canvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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/SkPaintFilterCanvas.h ('k') | src/core/SkPicturePlayback.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 "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkCanvasPriv.h" 10 #include "SkCanvasPriv.h"
(...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 } else if (deviceIsBitmapDevice) { 1398 } else if (deviceIsBitmapDevice) {
1399 const SkBitmap& src = static_cast<SkBitmapDevice*>(srcDev)->fBitmap; 1399 const SkBitmap& src = static_cast<SkBitmapDevice*>(srcDev)->fBitmap;
1400 dstDev->drawSprite(iter, src, pos.x(), pos.y(), *paint); 1400 dstDev->drawSprite(iter, src, pos.x(), pos.y(), *paint);
1401 } else { 1401 } else {
1402 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint); 1402 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint);
1403 } 1403 }
1404 } 1404 }
1405 LOOPER_END 1405 LOOPER_END
1406 } 1406 }
1407 1407
1408 void SkCanvas::onDrawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint* paint) {
1409 if (gTreatSpriteAsBitmap) {
1410 this->save();
1411 this->resetMatrix();
1412 this->drawBitmap(bitmap, SkIntToScalar(x), SkIntToScalar(y), paint);
1413 this->restore();
1414 return;
1415 }
1416
1417 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawSprite()");
1418 if (bitmap.drawsNothing()) {
1419 return;
1420 }
1421 SkDEBUGCODE(bitmap.validate();)
1422
1423 SkPaint tmp;
1424 if (nullptr == paint) {
1425 paint = &tmp;
1426 }
1427
1428 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type)
1429
1430 while (iter.next()) {
1431 const SkIPoint pos = { x - iter.getX(), y - iter.getY() };
1432 iter.fDevice->drawBitmapAsSprite(iter, bitmap, pos.x(), pos.y(), looper. paint());
1433 }
1434 LOOPER_END
1435 }
1436
1408 ///////////////////////////////////////////////////////////////////////////// 1437 /////////////////////////////////////////////////////////////////////////////
1409
1410 void SkCanvas::translate(SkScalar dx, SkScalar dy) { 1438 void SkCanvas::translate(SkScalar dx, SkScalar dy) {
1411 SkMatrix m; 1439 SkMatrix m;
1412 m.setTranslate(dx, dy); 1440 m.setTranslate(dx, dy);
1413 this->concat(m); 1441 this->concat(m);
1414 } 1442 }
1415 1443
1416 void SkCanvas::scale(SkScalar sx, SkScalar sy) { 1444 void SkCanvas::scale(SkScalar sx, SkScalar sy) {
1417 SkMatrix m; 1445 SkMatrix m;
1418 m.setScale(sx, sy); 1446 m.setScale(sx, sy);
1419 this->concat(m); 1447 this->concat(m);
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 const SkPaint* paint) { 1970 const SkPaint* paint) {
1943 if (bitmap.drawsNothing() || dst.isEmpty()) { 1971 if (bitmap.drawsNothing() || dst.isEmpty()) {
1944 return; 1972 return;
1945 } 1973 }
1946 if (!SkNinePatchIter::Valid(bitmap.width(), bitmap.height(), center)) { 1974 if (!SkNinePatchIter::Valid(bitmap.width(), bitmap.height(), center)) {
1947 this->drawBitmapRect(bitmap, dst, paint); 1975 this->drawBitmapRect(bitmap, dst, paint);
1948 } 1976 }
1949 this->onDrawBitmapNine(bitmap, center, dst, paint); 1977 this->onDrawBitmapNine(bitmap, center, dst, paint);
1950 } 1978 }
1951 1979
1980 void SkCanvas::drawSprite(const SkBitmap& bitmap, int left, int top, const SkPai nt* paint) {
1981 if (bitmap.drawsNothing()) {
1982 return;
1983 }
1984 this->onDrawSprite(bitmap, left, top, paint);
1985 }
1986
1952 void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const Sk Rect tex[], 1987 void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const Sk Rect tex[],
1953 const SkColor colors[], int count, SkXfermode::Mode mod e, 1988 const SkColor colors[], int count, SkXfermode::Mode mod e,
1954 const SkRect* cull, const SkPaint* paint) { 1989 const SkRect* cull, const SkPaint* paint) {
1955 if (count <= 0) { 1990 if (count <= 0) {
1956 return; 1991 return;
1957 } 1992 }
1958 SkASSERT(atlas); 1993 SkASSERT(atlas);
1959 SkASSERT(xform); 1994 SkASSERT(xform);
1960 SkASSERT(tex); 1995 SkASSERT(tex);
1961 this->onDrawAtlas(atlas, xform, tex, colors, count, mode, cull, paint); 1996 this->onDrawAtlas(atlas, xform, tex, colors, count, mode, cull, paint);
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
2978 } 3013 }
2979 3014
2980 if (matrix) { 3015 if (matrix) {
2981 canvas->concat(*matrix); 3016 canvas->concat(*matrix);
2982 } 3017 }
2983 } 3018 }
2984 3019
2985 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 3020 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2986 fCanvas->restoreToCount(fSaveCount); 3021 fCanvas->restoreToCount(fSaveCount);
2987 } 3022 }
OLDNEW
« no previous file with comments | « include/utils/SkPaintFilterCanvas.h ('k') | src/core/SkPicturePlayback.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698