Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Unified Diff: third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp

Issue 1822353002: Revert of wtf/CheckedArithmetic.h delegates to base/numerics/safe_math.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
index f1dfe2d9974eed1b36170c67e71f29d167308f19..6d81dc80039558c85962f842566ab745f8ff9e36 100644
--- a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
+++ b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
@@ -55,7 +55,6 @@
#include "third_party/skia/include/gpu/GrContext.h"
#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
#include "wtf/ArrayBufferContents.h"
-#include "wtf/CheckedNumeric.h"
#include "wtf/MathExtras.h"
#include "wtf/Vector.h"
#include "wtf/text/Base64.h"
@@ -285,10 +284,10 @@
bool ImageBuffer::getImageData(Multiply multiplied, const IntRect& rect, WTF::ArrayBufferContents& contents) const
{
- CheckedNumeric<int> dataSize = 4;
+ Checked<int, RecordOverflow> dataSize = 4;
dataSize *= rect.width();
dataSize *= rect.height();
- if (!dataSize.IsValid())
+ if (dataSize.hasOverflowed())
return false;
if (!isSurfaceValid()) {
@@ -363,10 +362,12 @@
if (this->isAccelerated()) {
// If image buffer is accelerated, we should keep track of GPU memory usage.
int gpuBufferCount = 2;
- CheckedNumeric<intptr_t> checkedGPUUsage = 4 * gpuBufferCount;
+ Checked<intptr_t, RecordOverflow> checkedGPUUsage = 4 * gpuBufferCount;
checkedGPUUsage *= this->size().width();
checkedGPUUsage *= this->size().height();
- intptr_t gpuMemoryUsage = checkedGPUUsage.ValueOrDefault(std::numeric_limits<intptr_t>::max());
+ intptr_t gpuMemoryUsage;
+ if (checkedGPUUsage.safeGet(gpuMemoryUsage) == CheckedState::DidOverflow)
+ gpuMemoryUsage = std::numeric_limits<intptr_t>::max();
s_globalGPUMemoryUsage += (gpuMemoryUsage - m_gpuMemoryUsage);
m_gpuMemoryUsage = gpuMemoryUsage;

Powered by Google App Engine
This is Rietveld 408576698