diff options
author | jvanverth <jvanverth@google.com> | 2014-11-06 13:38:52 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-06 13:38:52 -0800 |
commit | 06ba179838ba4fe187cf290750aeeb4a02a2960b (patch) | |
tree | 1e77099a7fe0905ee476d5934ab57d1e71a76f73 /src | |
parent | 2c93efeb6f2dd652eb2575c04124d82952f020c7 (diff) |
Get gpudft support working in dm, gm, nanobench and bench_pictures
Adds a new config to test distance field text.
Clean up some flags and #defines to read "distance field text",
not "distance field fonts" to be consistent with Chromium
NOTREECHECKS=true
Review URL: https://codereview.chromium.org/699453005
Diffstat (limited to 'src')
-rwxr-xr-x | src/gpu/GrDistanceFieldTextContext.cpp | 2 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 14 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.h | 6 | ||||
-rw-r--r-- | src/image/SkSurface_Gpu.cpp | 2 |
4 files changed, 13 insertions, 11 deletions
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp index 1976cf16a3..58c8121cd9 100755 --- a/src/gpu/GrDistanceFieldTextContext.cpp +++ b/src/gpu/GrDistanceFieldTextContext.cpp @@ -64,7 +64,7 @@ GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context, const SkDeviceProperties& properties, bool enable) : GrTextContext(context, properties) { -#if SK_FORCE_DISTANCEFIELD_FONTS +#if SK_FORCE_DISTANCE_FIELD_TEXT fEnableDFRendering = true; #else fEnableDFRendering = enable; diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index da81c696d2..96c071473c 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -67,7 +67,7 @@ enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 }; #define DO_DEFERRED_CLEAR() \ do { \ - if (fNeedClear) { \ + if (fFlags & kNeedClear_Flag) { \ this->clear(SK_ColorTRANSPARENT); \ } \ } while (false) \ @@ -137,7 +137,7 @@ SkGpuDevice::SkGpuDevice(GrSurface* surface, const SkSurfaceProps& props, unsign fContext = SkRef(surface->getContext()); - fNeedClear = flags & kNeedClear_Flag; + fFlags = flags; fRenderTarget = SkRef(surface->asRenderTarget()); @@ -148,8 +148,8 @@ SkGpuDevice::SkGpuDevice(GrSurface* surface, const SkSurfaceProps& props, unsign this->setPixelGeometry(props.pixelGeometry()); - bool useDFFonts = !!(flags & kDFFonts_Flag); - fTextContext = fContext->createTextContext(fRenderTarget, this->getLeakyProperties(), useDFFonts); + bool useDFT = SkToBool(flags & kDFText_Flag); + fTextContext = fContext->createTextContext(fRenderTarget, this->getLeakyProperties(), useDFT); } SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo, @@ -310,7 +310,7 @@ void SkGpuDevice::clear(SkColor color) { GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::clear", fContext); SkIRect rect = SkIRect::MakeWH(this->width(), this->height()); fContext->clear(&rect, SkColor2GrColor(color), true, fRenderTarget); - fNeedClear = false; + fFlags &= ~kNeedClear_Flag; } void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { @@ -1473,7 +1473,7 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, // clear of the source device must occur before CHECK_SHOULD_DRAW GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawDevice", fContext); SkGpuDevice* dev = static_cast<SkGpuDevice*>(device); - if (dev->fNeedClear) { + if (dev->fFlags & kNeedClear_Flag) { // TODO: could check here whether we really need to draw at all dev->clear(0x0); } @@ -1763,6 +1763,8 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const SkImageInfo& info, Usage usage) SkAutoTUnref<GrTexture> texture; // Skia's convention is to only clear a device if it is non-opaque. unsigned flags = info.isOpaque() ? 0 : kNeedClear_Flag; + // If we're using distance field text, enable in the new device + flags |= (fFlags & kDFText_Flag) ? kDFText_Flag : 0; #if CACHE_COMPATIBLE_DEVICE_TEXTURES // layers are never draw in repeat modes, so we can request an approx diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h index 6a68eeb33e..6bba97434a 100644 --- a/src/gpu/SkGpuDevice.h +++ b/src/gpu/SkGpuDevice.h @@ -34,7 +34,7 @@ class SK_API SkGpuDevice : public SkBaseDevice { public: enum Flags { kNeedClear_Flag = 1 << 0, //!< Surface requires an initial clear - kDFFonts_Flag = 1 << 1, //!< Surface should render fonts using signed distance fields + kDFText_Flag = 1 << 1, //!< Surface should render text using signed distance fields }; /** @@ -136,8 +136,8 @@ private: GrTextContext* fTextContext; // state for our render-target - GrRenderTarget* fRenderTarget; - bool fNeedClear; + GrRenderTarget* fRenderTarget; + uint32_t fFlags; // remove when our clients don't rely on accessBitmap() SkBitmap fLegacyBitmap; diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index 3e1eb9452b..1555c9a7a8 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -39,7 +39,7 @@ SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget, const SkSurfaceProps* bool doClear) : INHERITED(renderTarget->width(), renderTarget->height(), props) { int deviceFlags = 0; - deviceFlags |= this->props().isUseDistanceFieldFonts() ? SkGpuDevice::kDFFonts_Flag : 0; + deviceFlags |= this->props().isUseDistanceFieldFonts() ? SkGpuDevice::kDFText_Flag : 0; fDevice = SkGpuDevice::Create(renderTarget, this->props(), deviceFlags); if (kRGB_565_GrPixelConfig != renderTarget->config() && doClear) { |