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

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

Issue 1814563002: wtf/CheckedArithmetic.h delegates to base/numerics/safe_math.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert new check 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 6d81dc80039558c85962f842566ab745f8ff9e36..f1dfe2d9974eed1b36170c67e71f29d167308f19 100644
--- a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
+++ b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
@@ -55,6 +55,7 @@
#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"
@@ -284,10 +285,10 @@ void ImageBuffer::flushGpu(FlushReason reason)
bool ImageBuffer::getImageData(Multiply multiplied, const IntRect& rect, WTF::ArrayBufferContents& contents) const
{
- Checked<int, RecordOverflow> dataSize = 4;
+ CheckedNumeric<int> dataSize = 4;
dataSize *= rect.width();
dataSize *= rect.height();
- if (dataSize.hasOverflowed())
+ if (!dataSize.IsValid())
return false;
if (!isSurfaceValid()) {
@@ -362,12 +363,10 @@ void ImageBuffer::updateGPUMemoryUsage() const
if (this->isAccelerated()) {
// If image buffer is accelerated, we should keep track of GPU memory usage.
int gpuBufferCount = 2;
- Checked<intptr_t, RecordOverflow> checkedGPUUsage = 4 * gpuBufferCount;
+ CheckedNumeric<intptr_t> checkedGPUUsage = 4 * gpuBufferCount;
checkedGPUUsage *= this->size().width();
checkedGPUUsage *= this->size().height();
- intptr_t gpuMemoryUsage;
- if (checkedGPUUsage.safeGet(gpuMemoryUsage) == CheckedState::DidOverflow)
- gpuMemoryUsage = std::numeric_limits<intptr_t>::max();
+ intptr_t gpuMemoryUsage = checkedGPUUsage.ValueOrDefault(std::numeric_limits<intptr_t>::max());
s_globalGPUMemoryUsage += (gpuMemoryUsage - m_gpuMemoryUsage);
m_gpuMemoryUsage = gpuMemoryUsage;

Powered by Google App Engine
This is Rietveld 408576698