Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Unified Diff: third_party/WebKit/Source/platform/DragImage.cpp

Issue 1361413004: Fix directly composited image path for CSS image-orientation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/DragImage.cpp
diff --git a/third_party/WebKit/Source/platform/DragImage.cpp b/third_party/WebKit/Source/platform/DragImage.cpp
index be1b995eb8d560f7f8c384bd07ad110ece9ac7dd..f64d0d465a2e5dc5a6d072c0025080d7c1740f94 100644
--- a/third_party/WebKit/Source/platform/DragImage.cpp
+++ b/third_party/WebKit/Source/platform/DragImage.cpp
@@ -72,6 +72,8 @@ const float kMaxDragLabelStringWidth = (kMaxDragLabelWidth - 2 * kDragLabelBorde
const float kDragLinkLabelFontSize = 11;
const float kDragLinkUrlFontSize = 10;
+} // anonymous namespace
+
PassRefPtr<SkImage> adjustedImage(PassRefPtr<SkImage> image, const IntSize& size,
const AffineTransform& transform, float opacity, InterpolationQuality interpolationQuality)
{
@@ -100,15 +102,13 @@ PassRefPtr<SkImage> adjustedImage(PassRefPtr<SkImage> image, const IntSize& size
return adoptRef(surface->newImageSnapshot());
}
-} // anonymous namespace
-
-FloatSize DragImage::clampedImageScale(const Image& image, const IntSize& size,
+FloatSize DragImage::clampedImageScale(const IntSize& imageSize, const IntSize& size,
const IntSize& maxSize)
{
// Non-uniform scaling for size mapping.
FloatSize imageScale(
- static_cast<float>(size.width()) / image.width(),
- static_cast<float>(size.height()) / image.height());
+ static_cast<float>(size.width()) / imageSize.width(),
+ static_cast<float>(size.height()) / imageSize.height());
// Uniform scaling for clamping.
const float clampScaleX = size.width() > maxSize.width()
@@ -122,7 +122,7 @@ FloatSize DragImage::clampedImageScale(const Image& image, const IntSize& size,
PassOwnPtr<DragImage> DragImage::create(Image* image,
RespectImageOrientationEnum shouldRespectImageOrientation, float deviceScaleFactor,
- InterpolationQuality interpolationQuality, float opacity, const FloatSize& imageScale)
+ InterpolationQuality interpolationQuality, float opacity, FloatSize imageScale)
{
if (!image)
return nullptr;
@@ -137,22 +137,17 @@ PassOwnPtr<DragImage> DragImage::create(Image* image,
return nullptr;
AffineTransform transform;
- transform.scaleNonUniform(imageScale.width(), imageScale.height());
-
if (shouldRespectImageOrientation == RespectImageOrientation && image->isBitmapImage()) {
BitmapImage* bitmapImage = toBitmapImage(image);
ImageOrientation orientation = bitmapImage->currentFrameOrientation();
if (orientation != DefaultImageOrientation) {
size = bitmapImage->sizeRespectingOrientation();
- if (orientation.usesWidthAsHeight())
- size.scale(imageScale.height(), imageScale.width());
- else
- size.scale(imageScale.width(), imageScale.height());
-
+ size.scale(imageScale.width(), imageScale.height());
transform *= orientation.transformFromDefault(size);
}
}
+ transform.scaleNonUniform(imageScale.width(), imageScale.height());
SkBitmap bm;
RefPtr<SkImage> resizedImage =

Powered by Google App Engine
This is Rietveld 408576698