Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: src/gpu/SkGpuDevice.cpp

Issue 650273003: Change GrTextContext fallbacks to be a linked list chain. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/gpu/GrTextContext.cpp ('K') | « src/gpu/SkGpuDevice.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 fRenderTarget = SkRef(surface->asRenderTarget()); 140 fRenderTarget = SkRef(surface->asRenderTarget());
141 141
142 SkImageInfo info = surface->surfacePriv().info(); 142 SkImageInfo info = surface->surfacePriv().info();
143 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, surface)); 143 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, surface));
144 fLegacyBitmap.setInfo(info); 144 fLegacyBitmap.setInfo(info);
145 fLegacyBitmap.setPixelRef(pr)->unref(); 145 fLegacyBitmap.setPixelRef(pr)->unref();
146 146
147 this->setPixelGeometry(props.pixelGeometry()); 147 this->setPixelGeometry(props.pixelGeometry());
148 148
149 bool useDFFonts = !!(flags & kDFFonts_Flag); 149 bool useDFFonts = !!(flags & kDFFonts_Flag);
150 fMainTextContext = fContext->createTextContext(fRenderTarget, this->getLeaky Properties(), useDFFonts); 150 fTextContext = fContext->createTextContext(fRenderTarget, this->getLeakyProp erties(), useDFFonts);
151 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, this->getL eakyProperties()));
152 } 151 }
153 152
154 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo , 153 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo ,
155 const SkSurfaceProps& props, int sampleCount) { 154 const SkSurfaceProps& props, int sampleCount) {
156 if (kUnknown_SkColorType == origInfo.colorType() || 155 if (kUnknown_SkColorType == origInfo.colorType() ||
157 origInfo.width() < 0 || origInfo.height() < 0) { 156 origInfo.width() < 0 || origInfo.height() < 0) {
158 return NULL; 157 return NULL;
159 } 158 }
160 159
161 SkColorType ct = origInfo.colorType(); 160 SkColorType ct = origInfo.colorType();
(...skipping 23 matching lines...) Expand all
185 } 184 }
186 185
187 return SkNEW_ARGS(SkGpuDevice, (texture.get(), props)); 186 return SkNEW_ARGS(SkGpuDevice, (texture.get(), props));
188 } 187 }
189 188
190 SkGpuDevice::~SkGpuDevice() { 189 SkGpuDevice::~SkGpuDevice() {
191 if (fDrawProcs) { 190 if (fDrawProcs) {
192 delete fDrawProcs; 191 delete fDrawProcs;
193 } 192 }
194 193
195 delete fMainTextContext; 194 delete fTextContext;
196 delete fFallbackTextContext;
197 195
198 // The GrContext takes a ref on the target. We don't want to cause the rende r 196 // The GrContext takes a ref on the target. We don't want to cause the rende r
199 // target to be unnecessarily kept alive. 197 // target to be unnecessarily kept alive.
200 if (fContext->getRenderTarget() == fRenderTarget) { 198 if (fContext->getRenderTarget() == fRenderTarget) {
201 fContext->setRenderTarget(NULL); 199 fContext->setRenderTarget(NULL);
202 } 200 }
203 201
204 if (fContext->getClip() == &fClipData) { 202 if (fContext->getClip() == &fClipData) {
205 fContext->setClip(NULL); 203 fContext->setClip(NULL);
206 } 204 }
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 } 1676 }
1679 1677
1680 /////////////////////////////////////////////////////////////////////////////// 1678 ///////////////////////////////////////////////////////////////////////////////
1681 1679
1682 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, 1680 void SkGpuDevice::drawText(const SkDraw& draw, const void* text,
1683 size_t byteLength, SkScalar x, SkScalar y, 1681 size_t byteLength, SkScalar x, SkScalar y,
1684 const SkPaint& paint) { 1682 const SkPaint& paint) {
1685 CHECK_SHOULD_DRAW(draw, false); 1683 CHECK_SHOULD_DRAW(draw, false);
1686 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext); 1684 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext);
1687 1685
1688 if (fMainTextContext->canDraw(paint)) { 1686 GrTextContext* textContext = fTextContext;
1689 GrPaint grPaint; 1687 do {
1690 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); 1688 if (textContext->canDraw(paint)) {
1689 GrPaint grPaint;
1690 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
1691 1691
1692 SkDEBUGCODE(this->validate();) 1692 SkDEBUGCODE(this->validate();)
1693 1693
1694 fMainTextContext->drawText(grPaint, paint, (const char *)text, byteLengt h, x, y); 1694 textContext->drawText(grPaint, paint, (const char *)text, byteLength , x, y);
1695 } else if (fFallbackTextContext && fFallbackTextContext->canDraw(paint)) { 1695 return;
1696 GrPaint grPaint; 1696 }
1697 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); 1697 textContext = textContext->getFallbackTextContext();
bsalomon 2014/10/13 18:46:36 Would it make sense for this to just happen within
jvanverth1 2014/10/13 18:54:48 I thought of that, but you'd have to call canDraw(
bsalomon 2014/10/13 19:01:44 I'm not sure I see why... GrTextContext::drawTex
jvanverth1 2014/10/13 19:06:18 Got it. And GrTextContext::drawText can return fal
1698 } while (textContext);
1698 1699
1699 SkDEBUGCODE(this->validate();) 1700 // this will just call our drawPath()
1700 1701 draw.drawText_asPaths((const char*)text, byteLength, x, y, paint);
1701 fFallbackTextContext->drawText(grPaint, paint, (const char *)text, byteL ength, x, y);
1702 } else {
1703 // this guy will just call our drawPath()
1704 draw.drawText_asPaths((const char*)text, byteLength, x, y, paint);
1705 }
1706 } 1702 }
1707 1703
1708 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL ength, 1704 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL ength,
1709 const SkScalar pos[], int scalarsPerPos, 1705 const SkScalar pos[], int scalarsPerPos,
1710 const SkPoint& offset, const SkPaint& paint) { 1706 const SkPoint& offset, const SkPaint& paint) {
1711 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPosText", fContext); 1707 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPosText", fContext);
1712 CHECK_SHOULD_DRAW(draw, false); 1708 CHECK_SHOULD_DRAW(draw, false);
1713 1709
1714 if (fMainTextContext->canDraw(paint)) { 1710 GrTextContext* textContext = fTextContext;
1715 GrPaint grPaint; 1711 do {
1716 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); 1712 if (textContext->canDraw(paint)) {
1713 GrPaint grPaint;
1714 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
1717 1715
1718 SkDEBUGCODE(this->validate();) 1716 SkDEBUGCODE(this->validate();)
1719 1717
1720 fMainTextContext->drawPosText(grPaint, paint, (const char *)text, byteLe ngth, pos, 1718 textContext->drawPosText(grPaint, paint, (const char *)text, byteLen gth, pos,
1721 scalarsPerPos, offset); 1719 scalarsPerPos, offset);
1722 } else if (fFallbackTextContext && fFallbackTextContext->canDraw(paint)) { 1720 return;
1723 GrPaint grPaint; 1721 }
1724 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); 1722 textContext = textContext->getFallbackTextContext();
1723 } while (textContext);
1725 1724
1726 SkDEBUGCODE(this->validate();) 1725 draw.drawPosText_asPaths((const char*)text, byteLength, pos, scalarsPerPos, offset, paint);
1727
1728 fFallbackTextContext->drawPosText(grPaint, paint, (const char *)text, by teLength, pos,
1729 scalarsPerPos, offset);
1730 } else {
1731 draw.drawPosText_asPaths((const char*)text, byteLength, pos, scalarsPerP os, offset, paint);
1732 }
1733 } 1726 }
1734 1727
1735 void SkGpuDevice::drawTextOnPath(const SkDraw& draw, const void* text, 1728 void SkGpuDevice::drawTextOnPath(const SkDraw& draw, const void* text,
1736 size_t len, const SkPath& path, 1729 size_t len, const SkPath& path,
1737 const SkMatrix* m, const SkPaint& paint) { 1730 const SkMatrix* m, const SkPaint& paint) {
1738 CHECK_SHOULD_DRAW(draw, false); 1731 CHECK_SHOULD_DRAW(draw, false);
1739 1732
1740 SkASSERT(draw.fDevice == this); 1733 SkASSERT(draw.fDevice == this);
1741 draw.drawTextOnPath((const char*)text, len, path, m, paint); 1734 draw.drawTextOnPath((const char*)text, len, path, m, paint);
1742 } 1735 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 GrLayerHoister::UnlockLayers(fContext, atlased, nonAtlased, recycled); 1851 GrLayerHoister::UnlockLayers(fContext, atlased, nonAtlased, recycled);
1859 1852
1860 return true; 1853 return true;
1861 } 1854 }
1862 1855
1863 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1856 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1864 // We always return a transient cache, so it is freed after each 1857 // We always return a transient cache, so it is freed after each
1865 // filter traversal. 1858 // filter traversal.
1866 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 1859 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
1867 } 1860 }
OLDNEW
« src/gpu/GrTextContext.cpp ('K') | « src/gpu/SkGpuDevice.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698