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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "platform/graphics/CanvasMetrics.h" 60 #include "platform/graphics/CanvasMetrics.h"
61 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" 61 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h"
62 #include "platform/graphics/ImageBuffer.h" 62 #include "platform/graphics/ImageBuffer.h"
63 #include "platform/graphics/RecordingImageBufferSurface.h" 63 #include "platform/graphics/RecordingImageBufferSurface.h"
64 #include "platform/graphics/StaticBitmapImage.h" 64 #include "platform/graphics/StaticBitmapImage.h"
65 #include "platform/graphics/UnacceleratedImageBufferSurface.h" 65 #include "platform/graphics/UnacceleratedImageBufferSurface.h"
66 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" 66 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h"
67 #include "platform/transforms/AffineTransform.h" 67 #include "platform/transforms/AffineTransform.h"
68 #include "public/platform/Platform.h" 68 #include "public/platform/Platform.h"
69 #include "public/platform/WebTraceLocation.h" 69 #include "public/platform/WebTraceLocation.h"
70 #include "wtf/CheckedNumeric.h"
71 #include <math.h> 70 #include <math.h>
72 #include <v8.h> 71 #include <v8.h>
73 72
74 namespace blink { 73 namespace blink {
75 74
76 using namespace HTMLNames; 75 using namespace HTMLNames;
77 76
78 namespace { 77 namespace {
79 78
80 // These values come from the WhatWG spec. 79 // These values come from the WhatWG spec.
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 // non-displayed state) and three (triple-buffered animations). 820 // non-displayed state) and three (triple-buffered animations).
822 // Adding 2 is a pessimistic but relevant estimate. 821 // Adding 2 is a pessimistic but relevant estimate.
823 // Note: These buffers might be allocated in GPU memory. 822 // Note: These buffers might be allocated in GPU memory.
824 bufferCount += 2; 823 bufferCount += 2;
825 } 824 }
826 } 825 }
827 if (m_copiedImage) 826 if (m_copiedImage)
828 bufferCount++; 827 bufferCount++;
829 828
830 // Four bytes per pixel per buffer. 829 // Four bytes per pixel per buffer.
831 CheckedNumeric<intptr_t> checkedExternallyAllocatedMemory = 4 * bufferCount; 830 Checked<intptr_t, RecordOverflow> checkedExternallyAllocatedMemory = 4 * buf ferCount;
832 if (is3D()) 831 if (is3D())
833 checkedExternallyAllocatedMemory += m_context->externallyAllocatedBytesP erPixel(); 832 checkedExternallyAllocatedMemory += m_context->externallyAllocatedBytesP erPixel();
834 833
835 checkedExternallyAllocatedMemory *= width(); 834 checkedExternallyAllocatedMemory *= width();
836 checkedExternallyAllocatedMemory *= height(); 835 checkedExternallyAllocatedMemory *= height();
837 intptr_t externallyAllocatedMemory = checkedExternallyAllocatedMemory.ValueO rDefault(std::numeric_limits<intptr_t>::max()); 836 intptr_t externallyAllocatedMemory;
837 if (checkedExternallyAllocatedMemory.safeGet(externallyAllocatedMemory) == C heckedState::DidOverflow)
838 externallyAllocatedMemory = std::numeric_limits<intptr_t>::max();
838 839
839 // Subtracting two intptr_t that are known to be positive will never underfl ow. 840 // Subtracting two intptr_t that are known to be positive will never underfl ow.
840 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(externallyA llocatedMemory - m_externallyAllocatedMemory); 841 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(externallyA llocatedMemory - m_externallyAllocatedMemory);
841 m_externallyAllocatedMemory = externallyAllocatedMemory; 842 m_externallyAllocatedMemory = externallyAllocatedMemory;
842 } 843 }
843 844
844 SkCanvas* HTMLCanvasElement::drawingCanvas() const 845 SkCanvas* HTMLCanvasElement::drawingCanvas() const
845 { 846 {
846 return buffer() ? m_imageBuffer->canvas() : nullptr; 847 return buffer() ? m_imageBuffer->canvas() : nullptr;
847 } 848 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 } 1080 }
1080 1081
1081 std::pair<Element*, String> HTMLCanvasElement::getControlAndIdIfHitRegionExists( const LayoutPoint& location) 1082 std::pair<Element*, String> HTMLCanvasElement::getControlAndIdIfHitRegionExists( const LayoutPoint& location)
1082 { 1083 {
1083 if (m_context && m_context->is2d()) 1084 if (m_context && m_context->is2d())
1084 return m_context->getControlAndIdIfHitRegionExists(location); 1085 return m_context->getControlAndIdIfHitRegionExists(location);
1085 return std::make_pair(nullptr, String()); 1086 return std::make_pair(nullptr, String());
1086 } 1087 }
1087 1088
1088 } // namespace blink 1089 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ImageResource.cpp ('k') | third_party/WebKit/Source/core/html/ImageData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698