| OLD | NEW | 
|     1 /* |     1 /* | 
|     2  * Copyright 2011 Google Inc. |     2  * Copyright 2011 Google Inc. | 
|     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 "SkGpuDevice.h" |     8 #include "SkGpuDevice.h" | 
|     9  |     9  | 
|    10 #include "effects/GrBicubicEffect.h" |    10 #include "effects/GrBicubicEffect.h" | 
| (...skipping 1753 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1764                            indexCount); |  1764                            indexCount); | 
|  1765 } |  1765 } | 
|  1766  |  1766  | 
|  1767 /////////////////////////////////////////////////////////////////////////////// |  1767 /////////////////////////////////////////////////////////////////////////////// | 
|  1768  |  1768  | 
|  1769 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, |  1769 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, | 
|  1770                           size_t byteLength, SkScalar x, SkScalar y, |  1770                           size_t byteLength, SkScalar x, SkScalar y, | 
|  1771                           const SkPaint& paint) { |  1771                           const SkPaint& paint) { | 
|  1772     CHECK_SHOULD_DRAW(draw, false); |  1772     CHECK_SHOULD_DRAW(draw, false); | 
|  1773  |  1773  | 
|  1774     if (SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix())) { |  1774     if (fTextContextManager->canDraw(paint, fContext->getMatrix())) { | 
|  1775         draw.drawText_asPaths((const char*)text, byteLength, x, y, paint); |  | 
|  1776     } else { |  | 
|  1777         GrPaint grPaint; |  1775         GrPaint grPaint; | 
|  1778         if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { |  1776         if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { | 
|  1779             return; |  1777             return; | 
|  1780         } |  1778         } | 
|  1781  |  1779  | 
|  1782         SkDEBUGCODE(this->validate();) |  1780         SkDEBUGCODE(this->validate();) | 
|  1783  |  1781  | 
|  1784         SkAutoTDelete<GrTextContext> ctx(fTextContextManager->create(this->conte
      xt(), |  1782         SkAutoTDelete<GrTextContext> ctx(fTextContextManager->create(this->conte
      xt(), | 
|  1785                                                                      grPaint, pa
      int, |  1783                                                                      grPaint, pa
      int, | 
|  1786                                                                      this->getDe
      viceProperties())); |  1784                                                                      this->getDe
      viceProperties())); | 
|  1787         ctx->drawText((const char *)text, byteLength, x, y); |  1785         ctx->drawText((const char *)text, byteLength, x, y); | 
 |  1786     } else if (GrBitmapTextContext::CanDraw(paint, fContext->getMatrix())) { | 
 |  1787         GrPaint grPaint; | 
 |  1788         if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { | 
 |  1789             return; | 
 |  1790         } | 
 |  1791  | 
 |  1792         SkDEBUGCODE(this->validate();) | 
 |  1793  | 
 |  1794         GrBitmapTextContext textContext(this->context(), grPaint, paint, | 
 |  1795                                         this->getDeviceProperties()); | 
 |  1796         textContext.drawText((const char *)text, byteLength, x, y); | 
 |  1797     } else { | 
 |  1798         // this guy will just call our drawPath() | 
 |  1799         draw.drawText_asPaths((const char*)text, byteLength, x, y, paint); | 
|  1788     } |  1800     } | 
|  1789 } |  1801 } | 
|  1790  |  1802  | 
|  1791 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, |  1803 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, | 
|  1792                              size_t byteLength, const SkScalar pos[], |  1804                              size_t byteLength, const SkScalar pos[], | 
|  1793                              SkScalar constY, int scalarsPerPos, |  1805                              SkScalar constY, int scalarsPerPos, | 
|  1794                              const SkPaint& paint) { |  1806                              const SkPaint& paint) { | 
|  1795     CHECK_SHOULD_DRAW(draw, false); |  1807     CHECK_SHOULD_DRAW(draw, false); | 
|  1796  |  1808  | 
|  1797     if (SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix())) { |  1809     if (fTextContextManager->canDraw(paint, fContext->getMatrix())) { | 
|  1798         // this guy will just call our drawPath() |  | 
|  1799         draw.drawPosText_asPaths((const char*)text, byteLength, pos, constY, |  | 
|  1800                          scalarsPerPos, paint); |  | 
|  1801     } else { |  | 
|  1802         GrPaint grPaint; |  1810         GrPaint grPaint; | 
|  1803         if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { |  1811         if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { | 
|  1804             return; |  1812             return; | 
|  1805         } |  1813         } | 
|  1806  |  1814  | 
|  1807         SkDEBUGCODE(this->validate();) |  1815         SkDEBUGCODE(this->validate();) | 
|  1808  |  1816  | 
|  1809         SkAutoTDelete<GrTextContext> ctx(fTextContextManager->create(this->conte
      xt(), |  1817         SkAutoTDelete<GrTextContext> ctx(fTextContextManager->create(this->conte
      xt(), | 
|  1810                                                                      grPaint, pa
      int, |  1818                                                                      grPaint, pa
      int, | 
|  1811                                                                      this->getDe
      viceProperties())); |  1819                                                                      this->getDe
      viceProperties())); | 
|  1812         ctx->drawPosText((const char *)text, byteLength, pos, constY, scalarsPer
      Pos); |  1820         ctx->drawPosText((const char *)text, byteLength, pos, constY, scalarsPer
      Pos); | 
 |  1821     } else if (GrBitmapTextContext::CanDraw(paint, fContext->getMatrix())) { | 
 |  1822         GrPaint grPaint; | 
 |  1823         if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { | 
 |  1824             return; | 
 |  1825         } | 
 |  1826          | 
 |  1827         SkDEBUGCODE(this->validate();) | 
 |  1828          | 
 |  1829         GrBitmapTextContext textContext(this->context(), grPaint, paint, | 
 |  1830                                         this->getDeviceProperties()); | 
 |  1831         textContext.drawPosText((const char *)text, byteLength, pos, constY, sca
      larsPerPos); | 
 |  1832     } else { | 
 |  1833         draw.drawPosText_asPaths((const char*)text, byteLength, pos, constY, | 
 |  1834                                  scalarsPerPos, paint); | 
|  1813     } |  1835     } | 
|  1814 } |  1836 } | 
|  1815  |  1837  | 
|  1816 void SkGpuDevice::drawTextOnPath(const SkDraw& draw, const void* text, |  1838 void SkGpuDevice::drawTextOnPath(const SkDraw& draw, const void* text, | 
|  1817                                 size_t len, const SkPath& path, |  1839                                 size_t len, const SkPath& path, | 
|  1818                                 const SkMatrix* m, const SkPaint& paint) { |  1840                                 const SkMatrix* m, const SkPaint& paint) { | 
|  1819     CHECK_SHOULD_DRAW(draw, false); |  1841     CHECK_SHOULD_DRAW(draw, false); | 
|  1820  |  1842  | 
|  1821     SkASSERT(draw.fDevice == this); |  1843     SkASSERT(draw.fDevice == this); | 
|  1822     draw.drawTextOnPath((const char*)text, len, path, m, paint); |  1844     draw.drawTextOnPath((const char*)text, len, path, m, paint); | 
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1891                          GrTexture* texture, |  1913                          GrTexture* texture, | 
|  1892                          bool needClear) |  1914                          bool needClear) | 
|  1893     : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { |  1915     : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { | 
|  1894  |  1916  | 
|  1895     SkASSERT(texture && texture->asRenderTarget()); |  1917     SkASSERT(texture && texture->asRenderTarget()); | 
|  1896     // This constructor is called from onCreateCompatibleDevice. It has locked t
      he RT in the texture |  1918     // This constructor is called from onCreateCompatibleDevice. It has locked t
      he RT in the texture | 
|  1897     // cache. We pass true for the third argument so that it will get unlocked. |  1919     // cache. We pass true for the third argument so that it will get unlocked. | 
|  1898     this->initFromRenderTarget(context, texture->asRenderTarget(), true); |  1920     this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 
|  1899     fNeedClear = needClear; |  1921     fNeedClear = needClear; | 
|  1900 } |  1922 } | 
| OLD | NEW |