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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkCanvasPriv.h" | 9 #include "SkCanvasPriv.h" |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
(...skipping 2428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2439 | 2439 |
2440 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL) | 2440 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL) |
2441 | 2441 |
2442 while (iter.next()) { | 2442 while (iter.next()) { |
2443 iter.fDevice->drawPatch(iter, cubics, colors, texCoords, xmode, paint); | 2443 iter.fDevice->drawPatch(iter, cubics, colors, texCoords, xmode, paint); |
2444 } | 2444 } |
2445 | 2445 |
2446 LOOPER_END | 2446 LOOPER_END |
2447 } | 2447 } |
2448 | 2448 |
2449 void SkCanvas::drawDrawable(SkDrawable* dr) { | 2449 void SkCanvas::drawDrawable(SkDrawable* dr, SkScalar x, SkScalar y) { |
2450 if (dr && !this->quickReject(dr->getBounds())) { | 2450 if (dr) { |
2451 this->onDrawDrawable(dr); | 2451 if (x || y) { |
| 2452 SkMatrix matrix = SkMatrix::MakeTrans(x, y); |
| 2453 this->onDrawDrawable(dr, &matrix); |
| 2454 } else { |
| 2455 this->onDrawDrawable(dr, NULL); |
| 2456 } |
2452 } | 2457 } |
2453 } | 2458 } |
2454 | 2459 |
2455 void SkCanvas::onDrawDrawable(SkDrawable* dr) { | 2460 void SkCanvas::drawDrawable(SkDrawable* dr, const SkMatrix* matrix) { |
2456 dr->draw(this); | 2461 if (dr) { |
| 2462 if (matrix && matrix->isIdentity()) { |
| 2463 matrix = NULL; |
| 2464 } |
| 2465 this->onDrawDrawable(dr, matrix); |
| 2466 } |
| 2467 } |
| 2468 |
| 2469 void SkCanvas::onDrawDrawable(SkDrawable* dr, const SkMatrix* matrix) { |
| 2470 SkRect bounds = dr->getBounds(); |
| 2471 if (matrix) { |
| 2472 matrix->mapRect(&bounds); |
| 2473 } |
| 2474 if (this->quickReject(bounds)) { |
| 2475 return; |
| 2476 } |
| 2477 dr->draw(this, matrix); |
2457 } | 2478 } |
2458 | 2479 |
2459 void SkCanvas::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const
SkRect tex[], | 2480 void SkCanvas::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const
SkRect tex[], |
2460 const SkColor colors[], int count, SkXfermode::Mode m
ode, | 2481 const SkColor colors[], int count, SkXfermode::Mode m
ode, |
2461 const SkRect* cull, const SkPaint* paint) { | 2482 const SkRect* cull, const SkPaint* paint) { |
2462 if (cull && this->quickReject(*cull)) { | 2483 if (cull && this->quickReject(*cull)) { |
2463 return; | 2484 return; |
2464 } | 2485 } |
2465 | 2486 |
2466 SkPaint pnt; | 2487 SkPaint pnt; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2738 } | 2759 } |
2739 | 2760 |
2740 if (matrix) { | 2761 if (matrix) { |
2741 canvas->concat(*matrix); | 2762 canvas->concat(*matrix); |
2742 } | 2763 } |
2743 } | 2764 } |
2744 | 2765 |
2745 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2766 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
2746 fCanvas->restoreToCount(fSaveCount); | 2767 fCanvas->restoreToCount(fSaveCount); |
2747 } | 2768 } |
OLD | NEW |