diff options
author | bsalomon <bsalomon@google.com> | 2015-09-22 11:38:46 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-22 11:38:46 -0700 |
commit | aca31fea8ca620bfdb2887641b7ba56e401a72d7 (patch) | |
tree | 9caecaf595521a246cd81aeb74dbd7756046ed18 /src | |
parent | a16e8bcef165aabb2463339e80fdd6f1fa19b8b9 (diff) |
Stop supporting HW dither
Review URL: https://codereview.chromium.org/1359833004
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrAtlasTextContext.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrBlurUtils.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrPaint.cpp | 1 | ||||
-rw-r--r-- | src/gpu/GrPipeline.cpp | 3 | ||||
-rw-r--r-- | src/gpu/GrPipeline.h | 6 | ||||
-rw-r--r-- | src/gpu/GrPipelineBuilder.cpp | 1 | ||||
-rw-r--r-- | src/gpu/GrPipelineBuilder.h | 9 | ||||
-rw-r--r-- | src/gpu/GrTextContext.cpp | 2 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 39 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 31 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 18 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 2 |
12 files changed, 34 insertions, 84 deletions
diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp index 822c480ef3..81cc6471f7 100644 --- a/src/gpu/GrAtlasTextContext.cpp +++ b/src/gpu/GrAtlasTextContext.cpp @@ -389,7 +389,7 @@ void GrAtlasTextContext::drawTextBlob(GrDrawContext* dc, GrRenderTarget* rt, // Though for the time being runs in the textblob can override the paint, they only touch font // info. GrPaint grPaint; - if (!SkPaint2GrPaint(fContext, rt, skPaint, viewMatrix, true, &grPaint)) { + if (!SkPaint2GrPaint(fContext, skPaint, viewMatrix, true, &grPaint)) { return; } @@ -2265,7 +2265,7 @@ DRAW_BATCH_TEST_DEFINE(TextBlobBatch) { skPaint.setSubpixelText(random->nextBool()); GrPaint grPaint; - if (!SkPaint2GrPaint(context, rt, skPaint, viewMatrix, true, &grPaint)) { + if (!SkPaint2GrPaint(context, skPaint, viewMatrix, true, &grPaint)) { SkFAIL("couldn't convert paint\n"); } diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp index d37f9bfc64..b601a200cf 100644 --- a/src/gpu/GrBlurUtils.cpp +++ b/src/gpu/GrBlurUtils.cpp @@ -197,7 +197,7 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context, SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) GrPaint grPaint; - if (!SkPaint2GrPaint(context, renderTarget, paint, viewMatrix, true, &grPaint)) { + if (!SkPaint2GrPaint(context, paint, viewMatrix, true, &grPaint)) { return; } diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp index 3b383681b2..4a9f417ff4 100644 --- a/src/gpu/GrPaint.cpp +++ b/src/gpu/GrPaint.cpp @@ -15,7 +15,6 @@ GrPaint::GrPaint() : fAntiAlias(false) - , fDither(false) , fColor(GrColor_WHITE) {} void GrPaint::setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage) { diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp index 1d7b71f605..80e3cbdf69 100644 --- a/src/gpu/GrPipeline.cpp +++ b/src/gpu/GrPipeline.cpp @@ -66,9 +66,6 @@ GrPipeline* GrPipeline::CreateAt(void* memory, const CreateArgs& args, if (builder.isHWAntialias()) { pipeline->fFlags |= kHWAA_Flag; } - if (builder.isDither()) { - pipeline->fFlags |= kDither_Flag; - } if (builder.snapVerticesToPixelCenters()) { pipeline->fFlags |= kSnapVertices_Flag; } diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h index b7e8b1f80d..df44ba680c 100644 --- a/src/gpu/GrPipeline.h +++ b/src/gpu/GrPipeline.h @@ -120,7 +120,6 @@ public: const GrScissorState& getScissorState() const { return fScissorState; } - bool isDitherState() const { return SkToBool(fFlags & kDither_Flag); } bool isHWAntialiasState() const { return SkToBool(fFlags & kHWAA_Flag); } bool snapVerticesToPixelCenters() const { return SkToBool(fFlags & kSnapVertices_Flag); } @@ -162,9 +161,8 @@ private: const GrCaps&); enum Flags { - kDither_Flag = 0x1, - kHWAA_Flag = 0x2, - kSnapVertices_Flag = 0x4, + kHWAA_Flag = 0x1, + kSnapVertices_Flag = 0x2, }; typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; diff --git a/src/gpu/GrPipelineBuilder.cpp b/src/gpu/GrPipelineBuilder.cpp index dbef6e8755..ab185505d6 100644 --- a/src/gpu/GrPipelineBuilder.cpp +++ b/src/gpu/GrPipelineBuilder.cpp @@ -42,7 +42,6 @@ GrPipelineBuilder::GrPipelineBuilder(const GrPaint& paint, GrRenderTarget* rt, c fClip = clip; - this->setState(GrPipelineBuilder::kDither_Flag, paint.isDither()); this->setState(GrPipelineBuilder::kHWAntialias_Flag, rt->isUnifiedMultisampled() && paint.isAntiAlias()); } diff --git a/src/gpu/GrPipelineBuilder.h b/src/gpu/GrPipelineBuilder.h index e37b54ac8e..e2a7bc7e5f 100644 --- a/src/gpu/GrPipelineBuilder.h +++ b/src/gpu/GrPipelineBuilder.h @@ -296,25 +296,20 @@ public: */ enum Flags { /** - * Perform dithering. TODO: Re-evaluate whether we need this bit - */ - kDither_Flag = 0x01, - /** * Perform HW anti-aliasing. This means either HW FSAA, if supported by the render target, * or smooth-line rendering if a line primitive is drawn and line smoothing is supported by * the 3D API. */ - kHWAntialias_Flag = 0x02, + kHWAntialias_Flag = 0x01, /** * Modifies the vertex shader so that vertices will be positioned at pixel centers. */ - kSnapVerticesToPixelCenters_Flag = 0x04, + kSnapVerticesToPixelCenters_Flag = 0x02, kLast_Flag = kSnapVerticesToPixelCenters_Flag, }; - bool isDither() const { return SkToBool(fFlags & kDither_Flag); } bool isHWAntialias() const { return SkToBool(fFlags & kHWAntialias_Flag); } bool snapVerticesToPixelCenters() const { return SkToBool(fFlags & kSnapVerticesToPixelCenters_Flag); } diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp index 6ab730cdfa..32c056f003 100644 --- a/src/gpu/GrTextContext.cpp +++ b/src/gpu/GrTextContext.cpp @@ -130,7 +130,7 @@ void GrTextContext::drawTextBlob(GrDrawContext* dc, GrRenderTarget* rt, runPaint.setFlags(FilterTextFlags(fSurfaceProps, runPaint)); GrPaint grPaint; - if (!SkPaint2GrPaint(fContext, rt, runPaint, viewMatrix, true, &grPaint)) { + if (!SkPaint2GrPaint(fContext, runPaint, viewMatrix, true, &grPaint)) { return; } diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index d897f3ce88..09206052f0 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -383,7 +383,7 @@ void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext); GrPaint grPaint; - if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint)) { + if (!SkPaint2GrPaint(this->context(), paint, *draw.fMatrix, true, &grPaint)) { return; } @@ -432,8 +432,7 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mode) { GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style); GrPaint grPaint; - if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, true, - &grPaint)) { + if (!SkPaint2GrPaint(this->context(), paint, *draw.fMatrix, true, &grPaint)) { return; } SkPath path; @@ -453,7 +452,7 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, } GrPaint grPaint; - if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint)) { + if (!SkPaint2GrPaint(this->context(), paint, *draw.fMatrix, true, &grPaint)) { return; } @@ -516,7 +515,7 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, } GrPaint grPaint; - if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint)) { + if (!SkPaint2GrPaint(this->context(), paint, *draw.fMatrix, true, &grPaint)) { return; } @@ -532,7 +531,7 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, CHECK_SHOULD_DRAW(draw); GrPaint grPaint; - if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint)) { + if (!SkPaint2GrPaint(this->context(), paint, *draw.fMatrix, true, &grPaint)) { return; } @@ -603,8 +602,7 @@ void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, CHECK_SHOULD_DRAW(draw); GrPaint grPaint; - if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, true, - &grPaint)) { + if (!SkPaint2GrPaint(this->context(), paint, *draw.fMatrix, true, &grPaint)) { return; } @@ -656,7 +654,7 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, } GrPaint grPaint; - if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint)) { + if (!SkPaint2GrPaint(this->context(), paint, *draw.fMatrix, true, &grPaint)) { return; } @@ -1011,8 +1009,8 @@ static void draw_aa_bitmap(GrDrawContext* drawContext, GrContext* context, // The bitmap read has to be first grPaint.addColorFragmentProcessor(fp); - if (!SkPaint2GrPaintNoShader(context, renderTarget, paint, SkColor2GrColor(paint.getColor()), - false, &grPaint)) { + if (!SkPaint2GrPaintNoShader(context, paint, SkColor2GrColor(paint.getColor()), false, + &grPaint)) { return; } @@ -1358,8 +1356,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap, bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType()); GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()) : SkColor2GrColor(paint.getColor()); - if (!SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, paintColor, false, - &grPaint)) { + if (!SkPaint2GrPaintNoShader(this->context(), paint, paintColor, false, &grPaint)) { return; } @@ -1432,7 +1429,7 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, GrPaint grPaint; grPaint.addColorTextureProcessor(texture, SkMatrix::I()); - if (!SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, + if (!SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(paint.getColor()), false, &grPaint)) { return; } @@ -1547,7 +1544,7 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, GrPaint grPaint; grPaint.addColorTextureProcessor(devTex, SkMatrix::I()); - if (!SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, + if (!SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(paint.getColor()), false, &grPaint)) { return; } @@ -1684,7 +1681,7 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, copy.setStrokeWidth(0); // we ignore the shader if texs is null. - if (!SkPaint2GrPaintNoShader(this->context(), fRenderTarget, copy, + if (!SkPaint2GrPaintNoShader(this->context(), copy, SkColor2GrColor(copy.getColor()), nullptr == colors, &grPaint)) { return; } @@ -1726,13 +1723,13 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, primType = gVertexMode2PrimitiveType[vmode]; if (nullptr == texs || nullptr == paint.getShader()) { - if (!SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, + if (!SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColor(paint.getColor()), nullptr == colors, &grPaint)) { return; } } else { - if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, + if (!SkPaint2GrPaint(this->context(), paint, *draw.fMatrix, nullptr == colors, &grPaint)) { return; } @@ -1792,7 +1789,7 @@ void SkGpuDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkRS p.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode))->unref(); GrPaint grPaint; - if (!SkPaint2GrPaint(this->context(), fRenderTarget, p, *draw.fMatrix, !colors, &grPaint)) { + if (!SkPaint2GrPaint(this->context(), p, *draw.fMatrix, !colors, &grPaint)) { return; } @@ -1820,7 +1817,7 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text, GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext); GrPaint grPaint; - if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint)) { + if (!SkPaint2GrPaint(this->context(), paint, *draw.fMatrix, true, &grPaint)) { return; } @@ -1837,7 +1834,7 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL CHECK_SHOULD_DRAW(draw); GrPaint grPaint; - if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint)) { + if (!SkPaint2GrPaint(this->context(), paint, *draw.fMatrix, true, &grPaint)) { return; } diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 9ab2f6393a..09c83b929a 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -708,10 +708,9 @@ bool GrPixelConfig2ColorAndProfileType(GrPixelConfig config, SkColorType* ctOut, /////////////////////////////////////////////////////////////////////////////// -bool SkPaint2GrPaintNoShader(GrContext* context, GrRenderTarget* rt, const SkPaint& skPaint, - GrColor paintColor, bool constantColor, GrPaint* grPaint) { +bool SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor paintColor, + bool constantColor, GrPaint* grPaint) { - grPaint->setDither(skPaint.isDither()); grPaint->setAntiAlias(skPaint.isAntiAlias()); SkXfermode* mode = skPaint.getXfermode(); @@ -748,34 +747,18 @@ bool SkPaint2GrPaintNoShader(GrContext* context, GrRenderTarget* rt, const SkPai } #ifndef SK_IGNORE_GPU_DITHER - // If the dither flag is set, then we need to see if the underlying context - // supports it. If not, then install a dither effect. if (skPaint.isDither() && grPaint->numColorFragmentProcessors() > 0) { - // What are we rendering into? - SkASSERT(rt); - - // Suspect the dithering flag has no effect on these configs, otherwise - // fall back on setting the appropriate state. - if (GrPixelConfigIs8888(rt->config()) || - GrPixelConfigIs8888(rt->config())) { - // The dither flag is set and the target is likely - // not going to be dithered by the GPU. - SkAutoTUnref<GrFragmentProcessor> fp(GrDitherEffect::Create()); - if (fp.get()) { - grPaint->addColorFragmentProcessor(fp); - grPaint->setDither(false); - } - } + grPaint->addColorFragmentProcessor(GrDitherEffect::Create())->unref(); } #endif return true; } -bool SkPaint2GrPaint(GrContext* context, GrRenderTarget* rt, const SkPaint& skPaint, - const SkMatrix& viewM, bool constantColor, GrPaint* grPaint) { +bool SkPaint2GrPaint(GrContext* context,const SkPaint& skPaint, const SkMatrix& viewM, + bool constantColor, GrPaint* grPaint) { SkShader* shader = skPaint.getShader(); if (nullptr == shader) { - return SkPaint2GrPaintNoShader(context, rt, skPaint, SkColor2GrColor(skPaint.getColor()), + return SkPaint2GrPaintNoShader(context, skPaint, SkColor2GrColor(skPaint.getColor()), constantColor, grPaint); } @@ -791,7 +774,7 @@ bool SkPaint2GrPaint(GrContext* context, GrRenderTarget* rt, const SkPaint& skPa // The grcolor is automatically set when calling asFragmentProcessor. // If the shader can be seen as an effect it returns true and adds its effect to the grpaint. - return SkPaint2GrPaintNoShader(context, rt, skPaint, paintColor, constantColor, grPaint); + return SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint); } SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque) { diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index c07f704d21..cb12fefc32 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -286,7 +286,6 @@ void GrGLGpu::onResetContext(uint32_t resetBits) { GL_CALL(DepthMask(GR_GL_FALSE)); fHWDrawFace = GrPipelineBuilder::kInvalid_DrawFace; - fHWDitherEnabled = kUnknown_TriState; if (kGL_GrGLStandard == this->glStandard()) { // Desktop-only state that we never change @@ -323,6 +322,7 @@ void GrGLGpu::onResetContext(uint32_t resetBits) { fHWWriteToColor = kUnknown_TriState; // we only ever use lines in hairline mode GL_CALL(LineWidth(1)); + GL_CALL(Disable(GR_GL_DITHER)); } if (resetBits & kMSAAEnable_GrGLBackendState) { @@ -1445,7 +1445,6 @@ bool GrGLGpu::flushGLState(const DrawArgs& args) { const GrPipeline& pipeline = *args.fPipeline; args.fPipeline->getXferProcessor()->getBlendInfo(&blendInfo); - this->flushDither(pipeline.isDitherState()); this->flushColorWrite(blendInfo.fWriteColor); this->flushDrawFace(pipeline.getDrawFace()); @@ -2344,20 +2343,6 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur texture->setCachedTexParams(newTexParams, this->getResetTimestamp()); } -void GrGLGpu::flushDither(bool dither) { - if (dither) { - if (kYes_TriState != fHWDitherEnabled) { - GL_CALL(Enable(GR_GL_DITHER)); - fHWDitherEnabled = kYes_TriState; - } - } else { - if (kNo_TriState != fHWDitherEnabled) { - GL_CALL(Disable(GR_GL_DITHER)); - fHWDitherEnabled = kNo_TriState; - } - } -} - void GrGLGpu::flushColorWrite(bool writeColor) { if (!writeColor) { if (kNo_TriState != fHWWriteToColor) { @@ -2930,7 +2915,6 @@ void GrGLGpu::copySurfaceAsDraw(GrSurface* dst, blendInfo.reset(); this->flushBlend(blendInfo); this->flushColorWrite(true); - this->flushDither(false); this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); this->flushHWAAState(dstRT, false); this->disableScissor(); diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 833f1ff7ec..2387b44af6 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -234,7 +234,6 @@ private: #endif }; - void flushDither(bool dither); void flushColorWrite(bool writeColor); void flushDrawFace(GrPipelineBuilder::DrawFace face); @@ -489,7 +488,6 @@ private: GrPipelineBuilder::DrawFace fHWDrawFace; TriState fHWWriteToColor; - TriState fHWDitherEnabled; uint32_t fHWBoundRenderTargetUniqueID; TriState fHWSRGBFramebuffer; SkTArray<uint32_t, true> fHWBoundTextureUniqueIDs; |