| OLD | NEW |
| 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" |
| 11 #include "core/css/parser/CSSParser.h" | 11 #include "core/css/parser/CSSParser.h" |
| 12 #include "core/dom/ExecutionContext.h" |
| 12 #include "core/dom/NotShared.h" | 13 #include "core/dom/NotShared.h" |
| 13 #include "core/frame/ImageBitmap.h" | 14 #include "core/frame/ImageBitmap.h" |
| 14 #include "core/html/HTMLCanvasElement.h" | 15 #include "core/html/HTMLCanvasElement.h" |
| 15 #include "core/html/HTMLImageElement.h" | 16 #include "core/html/HTMLImageElement.h" |
| 16 #include "core/html/HTMLVideoElement.h" | 17 #include "core/html/HTMLVideoElement.h" |
| 17 #include "core/html/ImageData.h" | 18 #include "core/html/ImageData.h" |
| 18 #include "core/offscreencanvas/OffscreenCanvas.h" | 19 #include "core/offscreencanvas/OffscreenCanvas.h" |
| 19 #include "core/svg/SVGImageElement.h" | 20 #include "core/svg/SVGImageElement.h" |
| 20 #include "modules/canvas2d/CanvasGradient.h" | 21 #include "modules/canvas2d/CanvasGradient.h" |
| 21 #include "modules/canvas2d/CanvasPattern.h" | 22 #include "modules/canvas2d/CanvasPattern.h" |
| (...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1347 ExpensiveCanvasHeuristicParameters::kExpensiveImageSizeRatio) | 1348 ExpensiveCanvasHeuristicParameters::kExpensiveImageSizeRatio) |
| 1348 is_expensive = true; | 1349 is_expensive = true; |
| 1349 | 1350 |
| 1350 if (is_expensive) { | 1351 if (is_expensive) { |
| 1351 ImageBuffer* buffer = GetImageBuffer(); | 1352 ImageBuffer* buffer = GetImageBuffer(); |
| 1352 if (buffer) | 1353 if (buffer) |
| 1353 buffer->SetHasExpensiveOp(); | 1354 buffer->SetHasExpensiveOp(); |
| 1354 } | 1355 } |
| 1355 | 1356 |
| 1356 if (OriginClean() && | 1357 if (OriginClean() && |
| 1357 WouldTaintOrigin(image_source, script_state->GetExecutionContext())) | 1358 WouldTaintOrigin(image_source, ExecutionContext::From(script_state))) |
| 1358 SetOriginTainted(); | 1359 SetOriginTainted(); |
| 1359 } | 1360 } |
| 1360 | 1361 |
| 1361 void BaseRenderingContext2D::ClearCanvas() { | 1362 void BaseRenderingContext2D::ClearCanvas() { |
| 1362 FloatRect canvas_rect(0, 0, Width(), Height()); | 1363 FloatRect canvas_rect(0, 0, Width(), Height()); |
| 1363 CheckOverdraw(canvas_rect, 0, CanvasRenderingContext2DState::kNoImage, | 1364 CheckOverdraw(canvas_rect, 0, CanvasRenderingContext2DState::kNoImage, |
| 1364 kClipFill); | 1365 kClipFill); |
| 1365 PaintCanvas* c = DrawingCanvas(); | 1366 PaintCanvas* c = DrawingCanvas(); |
| 1366 if (c) | 1367 if (c) |
| 1367 c->clear(HasAlpha() ? SK_ColorTRANSPARENT : SK_ColorBLACK); | 1368 c->clear(HasAlpha() ? SK_ColorTRANSPARENT : SK_ColorBLACK); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 break; | 1463 break; |
| 1463 case kIncompleteSourceImageStatus: | 1464 case kIncompleteSourceImageStatus: |
| 1464 return nullptr; | 1465 return nullptr; |
| 1465 default: | 1466 default: |
| 1466 NOTREACHED(); | 1467 NOTREACHED(); |
| 1467 return nullptr; | 1468 return nullptr; |
| 1468 } | 1469 } |
| 1469 DCHECK(image_for_rendering); | 1470 DCHECK(image_for_rendering); |
| 1470 | 1471 |
| 1471 bool origin_clean = | 1472 bool origin_clean = |
| 1472 !WouldTaintOrigin(image_source, script_state->GetExecutionContext()); | 1473 !WouldTaintOrigin(image_source, ExecutionContext::From(script_state)); |
| 1473 | 1474 |
| 1474 return CanvasPattern::Create(image_for_rendering.Release(), repeat_mode, | 1475 return CanvasPattern::Create(image_for_rendering.Release(), repeat_mode, |
| 1475 origin_clean); | 1476 origin_clean); |
| 1476 } | 1477 } |
| 1477 | 1478 |
| 1478 bool BaseRenderingContext2D::ComputeDirtyRect(const FloatRect& local_rect, | 1479 bool BaseRenderingContext2D::ComputeDirtyRect(const FloatRect& local_rect, |
| 1479 SkIRect* dirty_rect) { | 1480 SkIRect* dirty_rect) { |
| 1480 SkIRect clip_bounds; | 1481 SkIRect clip_bounds; |
| 1481 if (!DrawingCanvas()->getDeviceClipBounds(&clip_bounds)) | 1482 if (!DrawingCanvas()->getDeviceClipBounds(&clip_bounds)) |
| 1482 return false; | 1483 return false; |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2052 ExpensiveCanvasHeuristicParameters::kShadowFixedCost[index] * | 2053 ExpensiveCanvasHeuristicParameters::kShadowFixedCost[index] * |
| 2053 usage_counters_.num_blurred_shadows + | 2054 usage_counters_.num_blurred_shadows + |
| 2054 ExpensiveCanvasHeuristicParameters:: | 2055 ExpensiveCanvasHeuristicParameters:: |
| 2055 kShadowVariableCostPerAreaTimesShadowBlurSquared[index] * | 2056 kShadowVariableCostPerAreaTimesShadowBlurSquared[index] * |
| 2056 usage_counters_.bounding_box_area_times_shadow_blur_squared; | 2057 usage_counters_.bounding_box_area_times_shadow_blur_squared; |
| 2057 | 2058 |
| 2058 return basic_cost_of_draw_calls + fill_type_adjustment + shadow_adjustment; | 2059 return basic_cost_of_draw_calls + fill_type_adjustment + shadow_adjustment; |
| 2059 } | 2060 } |
| 2060 | 2061 |
| 2061 } // namespace blink | 2062 } // namespace blink |
| OLD | NEW |