diff options
author | reed <reed@google.com> | 2014-12-04 07:50:14 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-04 07:50:14 -0800 |
commit | 8eddfb50c0c9e4bcba6384a2ce39852b5fb5becb (patch) | |
tree | fee1ed25b223ba3e5cd458e351a9899e7179222c /src/gpu | |
parent | 60f3c657cc0235650b630be78105fc47d37385e7 (diff) |
Change clear() to respect the clip
This reverts commit af641a1c10f176cb9617026d3cc93c117a85d13d.
BUG=skia:
TBR=
Review URL: https://codereview.chromium.org/783493002
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrLayerHoister.cpp | 13 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 19 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.h | 4 |
3 files changed, 16 insertions, 20 deletions
diff --git a/src/gpu/GrLayerHoister.cpp b/src/gpu/GrLayerHoister.cpp index a17c7ddf97..5d2d5493b4 100644 --- a/src/gpu/GrLayerHoister.cpp +++ b/src/gpu/GrLayerHoister.cpp @@ -193,10 +193,6 @@ void GrLayerHoister::DrawLayersToAtlas(GrContext* context, SkCanvas* atlasCanvas = surface->getCanvas(); - SkPaint clearPaint; - clearPaint.setColor(SK_ColorTRANSPARENT); - clearPaint.setXfermode(SkXfermode::Create(SkXfermode::kSrc_Mode))->unref(); - for (int i = 0; i < atlased.count(); ++i) { const GrCachedLayer* layer = atlased[i].fLayer; const SkPicture* pict = atlased[i].fPicture; @@ -211,9 +207,7 @@ void GrLayerHoister::DrawLayersToAtlas(GrContext* context, // extend beyond the boundaries of the atlased sub-rect const SkRect bound = SkRect::Make(layer->rect()); atlasCanvas->clipRect(bound); - - // Since 'clear' doesn't respect the clip we need to draw a rect - atlasCanvas->drawRect(bound, clearPaint); + atlasCanvas->clear(0); // '-offset' maps the layer's top/left to the origin. // Since this layer is atlased, the top/left corner needs @@ -228,7 +222,7 @@ void GrLayerHoister::DrawLayersToAtlas(GrContext* context, SkRecordPartialDraw(*pict->fRecord.get(), atlasCanvas, pict->drawablePicts(), pict->drawableCount(), - bound, layer->start() + 1, layer->stop(), initialCTM); + layer->start() + 1, layer->stop(), initialCTM); atlasCanvas->restore(); } @@ -255,7 +249,6 @@ void GrLayerHoister::DrawLayers(GrContext* context, const SkTDArray<GrHoistedLay // extend beyond the boundaries of the layer const SkRect bound = SkRect::Make(layer->rect()); layerCanvas->clipRect(bound); - layerCanvas->clear(SK_ColorTRANSPARENT); SkMatrix initialCTM; @@ -267,7 +260,7 @@ void GrLayerHoister::DrawLayers(GrContext* context, const SkTDArray<GrHoistedLay SkRecordPartialDraw(*pict->fRecord.get(), layerCanvas, pict->drawablePicts(), pict->drawableCount(), - bound, layer->start()+1, layer->stop(), initialCTM); + layer->start()+1, layer->stop(), initialCTM); layerCanvas->flush(); } diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 407f36037d..f09ebf291f 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -68,7 +68,7 @@ enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 }; #define DO_DEFERRED_CLEAR() \ do { \ if (fFlags & kNeedClear_Flag) { \ - this->clear(SK_ColorTRANSPARENT); \ + this->clearAll(); \ } \ } while (false) \ @@ -294,6 +294,14 @@ GrRenderTarget* SkGpuDevice::accessRenderTarget() { return fRenderTarget; } +void SkGpuDevice::clearAll() { + GrColor color = 0; + GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::clearAll", fContext); + SkIRect rect = SkIRect::MakeWH(this->width(), this->height()); + fContext->clear(&rect, color, true, fRenderTarget); + fFlags &= ~kNeedClear_Flag; +} + /////////////////////////////////////////////////////////////////////////////// SK_COMPILE_ASSERT(SkShader::kNone_BitmapType == 0, shader_type_mismatch); @@ -309,13 +317,6 @@ SK_COMPILE_ASSERT(SkShader::kLast_BitmapType == 6, shader_type_mismatch); /////////////////////////////////////////////////////////////////////////////// -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); - fFlags &= ~kNeedClear_Flag; -} - void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { CHECK_SHOULD_DRAW(draw, false); GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext); @@ -1514,7 +1515,7 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, SkGpuDevice* dev = static_cast<SkGpuDevice*>(device); if (dev->fFlags & kNeedClear_Flag) { // TODO: could check here whether we really need to draw at all - dev->clear(0x0); + dev->clearAll(); } // drawDevice is defined to be in device coords. diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h index f7088e3fa3..2fb6de7eb8 100644 --- a/src/gpu/SkGpuDevice.h +++ b/src/gpu/SkGpuDevice.h @@ -65,13 +65,15 @@ public: GrContext* context() const { return fContext; } + // set all pixels to 0 + void clearAll(); + virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE; virtual SkImageInfo imageInfo() const SK_OVERRIDE { return fRenderTarget ? fRenderTarget->surfacePriv().info() : SkImageInfo::MakeUnknown(); } - virtual void clear(SkColor color) SK_OVERRIDE; virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE; virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count, const SkPoint[], const SkPaint& paint) SK_OVERRIDE; |