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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 m_imageElement->addClient(this); | 52 m_imageElement->addClient(this); |
53 | 53 |
54 ScriptWrappable::init(this); | 54 ScriptWrappable::init(this); |
55 } | 55 } |
56 | 56 |
57 ImageBitmap::ImageBitmap(HTMLVideoElement* video, const IntRect& cropRect) | 57 ImageBitmap::ImageBitmap(HTMLVideoElement* video, const IntRect& cropRect) |
58 : m_imageElement(nullptr) | 58 : m_imageElement(nullptr) |
59 , m_cropRect(cropRect) | 59 , m_cropRect(cropRect) |
60 , m_bitmapOffset(IntPoint()) | 60 , m_bitmapOffset(IntPoint()) |
61 { | 61 { |
62 IntRect videoRect = IntRect(IntPoint(), video->player()->naturalSize()); | 62 IntSize playerSize; |
| 63 |
| 64 if (video->webMediaPlayer()) |
| 65 playerSize = video->webMediaPlayer()->naturalSize(); |
| 66 |
| 67 IntRect videoRect = IntRect(IntPoint(), playerSize); |
63 IntRect srcRect = intersection(cropRect, videoRect); | 68 IntRect srcRect = intersection(cropRect, videoRect); |
64 IntRect dstRect(IntPoint(), srcRect.size()); | 69 IntRect dstRect(IntPoint(), srcRect.size()); |
65 | 70 |
66 OwnPtr<ImageBuffer> buf = ImageBuffer::create(videoRect.size()); | 71 OwnPtr<ImageBuffer> buf = ImageBuffer::create(videoRect.size()); |
67 if (!buf) | 72 if (!buf) |
68 return; | 73 return; |
69 GraphicsContext* c = buf->context(); | 74 GraphicsContext* c = buf->context(); |
70 c->clip(dstRect); | 75 c->clip(dstRect); |
71 c->translate(-srcRect.x(), -srcRect.y()); | 76 c->translate(-srcRect.x(), -srcRect.y()); |
72 video->paintCurrentFrameInContext(c, videoRect); | 77 video->paintCurrentFrameInContext(c, videoRect); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 { | 228 { |
224 return FloatSize(width(), height()); | 229 return FloatSize(width(), height()); |
225 } | 230 } |
226 | 231 |
227 void ImageBitmap::trace(Visitor* visitor) | 232 void ImageBitmap::trace(Visitor* visitor) |
228 { | 233 { |
229 ImageLoaderClient::trace(visitor); | 234 ImageLoaderClient::trace(visitor); |
230 } | 235 } |
231 | 236 |
232 } | 237 } |
OLD | NEW |