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

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

Issue 41213003: Hook in rough distance field support for fonts (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Replace magic number 32 with constant; fix comment in shader; fix Linux compiler error. Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrTextStrike_impl.h ('k') | src/gpu/effects/GrDistanceFieldTextureEffect.h » ('j') | 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/GrTextureDomainEffect.h" 10 #include "effects/GrTextureDomainEffect.h"
11 #include "effects/GrSimpleTextureEffect.h" 11 #include "effects/GrSimpleTextureEffect.h"
12 12
13 #include "GrContext.h" 13 #include "GrContext.h"
14 #include "GrBitmapTextContext.h" 14 #include "GrBitmapTextContext.h"
15 #if SK_DISTANCEFIELD_FONTS
16 #include "GrDistanceFieldTextContext.h"
17 #endif
15 18
16 #include "SkGrTexturePixelRef.h" 19 #include "SkGrTexturePixelRef.h"
17 20
18 #include "SkColorFilter.h" 21 #include "SkColorFilter.h"
19 #include "SkDeviceImageFilterProxy.h" 22 #include "SkDeviceImageFilterProxy.h"
20 #include "SkDrawProcs.h" 23 #include "SkDrawProcs.h"
21 #include "SkGlyphCache.h" 24 #include "SkGlyphCache.h"
22 #include "SkImageFilter.h" 25 #include "SkImageFilter.h"
23 #include "SkPathEffect.h" 26 #include "SkPathEffect.h"
24 #include "SkRRect.h" 27 #include "SkRRect.h"
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 procs->fFontScaler); 1715 procs->fFontScaler);
1713 } 1716 }
1714 1717
1715 SkDrawProcs* SkGpuDevice::initDrawForText(GrTextContext* context) { 1718 SkDrawProcs* SkGpuDevice::initDrawForText(GrTextContext* context) {
1716 1719
1717 // deferred allocation 1720 // deferred allocation
1718 if (NULL == fDrawProcs) { 1721 if (NULL == fDrawProcs) {
1719 fDrawProcs = SkNEW(GrSkDrawProcs); 1722 fDrawProcs = SkNEW(GrSkDrawProcs);
1720 fDrawProcs->fD1GProc = SkGPU_Draw1Glyph; 1723 fDrawProcs->fD1GProc = SkGPU_Draw1Glyph;
1721 fDrawProcs->fContext = fContext; 1724 fDrawProcs->fContext = fContext;
1725 #if SK_DISTANCEFIELD_FONTS
1726 fDrawProcs->fFlags = 0;
1727 fDrawProcs->fFlags |= SkDrawProcs::kSkipBakedGlyphTransform_Flag;
1728 fDrawProcs->fFlags |= SkDrawProcs::kUseScaledGlyphs_Flag;
1729 #endif
1722 } 1730 }
1723 1731
1724 // init our (and GL's) state 1732 // init our (and GL's) state
1725 fDrawProcs->fTextContext = context; 1733 fDrawProcs->fTextContext = context;
1726 fDrawProcs->fFontScaler = NULL; 1734 fDrawProcs->fFontScaler = NULL;
1727 return fDrawProcs; 1735 return fDrawProcs;
1728 } 1736 }
1729 1737
1730 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, 1738 void SkGpuDevice::drawText(const SkDraw& draw, const void* text,
1731 size_t byteLength, SkScalar x, SkScalar y, 1739 size_t byteLength, SkScalar x, SkScalar y,
1732 const SkPaint& paint) { 1740 const SkPaint& paint) {
1733 CHECK_SHOULD_DRAW(draw, false); 1741 CHECK_SHOULD_DRAW(draw, false);
1734 1742
1735 if (fContext->getMatrix().hasPerspective()) { 1743 if (fContext->getMatrix().hasPerspective()) {
1736 // this guy will just call our drawPath() 1744 // this guy will just call our drawPath()
1737 draw.drawText((const char*)text, byteLength, x, y, paint); 1745 draw.drawText((const char*)text, byteLength, x, y, paint);
1738 } else { 1746 } else {
1739 SkDraw myDraw(draw); 1747 SkDraw myDraw(draw);
1740 1748
1741 GrPaint grPaint; 1749 GrPaint grPaint;
1742 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { 1750 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) {
1743 return; 1751 return;
1744 } 1752 }
1745 1753 #if SK_DISTANCEFIELD_FONTS
1754 GrDistanceFieldTextContext context(fContext, grPaint, paint.getColor(),
1755 paint.getTextSize()/SkDrawProcs::kBas eDFFontSize);
1756 #else
1746 GrBitmapTextContext context(fContext, grPaint, paint.getColor()); 1757 GrBitmapTextContext context(fContext, grPaint, paint.getColor());
1758 #endif
1747 myDraw.fProcs = this->initDrawForText(&context); 1759 myDraw.fProcs = this->initDrawForText(&context);
1748 this->INHERITED::drawText(myDraw, text, byteLength, x, y, paint); 1760 this->INHERITED::drawText(myDraw, text, byteLength, x, y, paint);
1749 } 1761 }
1750 } 1762 }
1751 1763
1752 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, 1764 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text,
1753 size_t byteLength, const SkScalar pos[], 1765 size_t byteLength, const SkScalar pos[],
1754 SkScalar constY, int scalarsPerPos, 1766 SkScalar constY, int scalarsPerPos,
1755 const SkPaint& paint) { 1767 const SkPaint& paint) {
1756 CHECK_SHOULD_DRAW(draw, false); 1768 CHECK_SHOULD_DRAW(draw, false);
1757 1769
1758 if (fContext->getMatrix().hasPerspective()) { 1770 if (fContext->getMatrix().hasPerspective()) {
1759 // this guy will just call our drawPath() 1771 // this guy will just call our drawPath()
1760 draw.drawPosText((const char*)text, byteLength, pos, constY, 1772 draw.drawPosText((const char*)text, byteLength, pos, constY,
1761 scalarsPerPos, paint); 1773 scalarsPerPos, paint);
1762 } else { 1774 } else {
1763 SkDraw myDraw(draw); 1775 SkDraw myDraw(draw);
1764 1776
1765 GrPaint grPaint; 1777 GrPaint grPaint;
1766 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { 1778 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) {
1767 return; 1779 return;
1768 } 1780 }
1781 #if SK_DISTANCEFIELD_FONTS
1782 GrDistanceFieldTextContext context(fContext, grPaint, paint.getColor(),
1783 paint.getTextSize());
1784 #else
1769 GrBitmapTextContext context(fContext, grPaint, paint.getColor()); 1785 GrBitmapTextContext context(fContext, grPaint, paint.getColor());
1786 #endif
1770 myDraw.fProcs = this->initDrawForText(&context); 1787 myDraw.fProcs = this->initDrawForText(&context);
1771 this->INHERITED::drawPosText(myDraw, text, byteLength, pos, constY, 1788 this->INHERITED::drawPosText(myDraw, text, byteLength, pos, constY,
1772 scalarsPerPos, paint); 1789 scalarsPerPos, paint);
1773 } 1790 }
1774 } 1791 }
1775 1792
1776 void SkGpuDevice::drawTextOnPath(const SkDraw& draw, const void* text, 1793 void SkGpuDevice::drawTextOnPath(const SkDraw& draw, const void* text,
1777 size_t len, const SkPath& path, 1794 size_t len, const SkPath& path,
1778 const SkMatrix* m, const SkPaint& paint) { 1795 const SkMatrix* m, const SkPaint& paint) {
1779 CHECK_SHOULD_DRAW(draw, false); 1796 CHECK_SHOULD_DRAW(draw, false);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1851 GrTexture* texture, 1868 GrTexture* texture,
1852 bool needClear) 1869 bool needClear)
1853 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { 1870 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) {
1854 1871
1855 SkASSERT(texture && texture->asRenderTarget()); 1872 SkASSERT(texture && texture->asRenderTarget());
1856 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture 1873 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture
1857 // cache. We pass true for the third argument so that it will get unlocked. 1874 // cache. We pass true for the third argument so that it will get unlocked.
1858 this->initFromRenderTarget(context, texture->asRenderTarget(), true); 1875 this->initFromRenderTarget(context, texture->asRenderTarget(), true);
1859 fNeedClear = needClear; 1876 fNeedClear = needClear;
1860 } 1877 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextStrike_impl.h ('k') | src/gpu/effects/GrDistanceFieldTextureEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698