Commit 9ce069c9 authored by zandobersek@gmail.com's avatar zandobersek@gmail.com

Use Checked<uint32_t, RecordOverflow> instead of CheckedInt in GraphicsContext3D

https://bugs.webkit.org/show_bug.cgi?id=118988

Reviewed by Oliver Hunt.

Use the WTF's Checked class, with uint32_t as the numeric type and RecordOverflow as the overflow handler,
instead of the CheckedInt class. This removes a layering violation that's occurring due to including the CheckedInt
header that's currently located in the WebCore layer (alongside the HTML canvas code in Source/WebCore/html/canvas).

* platform/graphics/GraphicsContext3D.cpp:
(WebCore::GraphicsContext3D::computeImageSizeInBytes):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153062 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 576a5fb8
2013-07-23 Zan Dobersek <zdobersek@igalia.com>
Use Checked<uint32_t, RecordOverflow> instead of CheckedInt in GraphicsContext3D
https://bugs.webkit.org/show_bug.cgi?id=118988
Reviewed by Oliver Hunt.
Use the WTF's Checked class, with uint32_t as the numeric type and RecordOverflow as the overflow handler,
instead of the CheckedInt class. This removes a layering violation that's occurring due to including the CheckedInt
header that's currently located in the WebCore layer (alongside the HTML canvas code in Source/WebCore/html/canvas).
* platform/graphics/GraphicsContext3D.cpp:
(WebCore::GraphicsContext3D::computeImageSizeInBytes):
2013-07-23 Zalan Bujtas <zalan@apple.com>
REGRESSION(r152313): Links in certain twitter postings don't warp correctly on page
......@@ -31,7 +31,6 @@
#include "GraphicsContext3D.h"
#include "CheckedInt.h"
#include "Extensions3D.h"
#include "Image.h"
#include "ImageData.h"
......@@ -203,11 +202,11 @@ GC3Denum GraphicsContext3D::computeImageSizeInBytes(GC3Denum format, GC3Denum ty
*paddingInBytes = 0;
return GraphicsContext3D::NO_ERROR;
}
CheckedInt<uint32_t> checkedValue(bytesPerComponent * componentsPerPixel);
Checked<uint32_t, RecordOverflow> checkedValue = bytesPerComponent * componentsPerPixel;
checkedValue *= width;
if (!checkedValue.isValid())
if (checkedValue.hasOverflowed())
return GraphicsContext3D::INVALID_VALUE;
unsigned int validRowSize = checkedValue.value();
unsigned int validRowSize = checkedValue.unsafeGet();
unsigned int padding = 0;
unsigned int residual = validRowSize % alignment;
if (residual) {
......@@ -217,9 +216,9 @@ GC3Denum GraphicsContext3D::computeImageSizeInBytes(GC3Denum format, GC3Denum ty
// Last row needs no padding.
checkedValue *= (height - 1);
checkedValue += validRowSize;
if (!checkedValue.isValid())
if (checkedValue.hasOverflowed())
return GraphicsContext3D::INVALID_VALUE;
*imageSizeInBytes = checkedValue.value();
*imageSizeInBytes = checkedValue.unsafeGet();
if (paddingInBytes)
*paddingInBytes = padding;
return GraphicsContext3D::NO_ERROR;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment