OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/frame/ImageBitmap.h" | 6 #include "core/frame/ImageBitmap.h" |
7 | 7 |
8 #include "core/html/HTMLCanvasElement.h" | 8 #include "core/html/HTMLCanvasElement.h" |
9 #include "core/html/HTMLVideoElement.h" | 9 #include "core/html/HTMLVideoElement.h" |
10 #include "core/html/ImageData.h" | 10 #include "core/html/ImageData.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 std::max(rect.height(), -rect.height())); | 25 std::max(rect.height(), -rect.height())); |
26 } | 26 } |
27 | 27 |
28 static inline PassRefPtr<Image> cropImage(Image* image, const IntRect& cropRect) | 28 static inline PassRefPtr<Image> cropImage(Image* image, const IntRect& cropRect) |
29 { | 29 { |
30 IntRect intersectRect = intersection(IntRect(IntPoint(), image->size()), cro
pRect); | 30 IntRect intersectRect = intersection(IntRect(IntPoint(), image->size()), cro
pRect); |
31 if (!intersectRect.width() || !intersectRect.height()) | 31 if (!intersectRect.width() || !intersectRect.height()) |
32 return nullptr; | 32 return nullptr; |
33 | 33 |
34 SkBitmap cropped; | 34 SkBitmap cropped; |
35 image->nativeImageForCurrentFrame()->bitmap().extractSubset(&cropped, inters
ectRect); | 35 image->bitmapForCurrentFrame().extractSubset(&cropped, intersectRect); |
36 return BitmapImage::create(NativeImageSkia::create(cropped)); | 36 return BitmapImage::create(cropped); |
37 } | 37 } |
38 | 38 |
39 ImageBitmap::ImageBitmap(HTMLImageElement* image, const IntRect& cropRect) | 39 ImageBitmap::ImageBitmap(HTMLImageElement* image, const IntRect& cropRect) |
40 : m_imageElement(image) | 40 : m_imageElement(image) |
41 , m_bitmap(nullptr) | 41 , m_bitmap(nullptr) |
42 , m_cropRect(cropRect) | 42 , m_cropRect(cropRect) |
43 { | 43 { |
44 IntRect srcRect = intersection(cropRect, IntRect(0, 0, image->width(), image
->height())); | 44 IntRect srcRect = intersection(cropRect, IntRect(0, 0, image->width(), image
->height())); |
45 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro
pRect.y())), srcRect.size()); | 45 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro
pRect.y())), srcRect.size()); |
46 m_bitmapOffset = srcRect.location(); | 46 m_bitmapOffset = srcRect.location(); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 return FloatSize(width(), height()); | 235 return FloatSize(width(), height()); |
236 } | 236 } |
237 | 237 |
238 DEFINE_TRACE(ImageBitmap) | 238 DEFINE_TRACE(ImageBitmap) |
239 { | 239 { |
240 visitor->trace(m_imageElement); | 240 visitor->trace(m_imageElement); |
241 ImageLoaderClient::trace(visitor); | 241 ImageLoaderClient::trace(visitor); |
242 } | 242 } |
243 | 243 |
244 } // namespace blink | 244 } // namespace blink |
OLD | NEW |