| 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 "core/frame/ImageBitmap.h" | 5 #include "core/frame/ImageBitmap.h" |
| 6 | 6 |
| 7 #include "core/html/HTMLCanvasElement.h" | 7 #include "core/html/HTMLCanvasElement.h" |
| 8 #include "core/html/HTMLVideoElement.h" | 8 #include "core/html/HTMLVideoElement.h" |
| 9 #include "core/html/ImageData.h" | 9 #include "core/html/ImageData.h" |
| 10 #include "third_party/skia/include/core/SkSurface.h" | 10 #include "third_party/skia/include/core/SkSurface.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 if (video->webMediaPlayer()) | 57 if (video->webMediaPlayer()) |
| 58 playerSize = video->webMediaPlayer()->naturalSize(); | 58 playerSize = video->webMediaPlayer()->naturalSize(); |
| 59 | 59 |
| 60 IntRect videoRect = IntRect(IntPoint(), playerSize); | 60 IntRect videoRect = IntRect(IntPoint(), playerSize); |
| 61 IntRect srcRect = intersection(cropRect, videoRect); | 61 IntRect srcRect = intersection(cropRect, videoRect); |
| 62 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(cropRect.size(), NonOpaque,
DoNotInitializeImagePixels); | 62 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(cropRect.size(), NonOpaque,
DoNotInitializeImagePixels); |
| 63 if (!buffer) | 63 if (!buffer) |
| 64 return; | 64 return; |
| 65 | 65 |
| 66 IntPoint dstPoint = IntPoint(std::max(0, -cropRect.x()), std::max(0, -cropRe
ct.y())); | 66 IntPoint dstPoint = IntPoint(std::max(0, -cropRect.x()), std::max(0, -cropRe
ct.y())); |
| 67 video->paintCurrentFrame(buffer->canvas(), IntRect(dstPoint, srcRect.size())
, nullptr); | 67 video->paintCurrentFrame(buffer->canvas(), IntRect(dstPoint, srcRect.size())
, nullptr, nullptr); |
| 68 m_image = StaticBitmapImage::create(buffer->newSkImageSnapshot(PreferNoAccel
eration)); | 68 m_image = StaticBitmapImage::create(buffer->newSkImageSnapshot(PreferNoAccel
eration)); |
| 69 m_image->setOriginClean(!video->wouldTaintOrigin(document->securityOrigin())
); | 69 m_image->setOriginClean(!video->wouldTaintOrigin(document->securityOrigin())
); |
| 70 } | 70 } |
| 71 | 71 |
| 72 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect, con
st ImageBitmapOptions& options) | 72 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect, con
st ImageBitmapOptions& options) |
| 73 { | 73 { |
| 74 ASSERT(canvas->isPaintable()); | 74 ASSERT(canvas->isPaintable()); |
| 75 m_image = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration).get(
), cropRect); | 75 m_image = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration).get(
), cropRect); |
| 76 m_image->setOriginClean(canvas->originClean()); | 76 m_image->setOriginClean(canvas->originClean()); |
| 77 } | 77 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 { | 218 { |
| 219 return FloatSize(width(), height()); | 219 return FloatSize(width(), height()); |
| 220 } | 220 } |
| 221 | 221 |
| 222 DEFINE_TRACE(ImageBitmap) | 222 DEFINE_TRACE(ImageBitmap) |
| 223 { | 223 { |
| 224 ImageLoaderClient::trace(visitor); | 224 ImageLoaderClient::trace(visitor); |
| 225 } | 225 } |
| 226 | 226 |
| 227 } // namespace blink | 227 } // namespace blink |
| OLD | NEW |