| OLD | NEW |
| 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 Loading... |
| 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" |
| 70 #include <math.h> | 71 #include <math.h> |
| 71 #include <v8.h> | 72 #include <v8.h> |
| 72 | 73 |
| 73 namespace blink { | 74 namespace blink { |
| 74 | 75 |
| 75 using namespace HTMLNames; | 76 using namespace HTMLNames; |
| 76 | 77 |
| 77 namespace { | 78 namespace { |
| 78 | 79 |
| 79 // These values come from the WhatWG spec. | 80 // These values come from the WhatWG spec. |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 // non-displayed state) and three (triple-buffered animations). | 821 // non-displayed state) and three (triple-buffered animations). |
| 821 // Adding 2 is a pessimistic but relevant estimate. | 822 // Adding 2 is a pessimistic but relevant estimate. |
| 822 // Note: These buffers might be allocated in GPU memory. | 823 // Note: These buffers might be allocated in GPU memory. |
| 823 bufferCount += 2; | 824 bufferCount += 2; |
| 824 } | 825 } |
| 825 } | 826 } |
| 826 if (m_copiedImage) | 827 if (m_copiedImage) |
| 827 bufferCount++; | 828 bufferCount++; |
| 828 | 829 |
| 829 // Four bytes per pixel per buffer. | 830 // Four bytes per pixel per buffer. |
| 830 Checked<intptr_t, RecordOverflow> checkedExternallyAllocatedMemory = 4 * buf
ferCount; | 831 CheckedNumeric<intptr_t> checkedExternallyAllocatedMemory = 4 * bufferCount; |
| 831 if (is3D()) | 832 if (is3D()) |
| 832 checkedExternallyAllocatedMemory += m_context->externallyAllocatedBytesP
erPixel(); | 833 checkedExternallyAllocatedMemory += m_context->externallyAllocatedBytesP
erPixel(); |
| 833 | 834 |
| 834 checkedExternallyAllocatedMemory *= width(); | 835 checkedExternallyAllocatedMemory *= width(); |
| 835 checkedExternallyAllocatedMemory *= height(); | 836 checkedExternallyAllocatedMemory *= height(); |
| 836 intptr_t externallyAllocatedMemory; | 837 intptr_t externallyAllocatedMemory = checkedExternallyAllocatedMemory.ValueO
rDefault(std::numeric_limits<intptr_t>::max()); |
| 837 if (checkedExternallyAllocatedMemory.safeGet(externallyAllocatedMemory) == C
heckedState::DidOverflow) | |
| 838 externallyAllocatedMemory = std::numeric_limits<intptr_t>::max(); | |
| 839 | 838 |
| 840 // Subtracting two intptr_t that are known to be positive will never underfl
ow. | 839 // Subtracting two intptr_t that are known to be positive will never underfl
ow. |
| 841 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(externallyA
llocatedMemory - m_externallyAllocatedMemory); | 840 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(externallyA
llocatedMemory - m_externallyAllocatedMemory); |
| 842 m_externallyAllocatedMemory = externallyAllocatedMemory; | 841 m_externallyAllocatedMemory = externallyAllocatedMemory; |
| 843 } | 842 } |
| 844 | 843 |
| 845 SkCanvas* HTMLCanvasElement::drawingCanvas() const | 844 SkCanvas* HTMLCanvasElement::drawingCanvas() const |
| 846 { | 845 { |
| 847 return buffer() ? m_imageBuffer->canvas() : nullptr; | 846 return buffer() ? m_imageBuffer->canvas() : nullptr; |
| 848 } | 847 } |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 } | 1079 } |
| 1081 | 1080 |
| 1082 std::pair<Element*, String> HTMLCanvasElement::getControlAndIdIfHitRegionExists(
const LayoutPoint& location) | 1081 std::pair<Element*, String> HTMLCanvasElement::getControlAndIdIfHitRegionExists(
const LayoutPoint& location) |
| 1083 { | 1082 { |
| 1084 if (m_context && m_context->is2d()) | 1083 if (m_context && m_context->is2d()) |
| 1085 return m_context->getControlAndIdIfHitRegionExists(location); | 1084 return m_context->getControlAndIdIfHitRegionExists(location); |
| 1086 return std::make_pair(nullptr, String()); | 1085 return std::make_pair(nullptr, String()); |
| 1087 } | 1086 } |
| 1088 | 1087 |
| 1089 } // namespace blink | 1088 } // namespace blink |
| OLD | NEW |