| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "platform/fonts/Font.h" | 30 #include "platform/fonts/Font.h" |
| 31 #include "platform/fonts/FontCache.h" | 31 #include "platform/fonts/FontCache.h" |
| 32 #include "platform/fonts/FontDescription.h" | 32 #include "platform/fonts/FontDescription.h" |
| 33 #include "platform/fonts/FontMetrics.h" | 33 #include "platform/fonts/FontMetrics.h" |
| 34 #include "platform/geometry/FloatPoint.h" | 34 #include "platform/geometry/FloatPoint.h" |
| 35 #include "platform/geometry/FloatRect.h" | 35 #include "platform/geometry/FloatRect.h" |
| 36 #include "platform/geometry/IntPoint.h" | 36 #include "platform/geometry/IntPoint.h" |
| 37 #include "platform/graphics/BitmapImage.h" | 37 #include "platform/graphics/BitmapImage.h" |
| 38 #include "platform/graphics/Color.h" | 38 #include "platform/graphics/Color.h" |
| 39 #include "platform/graphics/GraphicsContext.h" | 39 #include "platform/graphics/GraphicsContext.h" |
| 40 #include "platform/graphics/GraphicsScreen.h" |
| 40 #include "platform/graphics/Image.h" | 41 #include "platform/graphics/Image.h" |
| 41 #include "platform/graphics/ImageBuffer.h" | 42 #include "platform/graphics/ImageBuffer.h" |
| 42 #include "platform/graphics/paint/DrawingRecorder.h" | 43 #include "platform/graphics/paint/DrawingRecorder.h" |
| 43 #include "platform/graphics/paint/SkPictureBuilder.h" | 44 #include "platform/graphics/paint/SkPictureBuilder.h" |
| 44 #include "platform/text/BidiTextRun.h" | 45 #include "platform/text/BidiTextRun.h" |
| 45 #include "platform/text/StringTruncator.h" | 46 #include "platform/text/StringTruncator.h" |
| 46 #include "platform/text/TextRun.h" | 47 #include "platform/text/TextRun.h" |
| 47 #include "platform/transforms/AffineTransform.h" | 48 #include "platform/transforms/AffineTransform.h" |
| 48 #include "platform/weborigin/KURL.h" | 49 #include "platform/weborigin/KURL.h" |
| 49 #include "skia/ext/image_operations.h" | 50 #include "skia/ext/image_operations.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 ? static_cast<float>(maxSize.height()) / size.height() : 1; | 131 ? static_cast<float>(maxSize.height()) / size.height() : 1; |
| 131 imageScale.scale(std::min(clampScaleX, clampScaleY)); | 132 imageScale.scale(std::min(clampScaleX, clampScaleY)); |
| 132 | 133 |
| 133 return imageScale; | 134 return imageScale; |
| 134 } | 135 } |
| 135 | 136 |
| 136 PassOwnPtr<DragImage> DragImage::create(Image* image, | 137 PassOwnPtr<DragImage> DragImage::create(Image* image, |
| 137 RespectImageOrientationEnum shouldRespectImageOrientation, float deviceScale
Factor, | 138 RespectImageOrientationEnum shouldRespectImageOrientation, float deviceScale
Factor, |
| 138 InterpolationQuality interpolationQuality, float opacity, FloatSize imageSca
le) | 139 InterpolationQuality interpolationQuality, float opacity, FloatSize imageSca
le) |
| 139 { | 140 { |
| 140 if (!image) | 141 RefPtr<SkImage> skImage = image ? image->imageForCurrentFrame() : nullptr; |
| 142 |
| 143 if (imageColorProfilesEnabled()) |
| 144 RELEASE_ASSERT(currentScreenId()); // There should be an active graphics
screen. |
| 145 |
| 146 if (skImage && imageColorProfilesEnabled() && image->isBitmapImage() && toBi
tmapImage(image)->hasColorProfile()) { |
| 147 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(image->size()); |
| 148 IntRect source = IntRect(IntPoint(), image->size()); |
| 149 image->draw(buffer->canvas(), SkPaint(), source, source, DoNotRespectIma
geOrientation, Image::ClampImageToSourceRect); |
| 150 skImage = buffer->newSkImageSnapshot(PreferNoAcceleration); |
| 151 } |
| 152 |
| 153 ImageOrientation orientation; |
| 154 if (skImage && shouldRespectImageOrientation == RespectImageOrientation && i
mage->isBitmapImage()) |
| 155 orientation = toBitmapImage(image)->currentFrameOrientation(); |
| 156 |
| 157 RefPtr<SkImage> dragImage; |
| 158 if (skImage) |
| 159 dragImage = resizeAndOrientImage(skImage.release(), orientation, imageSc
ale, opacity, interpolationQuality); |
| 160 |
| 161 SkBitmap bitmap; |
| 162 if (!dragImage || !dragImage->asLegacyBitmap(&bitmap, SkImage::kRO_LegacyBit
mapMode)) |
| 141 return nullptr; | 163 return nullptr; |
| 142 | 164 |
| 143 RefPtr<SkImage> skImage = image->imageForCurrentFrame(); | 165 return adoptPtr(new DragImage(bitmap, deviceScaleFactor, interpolationQualit
y)); |
| 144 if (!skImage) | |
| 145 return nullptr; | |
| 146 | |
| 147 ImageOrientation orientation; | |
| 148 if (shouldRespectImageOrientation == RespectImageOrientation && image->isBit
mapImage()) | |
| 149 orientation = toBitmapImage(image)->currentFrameOrientation(); | |
| 150 | |
| 151 SkBitmap bm; | |
| 152 RefPtr<SkImage> resizedImage = | |
| 153 resizeAndOrientImage(skImage.release(), orientation, imageScale, opacity
, interpolationQuality); | |
| 154 if (!resizedImage || !resizedImage->asLegacyBitmap(&bm, SkImage::kRO_LegacyB
itmapMode)) | |
| 155 return nullptr; | |
| 156 | |
| 157 return adoptPtr(new DragImage(bm, deviceScaleFactor, interpolationQuality)); | |
| 158 } | 166 } |
| 159 | 167 |
| 160 static Font deriveDragLabelFont(int size, FontWeight fontWeight, const FontDescr
iption& systemFont) | 168 static Font deriveDragLabelFont(int size, FontWeight fontWeight, const FontDescr
iption& systemFont) |
| 161 { | 169 { |
| 162 FontDescription description = systemFont; | 170 FontDescription description = systemFont; |
| 163 description.setWeight(fontWeight); | 171 description.setWeight(fontWeight); |
| 164 description.setSpecifiedSize(size); | 172 description.setSpecifiedSize(size); |
| 165 description.setComputedSize(size); | 173 description.setComputedSize(size); |
| 166 Font result(description); | 174 Font result(description); |
| 167 result.update(nullptr); | 175 result.update(nullptr); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 276 |
| 269 void DragImage::scale(float scaleX, float scaleY) | 277 void DragImage::scale(float scaleX, float scaleY) |
| 270 { | 278 { |
| 271 skia::ImageOperations::ResizeMethod resizeMethod = m_interpolationQuality ==
InterpolationNone ? skia::ImageOperations::RESIZE_BOX : skia::ImageOperations::
RESIZE_LANCZOS3; | 279 skia::ImageOperations::ResizeMethod resizeMethod = m_interpolationQuality ==
InterpolationNone ? skia::ImageOperations::RESIZE_BOX : skia::ImageOperations::
RESIZE_LANCZOS3; |
| 272 int imageWidth = scaleX * m_bitmap.width(); | 280 int imageWidth = scaleX * m_bitmap.width(); |
| 273 int imageHeight = scaleY * m_bitmap.height(); | 281 int imageHeight = scaleY * m_bitmap.height(); |
| 274 m_bitmap = skia::ImageOperations::Resize(m_bitmap, resizeMethod, imageWidth,
imageHeight); | 282 m_bitmap = skia::ImageOperations::Resize(m_bitmap, resizeMethod, imageWidth,
imageHeight); |
| 275 } | 283 } |
| 276 | 284 |
| 277 } // namespace blink | 285 } // namespace blink |
| OLD | NEW |