From c6cb56f36c4aad8ed45486a3bb4de614bb822f1b Mon Sep 17 00:00:00 2001 From: kkinnunen Date: Tue, 24 Jun 2014 00:12:27 -0700 Subject: Implement text rendering with NVPR Use path rendering to render the text from outlines if supported by the GPU. Implement this in GrStencilAndCoverTextContext by copying chunks of code from GrBitmapTextContext. The drawing is implemented with "instanced" path drawing functions. Moves the creation of the "main" text context from SkGpuDevice to the GrContext::createTextContext. This is done because the decision of which text renderer is optimal can be made only with the internal implementation-specific information of the context. Remove a windows assertion from SkScalerContext_GDI::getGDIGlyphPath. The GetGlyphOutlineW fails in fontmgr_match for the initial space char in the string " [700] ...". According to MSDN, this is a known problem. Just return that the glyph has no path data in these cases. R=jvanverth@google.com, bsalomon@google.com, mtklein@google.com Author: kkinnunen@nvidia.com Review URL: https://codereview.chromium.org/196133014 --- src/gpu/GrContext.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) mode change 100644 => 100755 src/gpu/GrContext.cpp (limited to 'src/gpu/GrContext.cpp') diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp old mode 100644 new mode 100755 index 6c90c178d3..d59d2e8d40 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -16,6 +16,7 @@ #include "GrAARectRenderer.h" #include "GrBufferAllocPool.h" #include "GrGpu.h" +#include "GrDistanceFieldTextContext.h" #include "GrDrawTargetCaps.h" #include "GrIndexBuffer.h" #include "GrInOrderDrawBuffer.h" @@ -26,6 +27,7 @@ #include "GrResourceCache.h" #include "GrSoftwarePathRenderer.h" #include "GrStencilBuffer.h" +#include "GrStencilAndCoverTextContext.h" #include "GrStrokeInfo.h" #include "GrTextStrike.h" #include "GrTraceMarker.h" @@ -236,6 +238,19 @@ void GrContext::getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) } } +GrTextContext* GrContext::createTextContext(GrRenderTarget* renderTarget, + const SkDeviceProperties& + leakyProperties, + bool enableDistanceFieldFonts) { + if (fGpu->caps()->pathRenderingSupport()) { + if (renderTarget->getStencilBuffer() && renderTarget->isMultisampled()) { + return SkNEW_ARGS(GrStencilAndCoverTextContext, (this, leakyProperties)); + } + } + return SkNEW_ARGS(GrDistanceFieldTextContext, (this, leakyProperties, + enableDistanceFieldFonts)); +} + //////////////////////////////////////////////////////////////////////////////// GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc, -- cgit v1.2.3