| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 ASSERT(canvas->isPaintable()); | 91 ASSERT(canvas->isPaintable()); |
| 92 m_bitmap = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration), cr
opRect); | 92 m_bitmap = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration), cr
opRect); |
| 93 } | 93 } |
| 94 | 94 |
| 95 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect) | 95 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect) |
| 96 : m_imageElement(nullptr) | 96 : m_imageElement(nullptr) |
| 97 , m_cropRect(cropRect) | 97 , m_cropRect(cropRect) |
| 98 , m_bitmapOffset(IntPoint()) | 98 , m_bitmapOffset(IntPoint()) |
| 99 { | 99 { |
| 100 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size())); | 100 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size())); |
| 101 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(data->size()); | 101 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(data->size(), Opaque, DoNot
InitializeImagePixels); |
| 102 if (!buffer) | 102 if (!buffer) |
| 103 return; | 103 return; |
| 104 | 104 |
| 105 if (srcRect.width() > 0 && srcRect.height() > 0) | 105 if (srcRect.width() > 0 && srcRect.height() > 0) |
| 106 buffer->putByteArray(Premultiplied, data->data()->data(), data->size(),
srcRect, IntPoint(std::min(0, -cropRect.x()), std::min(0, -cropRect.y()))); | 106 buffer->putByteArray(Premultiplied, data->data()->data(), data->size(),
srcRect, IntPoint(std::min(0, -cropRect.x()), std::min(0, -cropRect.y()))); |
| 107 | 107 |
| 108 m_bitmap = buffer->newImageSnapshot(); | 108 m_bitmap = buffer->newImageSnapshot(); |
| 109 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro
pRect.y())), srcRect.size()); | 109 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro
pRect.y())), srcRect.size()); |
| 110 } | 110 } |
| 111 | 111 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 return FloatSize(width(), height()); | 220 return FloatSize(width(), height()); |
| 221 } | 221 } |
| 222 | 222 |
| 223 DEFINE_TRACE(ImageBitmap) | 223 DEFINE_TRACE(ImageBitmap) |
| 224 { | 224 { |
| 225 visitor->trace(m_imageElement); | 225 visitor->trace(m_imageElement); |
| 226 ImageLoaderClient::trace(visitor); | 226 ImageLoaderClient::trace(visitor); |
| 227 } | 227 } |
| 228 | 228 |
| 229 } // namespace blink | 229 } // namespace blink |
| OLD | NEW |