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(), Opaque, DoNot InitializeImagePixels); | 101 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(data->size(), NonOpaque, Do NotInitializeImagePixels); |
xidachen
2015/10/18 14:08:48
This part is tricky. It was set to be Opaque on pu
jbroman
2015/10/18 15:44:14
I'd like Justin's opinion, but it seems to me that
xidachen
2015/10/18 15:44:52
Hmmm, I just found something very strange. With th
jbroman
2015/10/18 15:48:00
Yeah, something fishy is going on (or I'm misunder
Justin Novosad
2015/10/19 19:13:20
I agree that the image buffer should be marked as
| |
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()))); |
Justin Novosad
2015/10/19 19:13:20
This operation is an over-write. If it covers buff
| |
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 |
112 ImageBitmap::ImageBitmap(ImageBitmap* bitmap, const IntRect& cropRect) | 112 ImageBitmap::ImageBitmap(ImageBitmap* bitmap, const IntRect& cropRect) |
113 : m_imageElement(bitmap->imageElement()) | 113 : m_imageElement(bitmap->imageElement()) |
114 , m_bitmap(nullptr) | 114 , m_bitmap(nullptr) |
115 , m_cropRect(cropRect) | 115 , m_cropRect(cropRect) |
116 , m_bitmapOffset(IntPoint()) | 116 , m_bitmapOffset(IntPoint()) |
(...skipping 103 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 |