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

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp

Issue 2802353002: getImageData now finalizesFrame and disableAcceleration updates composit (Closed)
Patch Set: merge Created 3 years, 8 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/canvas2d/BaseRenderingContext2D.h" 5 #include "modules/canvas2d/BaseRenderingContext2D.h"
6 6
7 #include "bindings/core/v8/ExceptionMessages.h" 7 #include "bindings/core/v8/ExceptionMessages.h"
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "core/css/cssom/CSSURLImageValue.h" 10 #include "core/css/cssom/CSSURLImageValue.h"
(...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 if (!result) 1532 if (!result)
1533 exception_state.ThrowRangeError("Out of memory at ImageData creation"); 1533 exception_state.ThrowRangeError("Out of memory at ImageData creation");
1534 return result; 1534 return result;
1535 } 1535 }
1536 1536
1537 ImageData* BaseRenderingContext2D::getImageData( 1537 ImageData* BaseRenderingContext2D::getImageData(
1538 int sx, 1538 int sx,
1539 int sy, 1539 int sy,
1540 int sw, 1540 int sw,
1541 int sh, 1541 int sh,
1542 ExceptionState& exception_state) const { 1542 ExceptionState& exception_state) {
1543 if (!WTF::CheckMul(sw, sh).IsValid<int>()) { 1543 if (!WTF::CheckMul(sw, sh).IsValid<int>()) {
1544 exception_state.ThrowRangeError("Out of memory at ImageData creation"); 1544 exception_state.ThrowRangeError("Out of memory at ImageData creation");
1545 return nullptr; 1545 return nullptr;
1546 } 1546 }
1547 1547
1548 usage_counters_.num_get_image_data_calls++; 1548 usage_counters_.num_get_image_data_calls++;
1549 usage_counters_.area_get_image_data_calls += sw * sh; 1549 usage_counters_.area_get_image_data_calls += sw * sh;
1550 if (!OriginClean()) 1550 if (!OriginClean())
1551 exception_state.ThrowSecurityError( 1551 exception_state.ThrowSecurityError(
1552 "The canvas has been tainted by cross-origin data."); 1552 "The canvas has been tainted by cross-origin data.");
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 exception_state.ThrowRangeError("Out of memory at ImageData creation"); 1602 exception_state.ThrowRangeError("Out of memory at ImageData creation");
1603 return result; 1603 return result;
1604 } 1604 }
1605 1605
1606 WTF::ArrayBufferContents contents; 1606 WTF::ArrayBufferContents contents;
1607 if (!buffer->GetImageData(kUnmultiplied, image_data_rect, contents)) { 1607 if (!buffer->GetImageData(kUnmultiplied, image_data_rect, contents)) {
1608 exception_state.ThrowRangeError("Out of memory at ImageData creation"); 1608 exception_state.ThrowRangeError("Out of memory at ImageData creation");
1609 return nullptr; 1609 return nullptr;
1610 } 1610 }
1611 1611
1612 NeedsFinalizeFrame();
1613
1612 DOMArrayBuffer* array_buffer = DOMArrayBuffer::Create(contents); 1614 DOMArrayBuffer* array_buffer = DOMArrayBuffer::Create(contents);
1613 return ImageData::Create(image_data_rect.size(), 1615 return ImageData::Create(image_data_rect.size(),
1614 DOMUint8ClampedArray::Create( 1616 DOMUint8ClampedArray::Create(
1615 array_buffer, 0, array_buffer->ByteLength())); 1617 array_buffer, 0, array_buffer->ByteLength()));
1616 } 1618 }
1617 1619
1618 void BaseRenderingContext2D::putImageData(ImageData* data, 1620 void BaseRenderingContext2D::putImageData(ImageData* data,
1619 int dx, 1621 int dx,
1620 int dy, 1622 int dy,
1621 ExceptionState& exception_state) { 1623 ExceptionState& exception_state) {
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 ExpensiveCanvasHeuristicParameters::kShadowFixedCost[index] * 2050 ExpensiveCanvasHeuristicParameters::kShadowFixedCost[index] *
2049 usage_counters_.num_blurred_shadows + 2051 usage_counters_.num_blurred_shadows +
2050 ExpensiveCanvasHeuristicParameters:: 2052 ExpensiveCanvasHeuristicParameters::
2051 kShadowVariableCostPerAreaTimesShadowBlurSquared[index] * 2053 kShadowVariableCostPerAreaTimesShadowBlurSquared[index] *
2052 usage_counters_.bounding_box_area_times_shadow_blur_squared; 2054 usage_counters_.bounding_box_area_times_shadow_blur_squared;
2053 2055
2054 return basic_cost_of_draw_calls + fill_type_adjustment + shadow_adjustment; 2056 return basic_cost_of_draw_calls + fill_type_adjustment + shadow_adjustment;
2055 } 2057 }
2056 2058
2057 } // namespace blink 2059 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698