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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 IntRect normalizedCropRect = normalizeRect(cropRect); | 174 IntRect normalizedCropRect = normalizeRect(cropRect); |
175 return adoptRefWillBeNoop(new ImageBitmap(bitmap, normalizedCropRect)); | 175 return adoptRefWillBeNoop(new ImageBitmap(bitmap, normalizedCropRect)); |
176 } | 176 } |
177 | 177 |
178 PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(Image* image, const IntR
ect& cropRect) | 178 PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(Image* image, const IntR
ect& cropRect) |
179 { | 179 { |
180 IntRect normalizedCropRect = normalizeRect(cropRect); | 180 IntRect normalizedCropRect = normalizeRect(cropRect); |
181 return adoptRefWillBeNoop(new ImageBitmap(image, normalizedCropRect)); | 181 return adoptRefWillBeNoop(new ImageBitmap(image, normalizedCropRect)); |
182 } | 182 } |
183 | 183 |
184 PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::transfer() | |
185 { | |
186 RefPtrWillBeRawPtr<ImageBitmap> bitmap = adoptRefWillBeNoop(new ImageBitmap(
this, m_cropRect)); | |
187 if (m_imageElement) | |
188 m_imageElement.clear(); | |
189 if (m_bitmap) | |
190 m_bitmap.clear(); | |
191 m_bitmapRect.setLocation(IntPoint(0, 0)); | |
192 m_bitmapRect.setSize(IntSize(0, 0)); | |
193 m_cropRect = m_bitmapRect; | |
194 m_bitmapOffset.setX(0); | |
195 m_bitmapOffset.setY(0); | |
196 return bitmap.release(); | |
197 } | |
198 | |
199 void ImageBitmap::notifyImageSourceChanged() | 184 void ImageBitmap::notifyImageSourceChanged() |
200 { | 185 { |
201 m_bitmap = cropImage(m_imageElement->cachedImage()->image(), m_cropRect); | 186 m_bitmap = cropImage(m_imageElement->cachedImage()->image(), m_cropRect); |
202 m_bitmapOffset = IntPoint(); | 187 m_bitmapOffset = IntPoint(); |
203 m_imageElement = nullptr; | 188 m_imageElement = nullptr; |
204 } | 189 } |
205 | 190 |
206 PassRefPtr<Image> ImageBitmap::bitmapImage() const | 191 PassRefPtr<Image> ImageBitmap::bitmapImage() const |
207 { | 192 { |
208 ASSERT((m_imageElement || m_bitmap || !m_bitmapRect.width() || !m_bitmapRect
.height()) && (!m_imageElement || !m_bitmap)); | 193 ASSERT((m_imageElement || m_bitmap || !m_bitmapRect.width() || !m_bitmapRect
.height()) && (!m_imageElement || !m_bitmap)); |
(...skipping 26 matching lines...) Expand all Loading... |
235 return FloatSize(width(), height()); | 220 return FloatSize(width(), height()); |
236 } | 221 } |
237 | 222 |
238 DEFINE_TRACE(ImageBitmap) | 223 DEFINE_TRACE(ImageBitmap) |
239 { | 224 { |
240 visitor->trace(m_imageElement); | 225 visitor->trace(m_imageElement); |
241 ImageLoaderClient::trace(visitor); | 226 ImageLoaderClient::trace(visitor); |
242 } | 227 } |
243 | 228 |
244 } // namespace blink | 229 } // namespace blink |
OLD | NEW |