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 18 matching lines...) Expand all Loading... |
29 #include "platform/fonts/Font.h" | 29 #include "platform/fonts/Font.h" |
30 #include "platform/fonts/FontCache.h" | 30 #include "platform/fonts/FontCache.h" |
31 #include "platform/fonts/FontDescription.h" | 31 #include "platform/fonts/FontDescription.h" |
32 #include "platform/fonts/FontMetrics.h" | 32 #include "platform/fonts/FontMetrics.h" |
33 #include "platform/geometry/FloatPoint.h" | 33 #include "platform/geometry/FloatPoint.h" |
34 #include "platform/geometry/FloatRect.h" | 34 #include "platform/geometry/FloatRect.h" |
35 #include "platform/geometry/IntPoint.h" | 35 #include "platform/geometry/IntPoint.h" |
36 #include "platform/graphics/BitmapImage.h" | 36 #include "platform/graphics/BitmapImage.h" |
37 #include "platform/graphics/Color.h" | 37 #include "platform/graphics/Color.h" |
38 #include "platform/graphics/GraphicsContext.h" | 38 #include "platform/graphics/GraphicsContext.h" |
| 39 #include "platform/graphics/GraphicsScreen.h" |
39 #include "platform/graphics/Image.h" | 40 #include "platform/graphics/Image.h" |
40 #include "platform/graphics/ImageBuffer.h" | 41 #include "platform/graphics/ImageBuffer.h" |
41 #include "platform/graphics/paint/DrawingRecorder.h" | 42 #include "platform/graphics/paint/DrawingRecorder.h" |
42 #include "platform/graphics/paint/SkPictureBuilder.h" | 43 #include "platform/graphics/paint/SkPictureBuilder.h" |
43 #include "platform/text/BidiTextRun.h" | 44 #include "platform/text/BidiTextRun.h" |
44 #include "platform/text/StringTruncator.h" | 45 #include "platform/text/StringTruncator.h" |
45 #include "platform/text/TextRun.h" | 46 #include "platform/text/TextRun.h" |
46 #include "platform/transforms/AffineTransform.h" | 47 #include "platform/transforms/AffineTransform.h" |
47 #include "platform/weborigin/KURL.h" | 48 #include "platform/weborigin/KURL.h" |
48 #include "skia/ext/image_operations.h" | 49 #include "skia/ext/image_operations.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 ? static_cast<float>(maxSize.height()) / size.height() : 1; | 130 ? static_cast<float>(maxSize.height()) / size.height() : 1; |
130 imageScale.scale(std::min(clampScaleX, clampScaleY)); | 131 imageScale.scale(std::min(clampScaleX, clampScaleY)); |
131 | 132 |
132 return imageScale; | 133 return imageScale; |
133 } | 134 } |
134 | 135 |
135 PassOwnPtr<DragImage> DragImage::create(Image* image, | 136 PassOwnPtr<DragImage> DragImage::create(Image* image, |
136 RespectImageOrientationEnum shouldRespectImageOrientation, float deviceScale
Factor, | 137 RespectImageOrientationEnum shouldRespectImageOrientation, float deviceScale
Factor, |
137 InterpolationQuality interpolationQuality, float opacity, FloatSize imageSca
le) | 138 InterpolationQuality interpolationQuality, float opacity, FloatSize imageSca
le) |
138 { | 139 { |
139 if (!image) | 140 RefPtr<SkImage> skImage = image ? image->imageForCurrentFrame() : nullptr; |
| 141 |
| 142 if (imageColorProfilesEnabled()) |
| 143 RELEASE_ASSERT(currentScreenId()); // There should be an active graphics
screen. |
| 144 |
| 145 if (skImage && imageColorProfilesEnabled() && image->isBitmapImage() && toBi
tmapImage(image)->hasColorProfile()) { |
| 146 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(image->size()); |
| 147 IntRect source = IntRect(IntPoint(), image->size()); |
| 148 image->draw(buffer->canvas(), SkPaint(), source, source, DoNotRespectIma
geOrientation, Image::ClampImageToSourceRect); |
| 149 skImage = buffer->newSkImageSnapshot(PreferNoAcceleration); |
| 150 } |
| 151 |
| 152 ImageOrientation orientation; |
| 153 if (skImage && shouldRespectImageOrientation == RespectImageOrientation && i
mage->isBitmapImage()) |
| 154 orientation = toBitmapImage(image)->currentFrameOrientation(); |
| 155 |
| 156 RefPtr<SkImage> dragImage; |
| 157 if (skImage) |
| 158 dragImage = resizeAndOrientImage(skImage.release(), orientation, imageSc
ale, opacity, interpolationQuality); |
| 159 |
| 160 SkBitmap bitmap; |
| 161 if (!dragImage || !dragImage->asLegacyBitmap(&bitmap, SkImage::kRO_LegacyBit
mapMode)) |
140 return nullptr; | 162 return nullptr; |
141 | 163 |
142 RefPtr<SkImage> skImage = image->imageForCurrentFrame(); | 164 return adoptPtr(new DragImage(bitmap, deviceScaleFactor, interpolationQualit
y)); |
143 if (!skImage) | |
144 return nullptr; | |
145 | |
146 ImageOrientation orientation; | |
147 if (shouldRespectImageOrientation == RespectImageOrientation && image->isBit
mapImage()) | |
148 orientation = toBitmapImage(image)->currentFrameOrientation(); | |
149 | |
150 SkBitmap bm; | |
151 RefPtr<SkImage> resizedImage = | |
152 resizeAndOrientImage(skImage.release(), orientation, imageScale, opacity
, interpolationQuality); | |
153 if (!resizedImage || !resizedImage->asLegacyBitmap(&bm, SkImage::kRO_LegacyB
itmapMode)) | |
154 return nullptr; | |
155 | |
156 return adoptPtr(new DragImage(bm, deviceScaleFactor, interpolationQuality)); | |
157 } | 165 } |
158 | 166 |
159 static Font deriveDragLabelFont(int size, FontWeight fontWeight, const FontDescr
iption& systemFont) | 167 static Font deriveDragLabelFont(int size, FontWeight fontWeight, const FontDescr
iption& systemFont) |
160 { | 168 { |
161 FontDescription description = systemFont; | 169 FontDescription description = systemFont; |
162 description.setWeight(fontWeight); | 170 description.setWeight(fontWeight); |
163 description.setSpecifiedSize(size); | 171 description.setSpecifiedSize(size); |
164 description.setComputedSize(size); | 172 description.setComputedSize(size); |
165 Font result(description); | 173 Font result(description); |
166 result.update(nullptr); | 174 result.update(nullptr); |
(...skipping 101 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 |