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 "GrBitmapTextContext.h" | 10 #include "GrBitmapTextContext.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 fNeedClear = flags & kNeedClear_Flag; | 153 fNeedClear = flags & kNeedClear_Flag; |
154 | 154 |
155 fRenderTarget = SkRef(rt); | 155 fRenderTarget = SkRef(rt); |
156 | 156 |
157 SkImageInfo info = rt->surfacePriv().info(); | 157 SkImageInfo info = rt->surfacePriv().info(); |
158 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, rt)); | 158 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, rt)); |
159 fLegacyBitmap.setInfo(info); | 159 fLegacyBitmap.setInfo(info); |
160 fLegacyBitmap.setPixelRef(pr)->unref(); | 160 fLegacyBitmap.setPixelRef(pr)->unref(); |
161 | 161 |
162 bool useDFT = fSurfaceProps.isUseDistanceFieldFonts(); | 162 bool useDFT = fSurfaceProps.isUseDistanceFieldFonts(); |
163 fTextContext = fContext->createTextContext(fRenderTarget, this->getLeakyProp
erties(), useDFT); | 163 fTextContext = fContext->createTextContext(fRenderTarget, this, this->getLea
kyProperties(), |
| 164 useDFT); |
164 } | 165 } |
165 | 166 |
166 GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkSurface::B
udgeted budgeted, | 167 GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkSurface::B
udgeted budgeted, |
167 const SkImageInfo& origInfo, int
sampleCount) { | 168 const SkImageInfo& origInfo, int
sampleCount) { |
168 if (kUnknown_SkColorType == origInfo.colorType() || | 169 if (kUnknown_SkColorType == origInfo.colorType() || |
169 origInfo.width() < 0 || origInfo.height() < 0) { | 170 origInfo.width() < 0 || origInfo.height() < 0) { |
170 return NULL; | 171 return NULL; |
171 } | 172 } |
172 | 173 |
173 if (!context) { | 174 if (!context) { |
(...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1817 size_t byteLength, SkScalar x, SkScalar y, | 1818 size_t byteLength, SkScalar x, SkScalar y, |
1818 const SkPaint& paint) { | 1819 const SkPaint& paint) { |
1819 CHECK_SHOULD_DRAW(draw); | 1820 CHECK_SHOULD_DRAW(draw); |
1820 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext); | 1821 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext); |
1821 | 1822 |
1822 GrPaint grPaint; | 1823 GrPaint grPaint; |
1823 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); | 1824 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); |
1824 | 1825 |
1825 SkDEBUGCODE(this->validate();) | 1826 SkDEBUGCODE(this->validate();) |
1826 | 1827 |
1827 if (!fTextContext->drawText(fRenderTarget, fClip, grPaint, paint, *draw.fMat
rix, | 1828 fTextContext->drawText(fRenderTarget, fClip, grPaint, paint, *draw.fMatrix, |
1828 (const char *)text, byteLength, x, y)) { | 1829 (const char *)text, byteLength, x, y, draw.fClip->get
Bounds()); |
1829 // this will just call our drawPath() | |
1830 draw.drawText_asPaths((const char*)text, byteLength, x, y, paint); | |
1831 } | |
1832 } | 1830 } |
1833 | 1831 |
1834 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
ength, | 1832 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
ength, |
1835 const SkScalar pos[], int scalarsPerPos, | 1833 const SkScalar pos[], int scalarsPerPos, |
1836 const SkPoint& offset, const SkPaint& paint) { | 1834 const SkPoint& offset, const SkPaint& paint) { |
1837 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPosText", fContext); | 1835 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPosText", fContext); |
1838 CHECK_SHOULD_DRAW(draw); | 1836 CHECK_SHOULD_DRAW(draw); |
1839 | 1837 |
1840 GrPaint grPaint; | 1838 GrPaint grPaint; |
1841 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); | 1839 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); |
1842 | 1840 |
1843 SkDEBUGCODE(this->validate();) | 1841 SkDEBUGCODE(this->validate();) |
1844 | 1842 |
1845 if (!fTextContext->drawPosText(fRenderTarget, fClip, grPaint, paint, *draw.f
Matrix, | 1843 fTextContext->drawPosText(fRenderTarget, fClip, grPaint, paint, *draw.fMatri
x, |
1846 (const char *)text, byteLength, pos, scalarsP
erPos, offset)) { | 1844 (const char *)text, byteLength, pos, scalarsPerPos
, offset, |
1847 // this will just call our drawPath() | 1845 draw.fClip->getBounds()); |
1848 draw.drawPosText_asPaths((const char*)text, byteLength, pos, scalarsPerP
os, offset, paint); | |
1849 } | |
1850 } | 1846 } |
1851 | 1847 |
1852 /////////////////////////////////////////////////////////////////////////////// | 1848 /////////////////////////////////////////////////////////////////////////////// |
1853 | 1849 |
1854 bool SkGpuDevice::onShouldDisableLCD(const SkPaint& paint) const { | 1850 bool SkGpuDevice::onShouldDisableLCD(const SkPaint& paint) const { |
1855 if (paint.getShader() || | 1851 if (paint.getShader() || |
1856 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode) || | 1852 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode) || |
1857 paint.getMaskFilter() || | 1853 paint.getMaskFilter() || |
1858 paint.getRasterizer() || | 1854 paint.getRasterizer() || |
1859 paint.getColorFilter() || | 1855 paint.getColorFilter() || |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1976 #endif | 1972 #endif |
1977 } | 1973 } |
1978 | 1974 |
1979 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1975 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1980 // We always return a transient cache, so it is freed after each | 1976 // We always return a transient cache, so it is freed after each |
1981 // filter traversal. | 1977 // filter traversal. |
1982 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1978 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1983 } | 1979 } |
1984 | 1980 |
1985 #endif | 1981 #endif |
OLD | NEW |