| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 75 } | 75 } | 
| 76 | 76 | 
| 77 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect) | 77 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect) | 
| 78     : m_imageElement(nullptr) | 78     : m_imageElement(nullptr) | 
| 79     , m_cropRect(cropRect) | 79     , m_cropRect(cropRect) | 
| 80     , m_bitmapOffset(IntPoint()) | 80     , m_bitmapOffset(IntPoint()) | 
| 81 { | 81 { | 
| 82     IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), canvas->size())
     ); | 82     IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), canvas->size())
     ); | 
| 83     m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro
     pRect.y())), srcRect.size()); | 83     m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro
     pRect.y())), srcRect.size()); | 
| 84     ASSERT(canvas->isPaintable()); | 84     ASSERT(canvas->isPaintable()); | 
| 85     m_bitmap = cropImage(canvas->copiedImage(BackBuffer).get(), cropRect); | 85     m_bitmap = cropImage(canvas->copiedImage(FrontBuffer).get(), cropRect); | 
| 86 } | 86 } | 
| 87 | 87 | 
| 88 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect) | 88 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect) | 
| 89     : m_imageElement(nullptr) | 89     : m_imageElement(nullptr) | 
| 90     , m_cropRect(cropRect) | 90     , m_cropRect(cropRect) | 
| 91     , m_bitmapOffset(IntPoint()) | 91     , m_bitmapOffset(IntPoint()) | 
| 92 { | 92 { | 
| 93     IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size())); | 93     IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size())); | 
| 94 | 94 | 
| 95     OwnPtr<ImageBuffer> buf = ImageBuffer::create(data->size()); | 95     OwnPtr<ImageBuffer> buf = ImageBuffer::create(data->size()); | 
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 213     return FloatSize(width(), height()); | 213     return FloatSize(width(), height()); | 
| 214 } | 214 } | 
| 215 | 215 | 
| 216 void ImageBitmap::trace(Visitor* visitor) | 216 void ImageBitmap::trace(Visitor* visitor) | 
| 217 { | 217 { | 
| 218     visitor->trace(m_imageElement); | 218     visitor->trace(m_imageElement); | 
| 219     ImageLoaderClient::trace(visitor); | 219     ImageLoaderClient::trace(visitor); | 
| 220 } | 220 } | 
| 221 | 221 | 
| 222 } // namespace blink | 222 } // namespace blink | 
| OLD | NEW | 
|---|