Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/canvas/OffScreenCanvas.cpp |
| diff --git a/third_party/WebKit/Source/core/html/canvas/OffScreenCanvas.cpp b/third_party/WebKit/Source/core/html/canvas/OffScreenCanvas.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..76ab22b7c43ce9beba886c099f16134c3b758127 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/html/canvas/OffScreenCanvas.cpp |
| @@ -0,0 +1,46 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "config.h" |
| +#include "core/html/canvas/OffScreenCanvas.h" |
| + |
| +#include "wtf/MathExtras.h" |
| + |
| +namespace blink { |
| + |
| +OffScreenCanvas* OffScreenCanvas::create(unsigned width, unsigned height) |
| +{ |
| + if (width > INT_MAX) |
|
Justin Novosad
2015/12/03 19:06:11
This condition is not necessary. it is implied in
xidachen
2015/12/03 20:42:22
Done.
|
| + width = clampTo<int>(width); |
| + if (height > INT_MAX) |
| + height = clampTo<int>(height); |
| + return new OffScreenCanvas(IntSize(width, height)); |
| +} |
| + |
| +void OffScreenCanvas::setWidth(unsigned width) |
| +{ |
| + if (width > INT_MAX) |
| + m_size.setWidth(clampTo<int>(width)); |
| + else |
| + m_size.setWidth(width); |
| +} |
| + |
| +void OffScreenCanvas::setHeight(unsigned height) |
| +{ |
| + if (height > INT_MAX) |
| + m_size.setHeight(clampTo<int>(height)); |
| + else |
| + m_size.setHeight(height); |
| +} |
| + |
| +OffScreenCanvas::OffScreenCanvas(const IntSize& size) |
| + : m_size(size) |
| +{ |
| +} |
| + |
| +DEFINE_TRACE(OffScreenCanvas) |
| +{ |
| +} |
| + |
| +} // namespace blink |