Chromium Code Reviews| 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 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1794 this->onDrawBitmapNine(bitmap, center, dst, paint); | 1794 this->onDrawBitmapNine(bitmap, center, dst, paint); |
| 1795 } | 1795 } |
| 1796 | 1796 |
| 1797 void SkCanvas::drawSprite(const SkBitmap& bitmap, int left, int top, const SkPai nt* paint) { | 1797 void SkCanvas::drawSprite(const SkBitmap& bitmap, int left, int top, const SkPai nt* paint) { |
| 1798 if (bitmap.empty()) { | 1798 if (bitmap.empty()) { |
| 1799 return; | 1799 return; |
| 1800 } | 1800 } |
| 1801 this->onDrawSprite(bitmap, left, top, paint); | 1801 this->onDrawSprite(bitmap, left, top, paint); |
| 1802 } | 1802 } |
| 1803 | 1803 |
| 1804 #include "SkRSXform.h" | |
| 1805 void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const Sk Rect tex[], | |
| 1806 const SkColor colors[], int n, const SkRect* cull, cons t SkPaint* paint) { | |
| 1807 // this->drawImage(atlas, 0, 0, paint); | |
| 1808 | |
| 1809 SkPaint pnt; | |
| 1810 if (paint) { | |
| 1811 pnt = *paint; | |
| 1812 } | |
| 1813 // pnt.setStyle(SkPaint::kStroke_Style); | |
| 1814 | |
| 1815 SkPath path; | |
| 1816 for (int i = 0; i < n; ++i) { | |
| 1817 SkPoint quad[4]; | |
| 1818 xform[i].toQuad(tex[i].width(), tex[i].height(), quad); | |
| 1819 | |
| 1820 SkMatrix localM; | |
| 1821 localM.setRSXform(xform[i]); | |
| 1822 localM.preTranslate(-tex[i].left(), -tex[i].top()); | |
| 1823 | |
| 1824 pnt.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kCla mp_TileMode, | |
| 1825 &localM))->unref(); | |
| 1826 if (colors) { | |
| 1827 pnt.setColorFilter(SkColorFilter::CreateModeFilter(colors[i], | |
| 1828 SkXfermode::kModulat e_Mode))->unref(); | |
| 1829 } | |
| 1830 | |
| 1831 path.rewind(); | |
| 1832 path.addPoly(quad, 4, true); | |
| 1833 this->drawPath(path, pnt); | |
| 1834 } | |
| 1835 } | |
| 1836 | |
| 1804 ////////////////////////////////////////////////////////////////////////////// | 1837 ////////////////////////////////////////////////////////////////////////////// |
| 1805 // These are the virtual drawing methods | 1838 // These are the virtual drawing methods |
| 1806 ////////////////////////////////////////////////////////////////////////////// | 1839 ////////////////////////////////////////////////////////////////////////////// |
| 1807 | 1840 |
| 1808 void SkCanvas::onDiscard() { | 1841 void SkCanvas::onDiscard() { |
| 1809 if (fSurfaceBase) { | 1842 if (fSurfaceBase) { |
| 1810 fSurfaceBase->aboutToDraw(SkSurface::kDiscard_ContentChangeMode); | 1843 fSurfaceBase->aboutToDraw(SkSurface::kDiscard_ContentChangeMode); |
| 1811 } | 1844 } |
| 1812 } | 1845 } |
| 1813 | 1846 |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2442 void SkCanvas::drawDrawable(SkDrawable* dr) { | 2475 void SkCanvas::drawDrawable(SkDrawable* dr) { |
| 2443 if (dr && !this->quickReject(dr->getBounds())) { | 2476 if (dr && !this->quickReject(dr->getBounds())) { |
| 2444 this->onDrawDrawable(dr); | 2477 this->onDrawDrawable(dr); |
| 2445 } | 2478 } |
| 2446 } | 2479 } |
| 2447 | 2480 |
| 2448 void SkCanvas::onDrawDrawable(SkDrawable* dr) { | 2481 void SkCanvas::onDrawDrawable(SkDrawable* dr) { |
| 2449 dr->draw(this); | 2482 dr->draw(this); |
| 2450 } | 2483 } |
| 2451 | 2484 |
| 2485 void SkCanvas::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[], | |
|
mtklein
2015/06/15 20:55:18
Am I crazy or is this never called?
reed1
2015/06/15 20:59:17
I'm crazy. Will fix.
| |
| 2486 const SkColor colors[], int count, const SkRect* cull , | |
| 2487 const SkPaint* paint) { | |
| 2488 if (cull && this->quickReject(*cull)) { | |
| 2489 return; | |
| 2490 } | |
| 2491 | |
| 2492 SkPaint pnt; | |
| 2493 if (paint) { | |
| 2494 pnt = *paint; | |
| 2495 } | |
| 2496 | |
| 2497 LOOPER_BEGIN(pnt, SkDrawFilter::kPath_Type, NULL) | |
| 2498 while (iter.next()) { | |
| 2499 iter.fDevice->drawAtlas(iter, atlas, xform, tex, colors, count, pnt); | |
| 2500 } | |
| 2501 LOOPER_END | |
| 2502 } | |
| 2503 | |
| 2452 ////////////////////////////////////////////////////////////////////////////// | 2504 ////////////////////////////////////////////////////////////////////////////// |
| 2453 // These methods are NOT virtual, and therefore must call back into virtual | 2505 // These methods are NOT virtual, and therefore must call back into virtual |
| 2454 // methods, rather than actually drawing themselves. | 2506 // methods, rather than actually drawing themselves. |
| 2455 ////////////////////////////////////////////////////////////////////////////// | 2507 ////////////////////////////////////////////////////////////////////////////// |
| 2456 | 2508 |
| 2457 void SkCanvas::drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b, | 2509 void SkCanvas::drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b, |
| 2458 SkXfermode::Mode mode) { | 2510 SkXfermode::Mode mode) { |
| 2459 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawARGB()"); | 2511 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawARGB()"); |
| 2460 SkPaint paint; | 2512 SkPaint paint; |
| 2461 | 2513 |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2712 } | 2764 } |
| 2713 | 2765 |
| 2714 if (matrix) { | 2766 if (matrix) { |
| 2715 canvas->concat(*matrix); | 2767 canvas->concat(*matrix); |
| 2716 } | 2768 } |
| 2717 } | 2769 } |
| 2718 | 2770 |
| 2719 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2771 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 2720 fCanvas->restoreToCount(fSaveCount); | 2772 fCanvas->restoreToCount(fSaveCount); |
| 2721 } | 2773 } |
| OLD | NEW |