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 OpacityMode opacityMode = Opaque; |
102 ImageBitmapSourceType sourceType = FromImageData; | |
Justin Novosad
2015/10/14 14:25:28
No need to use temporaries like this when you alre
| |
103 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(data->size(), opacityMode, sourceType); | |
102 if (!buffer) | 104 if (!buffer) |
103 return; | 105 return; |
104 | 106 |
105 if (srcRect.width() > 0 && srcRect.height() > 0) | 107 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()))); | 108 buffer->putByteArray(Premultiplied, data->data()->data(), data->size(), srcRect, IntPoint(std::min(0, -cropRect.x()), std::min(0, -cropRect.y()))); |
107 | 109 |
108 m_bitmap = buffer->newImageSnapshot(); | 110 m_bitmap = buffer->newImageSnapshot(); |
109 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro pRect.y())), srcRect.size()); | 111 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro pRect.y())), srcRect.size()); |
110 } | 112 } |
111 | 113 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 return FloatSize(width(), height()); | 222 return FloatSize(width(), height()); |
221 } | 223 } |
222 | 224 |
223 DEFINE_TRACE(ImageBitmap) | 225 DEFINE_TRACE(ImageBitmap) |
224 { | 226 { |
225 visitor->trace(m_imageElement); | 227 visitor->trace(m_imageElement); |
226 ImageLoaderClient::trace(visitor); | 228 ImageLoaderClient::trace(visitor); |
227 } | 229 } |
228 | 230 |
229 } // namespace blink | 231 } // namespace blink |
OLD | NEW |