Copy src in SkDrawLooper::computeFastBounds().
authormtklein <mtklein@chromium.org>
Wed, 3 Dec 2014 19:08:47 +0000 (11:08 -0800)
committerCommit bot <commit-bot@chromium.org>
Wed, 3 Dec 2014 19:08:47 +0000 (11:08 -0800)
We do alias src and dst when building the BBH.  This meant we calculated
the wrong bounds in LayoutTests/ietestcenter/css3/text/textshadow-010.htm.

Not sure how best to test this inside Skia.  It may become moot after I
work through the API changes we were talking about today, but if not I'll
make sure it's tested somehow before I'm done with SkDrawLoopers.

BUG=skia:3186

Review URL: https://codereview.chromium.org/760023004

src/core/SkDrawLooper.cpp

index d18d127..1af68a2 100644 (file)
@@ -32,8 +32,11 @@ bool SkDrawLooper::canComputeFastBounds(const SkPaint& paint) const {
     return true;
 }
 
-void SkDrawLooper::computeFastBounds(const SkPaint& paint, const SkRect& src,
+void SkDrawLooper::computeFastBounds(const SkPaint& paint, const SkRect& s,
                                      SkRect* dst) const {
+    // src and dst rects may alias and we need to keep the original src, so copy it.
+    const SkRect src = s;
+
     SkCanvas canvas;
     SkSmallAllocator<1, 32> allocator;
     void* buffer = allocator.reserveT<SkDrawLooper::Context>(this->contextSize());