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 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro
pRect.y())), srcRect.size()); | 75 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro
pRect.y())), srcRect.size()); |
76 } | 76 } |
77 | 77 |
78 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect) | 78 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect) |
79 : m_imageElement(nullptr) | 79 : m_imageElement(nullptr) |
80 , m_cropRect(cropRect) | 80 , m_cropRect(cropRect) |
81 , m_bitmapOffset(IntPoint()) | 81 , m_bitmapOffset(IntPoint()) |
82 { | 82 { |
83 CanvasRenderingContext* sourceContext = canvas->renderingContext(); | 83 CanvasRenderingContext* sourceContext = canvas->renderingContext(); |
84 if (sourceContext && sourceContext->is3d()) | 84 if (sourceContext && sourceContext->is3d()) |
85 sourceContext->paintRenderingResultsToCanvas(CanvasRenderingContext::Bac
k); | 85 sourceContext->paintRenderingResultsToCanvas(BackBuffer); |
86 | 86 |
87 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), canvas->size())
); | 87 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), canvas->size())
); |
88 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro
pRect.y())), srcRect.size()); | 88 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro
pRect.y())), srcRect.size()); |
89 m_bitmap = cropImage(canvas->buffer()->copyImage(CopyBackingStore).get(), cr
opRect); | 89 m_bitmap = cropImage(canvas->buffer()->copyImage(CopyBackingStore).get(), cr
opRect); |
90 } | 90 } |
91 | 91 |
92 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect) | 92 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect) |
93 : m_imageElement(nullptr) | 93 : m_imageElement(nullptr) |
94 , m_cropRect(cropRect) | 94 , m_cropRect(cropRect) |
95 , m_bitmapOffset(IntPoint()) | 95 , m_bitmapOffset(IntPoint()) |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 return FloatSize(width(), height()); | 217 return FloatSize(width(), height()); |
218 } | 218 } |
219 | 219 |
220 void ImageBitmap::trace(Visitor* visitor) | 220 void ImageBitmap::trace(Visitor* visitor) |
221 { | 221 { |
222 visitor->trace(m_imageElement); | 222 visitor->trace(m_imageElement); |
223 ImageLoaderClient::trace(visitor); | 223 ImageLoaderClient::trace(visitor); |
224 } | 224 } |
225 | 225 |
226 } // namespace blink | 226 } // namespace blink |
OLD | NEW |