Skip to content

Commit

Permalink
[chromium] Refactor the computation of resampled bitmap size in
Browse files Browse the repository at this point in the history
drawImage and drawPattern.
https://bugs.webkit.org/show_bug.cgi?id=92408

Reviewed by Adrienne Walker.

Source/WebCore: 

We used to have a special-purpose function called TransformDimensions()
which did pretty much the same thing as SkRect::mapRect() does.  This
change unifies the drawPattern code to use mapRect() in the same way
that drawImage() does.

Covered by existing tests, e.g., fast/backgrounds/size/*.

* platform/graphics/skia/ImageSkia.cpp:
(WebCore):
(WebCore::Image::drawPattern):
Note:  we're now doing using the original (float) source rect, and
converting to int only after applying the matrix transform.  This
might result in different decisions about resampling mode, but it's
more correct anyway.

LayoutTests: 

Mark a test as expected to fail (will need rebaseline).

* platform/chromium/TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@124042 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
SenorBlanco committed Jul 30, 2012
1 parent 052e3f0 commit fcda600
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 22 deletions.
12 changes: 12 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
2012-07-26 Stephen White <senorblanco@chromium.org>

[chromium] Refactor the computation of resampled bitmap size in
drawImage and drawPattern.
https://bugs.webkit.org/show_bug.cgi?id=92408

Reviewed by Adrienne Walker.

Mark a test as expected to fail (will need rebaseline).

* platform/chromium/TestExpectations:

2012-07-30 Dominik Röttsches <dominik.rottsches@intel.com>

[EFL][DRT] fast/text/font-variant-ligatures.html fails with missing rendering output
Expand Down
3 changes: 3 additions & 0 deletions LayoutTests/platform/chromium/TestExpectations
Expand Up @@ -3045,6 +3045,9 @@ BUGWK81145 LION : fast/writing-mode/broken-ideograph-small-caps.html = CRASH
BUGWK81145 LION : fast/writing-mode/broken-ideographic-font.html = CRASH
BUGWK81145 LION : fast/writing-mode/japanese-rl-text-with-broken-font.html = CRASH

// Needs rebaseline.
BUGWK92059 : fast/gradients/background-clipped.html = IMAGE

BUGYANGGUO MAC : fast/repaint/moving-shadow-on-container.html = TEXT

BUGWK81537 : fast/events/touch/gesture/pad-gesture-fling.html = TEXT PASS
Expand Down
23 changes: 23 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,26 @@
2012-07-26 Stephen White <senorblanco@chromium.org>

[chromium] Refactor the computation of resampled bitmap size in
drawImage and drawPattern.
https://bugs.webkit.org/show_bug.cgi?id=92408

Reviewed by Adrienne Walker.

We used to have a special-purpose function called TransformDimensions()
which did pretty much the same thing as SkRect::mapRect() does. This
change unifies the drawPattern code to use mapRect() in the same way
that drawImage() does.

Covered by existing tests, e.g., fast/backgrounds/size/*.

* platform/graphics/skia/ImageSkia.cpp:
(WebCore):
(WebCore::Image::drawPattern):
Note: we're now doing using the original (float) source rect, and
converting to int only after applying the matrix transform. This
might result in different decisions about resampling mode, but it's
more correct anyway.

2012-07-30 Vineet Chaudhary <rgf748@motorola.com>

https://bugs.webkit.org/show_bug.cgi?id=92642
Expand Down
27 changes: 5 additions & 22 deletions Source/WebCore/platform/graphics/skia/ImageSkia.cpp
Expand Up @@ -274,25 +274,6 @@ static void paintSkBitmap(PlatformContextSkia* platformContext, const NativeImag
platformContext->didDrawRect(destRect, paint, &bitmap.bitmap());
}

// Transforms the given dimensions with the given matrix. Used to see how big
// images will be once transformed.
static void TransformDimensions(const SkMatrix& matrix, float srcWidth, float srcHeight, float* destWidth, float* destHeight)
{
// Transform 3 points to see how long each side of the bitmap will be.
SkPoint srcPoints[3]; // (0, 0), (width, 0), (0, height).
srcPoints[0].set(0, 0);
srcPoints[1].set(SkFloatToScalar(srcWidth), 0);
srcPoints[2].set(0, SkFloatToScalar(srcHeight));

// Now measure the length of the two transformed vectors relative to the
// transformed origin to see how big the bitmap will be. Note: for skews,
// this isn't the best thing, but we don't have skews.
SkPoint destPoints[3];
matrix.mapPoints(destPoints, srcPoints, 3);
*destWidth = SkScalarToFloat((destPoints[1] - destPoints[0]).length());
*destHeight = SkScalarToFloat((destPoints[2] - destPoints[0]).length());
}

// A helper method for translating negative width and height values.
FloatRect normalizeRect(const FloatRect& rect)
{
Expand Down Expand Up @@ -350,9 +331,11 @@ void Image::drawPattern(GraphicsContext* context,
// Figure out what size the bitmap will be in the destination. The
// destination rect is the bounds of the pattern, we need to use the
// matrix to see how big it will be.
float destBitmapWidth, destBitmapHeight;
TransformDimensions(totalMatrix, srcRect.width(), srcRect.height(),
&destBitmapWidth, &destBitmapHeight);
SkRect destRectTarget;
totalMatrix.mapRect(&destRectTarget, normSrcRect);

float destBitmapWidth = SkScalarToFloat(destRectTarget.width());
float destBitmapHeight = SkScalarToFloat(destRectTarget.height());

// Compute the resampling mode.
ResamplingMode resampling;
Expand Down

0 comments on commit fcda600

Please sign in to comment.