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

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

Issue 2785203002: Split Gradient impl into separate classes (Closed)
Patch Set: review 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 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 1841
1842 CanvasStyle* canvasStyle; 1842 CanvasStyle* canvasStyle;
1843 if (callType == FillText || callType == FillPath || callType == FillRect) { 1843 if (callType == FillText || callType == FillPath || callType == FillRect) {
1844 canvasStyle = state().fillStyle(); 1844 canvasStyle = state().fillStyle();
1845 } else { 1845 } else {
1846 canvasStyle = state().strokeStyle(); 1846 canvasStyle = state().strokeStyle();
1847 } 1847 }
1848 1848
1849 CanvasGradient* gradient = canvasStyle->getCanvasGradient(); 1849 CanvasGradient* gradient = canvasStyle->getCanvasGradient();
1850 if (gradient) { 1850 if (gradient) {
1851 if (gradient->getGradient()->isRadial()) { 1851 switch (gradient->getGradient()->getType()) {
1852 m_usageCounters.numRadialGradients++; 1852 case Gradient::Type::Linear:
1853 m_usageCounters.boundingBoxAreaFillType 1853 m_usageCounters.numLinearGradients++;
1854 [BaseRenderingContext2D::RadialGradientFillType] += 1854 m_usageCounters.boundingBoxAreaFillType
1855 boundingRectArea; 1855 [BaseRenderingContext2D::LinearGradientFillType] +=
1856 } else { 1856 boundingRectArea;
1857 m_usageCounters.numLinearGradients++; 1857 break;
1858 m_usageCounters.boundingBoxAreaFillType 1858 case Gradient::Type::Radial:
1859 [BaseRenderingContext2D::LinearGradientFillType] += 1859 m_usageCounters.numRadialGradients++;
1860 boundingRectArea; 1860 m_usageCounters.boundingBoxAreaFillType
1861 [BaseRenderingContext2D::RadialGradientFillType] +=
1862 boundingRectArea;
1863 break;
1864 default:
1865 NOTREACHED();
1861 } 1866 }
1862 } else if (canvasStyle->getCanvasPattern()) { 1867 } else if (canvasStyle->getCanvasPattern()) {
1863 m_usageCounters.numPatterns++; 1868 m_usageCounters.numPatterns++;
1864 m_usageCounters 1869 m_usageCounters
1865 .boundingBoxAreaFillType[BaseRenderingContext2D::PatternFillType] += 1870 .boundingBoxAreaFillType[BaseRenderingContext2D::PatternFillType] +=
1866 boundingRectArea; 1871 boundingRectArea;
1867 } else { 1872 } else {
1868 m_usageCounters 1873 m_usageCounters
1869 .boundingBoxAreaFillType[BaseRenderingContext2D::ColorFillType] += 1874 .boundingBoxAreaFillType[BaseRenderingContext2D::ColorFillType] +=
1870 boundingRectArea; 1875 boundingRectArea;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * 2030 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] *
2026 m_usageCounters.numBlurredShadows + 2031 m_usageCounters.numBlurredShadows +
2027 ExpensiveCanvasHeuristicParameters:: 2032 ExpensiveCanvasHeuristicParameters::
2028 ShadowVariableCostPerAreaTimesShadowBlurSquared[index] * 2033 ShadowVariableCostPerAreaTimesShadowBlurSquared[index] *
2029 m_usageCounters.boundingBoxAreaTimesShadowBlurSquared; 2034 m_usageCounters.boundingBoxAreaTimesShadowBlurSquared;
2030 2035
2031 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment; 2036 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment;
2032 } 2037 }
2033 2038
2034 } // namespace blink 2039 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698