| Index: src/image/SkSurface_Gpu.cpp
|
| diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
|
| index f94dc5bd7002dc88a18b65b811702f2f5a992b20..a6dfd4e849168e348171ad65cb901e61cc4c5503 100644
|
| --- a/src/image/SkSurface_Gpu.cpp
|
| +++ b/src/image/SkSurface_Gpu.cpp
|
| @@ -14,8 +14,8 @@ class SkSurface_Gpu : public SkSurface_Base {
|
| public:
|
| SK_DECLARE_INST_COUNT(SkSurface_Gpu)
|
|
|
| - SkSurface_Gpu(GrRenderTarget*, bool cached, TextRenderMode trm,
|
| - SkSurface::RenderTargetFlags flags);
|
| + SkSurface_Gpu(GrRenderTarget*, bool cached, SkSurface::RenderTargetFlags flags,
|
| + const SkSurfaceProps&);
|
| virtual ~SkSurface_Gpu();
|
|
|
| virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
|
| @@ -34,15 +34,16 @@ private:
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| -SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget, bool cached, TextRenderMode trm,
|
| - SkSurface::RenderTargetFlags flags)
|
| - : INHERITED(renderTarget->width(), renderTarget->height()) {
|
| +SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget, bool cached, RenderTargetFlags flags,
|
| + const SkSurfaceProps& props)
|
| + : INHERITED(renderTarget->width(), renderTarget->height(), &props)
|
| +{
|
| int deviceFlags = 0;
|
| deviceFlags |= cached ? SkGpuDevice::kCached_Flag : 0;
|
| - deviceFlags |= (kDistanceField_TextRenderMode == trm) ? SkGpuDevice::kDFFonts_Flag : 0;
|
| - fDevice = SkGpuDevice::Create(renderTarget, deviceFlags);
|
| + deviceFlags |= props.useDistanceFieldFonts() ? SkGpuDevice::kDFFonts_Flag : 0;
|
| + fDevice = SkGpuDevice::Create(renderTarget, this->props(), deviceFlags);
|
|
|
| - if (kRGB_565_GrPixelConfig != renderTarget->config() &&
|
| + if (kRGB_565_GrPixelConfig != renderTarget->config() &&
|
| !(flags & kDontClear_RenderTargetFlag)) {
|
| fDevice->clear(0x0);
|
| }
|
| @@ -53,7 +54,11 @@ SkSurface_Gpu::~SkSurface_Gpu() {
|
| }
|
|
|
| SkCanvas* SkSurface_Gpu::onNewCanvas() {
|
| - return SkNEW_ARGS(SkCanvas, (fDevice));
|
| + SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags;
|
| + // When we think this works...
|
| +// flags |= SkCanvas::kConservativeRasterClip_InitFlag;
|
| +
|
| + return SkNEW_ARGS(SkCanvas, (fDevice, &this->props(), flags));
|
| }
|
|
|
| SkSurface* SkSurface_Gpu::onNewSurface(const SkImageInfo& info) {
|
| @@ -104,16 +109,31 @@ void SkSurface_Gpu::onDiscard() {
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| +static SkSurfaceProps make_props(SkSurface::TextRenderMode trm) {
|
| + const SkSurfaceProps legacyProps(SkSurfaceProps::kLegacyFontHost_InitType);
|
| +
|
| + uint32_t propsFlags = 0;
|
| + if (SkSurface::kDistanceField_TextRenderMode == trm) {
|
| + propsFlags |= SkSurfaceProps::kUseDistanceFieldFonts_Flag;
|
| + }
|
| + return SkSurfaceProps(propsFlags, legacyProps.pixelGeometry());
|
| +}
|
| +
|
| SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, TextRenderMode trm,
|
| RenderTargetFlags flags) {
|
| if (NULL == target) {
|
| return NULL;
|
| }
|
| - return SkNEW_ARGS(SkSurface_Gpu, (target, false, trm, flags));
|
| + return SkNEW_ARGS(SkSurface_Gpu, (target, false, flags, make_props(trm)));
|
| +}
|
| +
|
| +SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, int sampleCount,
|
| + TextRenderMode trm, RenderTargetFlags renderFlags) {
|
| + return NewRenderTarget(ctx, info, sampleCount, make_props(trm), renderFlags);
|
| }
|
|
|
| SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, int sampleCount,
|
| - TextRenderMode trm, RenderTargetFlags flags) {
|
| + const SkSurfaceProps& props, RenderTargetFlags flags) {
|
| if (NULL == ctx) {
|
| return NULL;
|
| }
|
| @@ -130,7 +150,7 @@ SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, i
|
| return NULL;
|
| }
|
|
|
| - return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), false, trm, flags));
|
| + return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), false, flags, props));
|
| }
|
|
|
| SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo& info,
|
| @@ -153,5 +173,5 @@ SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo&
|
| return NULL;
|
| }
|
|
|
| - return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true, trm, flags));
|
| + return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true, flags, make_props(trm)));
|
| }
|
|
|