OLD | NEW |
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 Loading... |
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 | |
1437 ///////////////////////////////////////////////////////////////////////////// | 1408 ///////////////////////////////////////////////////////////////////////////// |
| 1409 |
1438 void SkCanvas::translate(SkScalar dx, SkScalar dy) { | 1410 void SkCanvas::translate(SkScalar dx, SkScalar dy) { |
1439 SkMatrix m; | 1411 SkMatrix m; |
1440 m.setTranslate(dx, dy); | 1412 m.setTranslate(dx, dy); |
1441 this->concat(m); | 1413 this->concat(m); |
1442 } | 1414 } |
1443 | 1415 |
1444 void SkCanvas::scale(SkScalar sx, SkScalar sy) { | 1416 void SkCanvas::scale(SkScalar sx, SkScalar sy) { |
1445 SkMatrix m; | 1417 SkMatrix m; |
1446 m.setScale(sx, sy); | 1418 m.setScale(sx, sy); |
1447 this->concat(m); | 1419 this->concat(m); |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1970 const SkPaint* paint) { | 1942 const SkPaint* paint) { |
1971 if (bitmap.drawsNothing() || dst.isEmpty()) { | 1943 if (bitmap.drawsNothing() || dst.isEmpty()) { |
1972 return; | 1944 return; |
1973 } | 1945 } |
1974 if (!SkNinePatchIter::Valid(bitmap.width(), bitmap.height(), center)) { | 1946 if (!SkNinePatchIter::Valid(bitmap.width(), bitmap.height(), center)) { |
1975 this->drawBitmapRect(bitmap, dst, paint); | 1947 this->drawBitmapRect(bitmap, dst, paint); |
1976 } | 1948 } |
1977 this->onDrawBitmapNine(bitmap, center, dst, paint); | 1949 this->onDrawBitmapNine(bitmap, center, dst, paint); |
1978 } | 1950 } |
1979 | 1951 |
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 | |
1987 void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const Sk
Rect tex[], | 1952 void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const Sk
Rect tex[], |
1988 const SkColor colors[], int count, SkXfermode::Mode mod
e, | 1953 const SkColor colors[], int count, SkXfermode::Mode mod
e, |
1989 const SkRect* cull, const SkPaint* paint) { | 1954 const SkRect* cull, const SkPaint* paint) { |
1990 if (count <= 0) { | 1955 if (count <= 0) { |
1991 return; | 1956 return; |
1992 } | 1957 } |
1993 SkASSERT(atlas); | 1958 SkASSERT(atlas); |
1994 SkASSERT(xform); | 1959 SkASSERT(xform); |
1995 SkASSERT(tex); | 1960 SkASSERT(tex); |
1996 this->onDrawAtlas(atlas, xform, tex, colors, count, mode, cull, paint); | 1961 this->onDrawAtlas(atlas, xform, tex, colors, count, mode, cull, paint); |
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3013 } | 2978 } |
3014 | 2979 |
3015 if (matrix) { | 2980 if (matrix) { |
3016 canvas->concat(*matrix); | 2981 canvas->concat(*matrix); |
3017 } | 2982 } |
3018 } | 2983 } |
3019 | 2984 |
3020 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2985 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
3021 fCanvas->restoreToCount(fSaveCount); | 2986 fCanvas->restoreToCount(fSaveCount); |
3022 } | 2987 } |
OLD | NEW |