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

Side by Side Diff: third_party/WebKit/Source/core/paint/FilterEffectBuilder.cpp

Issue 2392443009: reflow comments in core/paint (Closed)
Patch Set: Created 4 years, 2 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) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 matrix.uncheckedAppend(0); 60 matrix.uncheckedAppend(0);
61 matrix.uncheckedAppend(0); 61 matrix.uncheckedAppend(0);
62 matrix.uncheckedAppend(0); 62 matrix.uncheckedAppend(0);
63 matrix.uncheckedAppend(1); 63 matrix.uncheckedAppend(1);
64 matrix.uncheckedAppend(0); 64 matrix.uncheckedAppend(0);
65 } 65 }
66 66
67 Vector<float> grayscaleMatrix(double amount) { 67 Vector<float> grayscaleMatrix(double amount) {
68 double oneMinusAmount = clampTo(1 - amount, 0.0, 1.0); 68 double oneMinusAmount = clampTo(1 - amount, 0.0, 1.0);
69 69
70 // See https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#grayscaleEq uivalent 70 // See
71 // https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#grayscaleEquiva lent
71 // for information on parameters. 72 // for information on parameters.
72 Vector<float> matrix; 73 Vector<float> matrix;
73 matrix.reserveInitialCapacity(20); 74 matrix.reserveInitialCapacity(20);
74 75
75 matrix.uncheckedAppend(clampTo<float>(0.2126 + 0.7874 * oneMinusAmount)); 76 matrix.uncheckedAppend(clampTo<float>(0.2126 + 0.7874 * oneMinusAmount));
76 matrix.uncheckedAppend(clampTo<float>(0.7152 - 0.7152 * oneMinusAmount)); 77 matrix.uncheckedAppend(clampTo<float>(0.7152 - 0.7152 * oneMinusAmount));
77 matrix.uncheckedAppend(clampTo<float>(0.0722 - 0.0722 * oneMinusAmount)); 78 matrix.uncheckedAppend(clampTo<float>(0.0722 - 0.0722 * oneMinusAmount));
78 endMatrixRow(matrix); 79 endMatrixRow(matrix);
79 80
80 matrix.uncheckedAppend(clampTo<float>(0.2126 - 0.2126 * oneMinusAmount)); 81 matrix.uncheckedAppend(clampTo<float>(0.2126 - 0.2126 * oneMinusAmount));
81 matrix.uncheckedAppend(clampTo<float>(0.7152 + 0.2848 * oneMinusAmount)); 82 matrix.uncheckedAppend(clampTo<float>(0.7152 + 0.2848 * oneMinusAmount));
82 matrix.uncheckedAppend(clampTo<float>(0.0722 - 0.0722 * oneMinusAmount)); 83 matrix.uncheckedAppend(clampTo<float>(0.0722 - 0.0722 * oneMinusAmount));
83 endMatrixRow(matrix); 84 endMatrixRow(matrix);
84 85
85 matrix.uncheckedAppend(clampTo<float>(0.2126 - 0.2126 * oneMinusAmount)); 86 matrix.uncheckedAppend(clampTo<float>(0.2126 - 0.2126 * oneMinusAmount));
86 matrix.uncheckedAppend(clampTo<float>(0.7152 - 0.7152 * oneMinusAmount)); 87 matrix.uncheckedAppend(clampTo<float>(0.7152 - 0.7152 * oneMinusAmount));
87 matrix.uncheckedAppend(clampTo<float>(0.0722 + 0.9278 * oneMinusAmount)); 88 matrix.uncheckedAppend(clampTo<float>(0.0722 + 0.9278 * oneMinusAmount));
88 endMatrixRow(matrix); 89 endMatrixRow(matrix);
89 90
90 lastMatrixRow(matrix); 91 lastMatrixRow(matrix);
91 return matrix; 92 return matrix;
92 } 93 }
93 94
94 Vector<float> sepiaMatrix(double amount) { 95 Vector<float> sepiaMatrix(double amount) {
95 double oneMinusAmount = clampTo(1 - amount, 0.0, 1.0); 96 double oneMinusAmount = clampTo(1 - amount, 0.0, 1.0);
96 97
97 // See https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#sepiaEquiva lent 98 // See
99 // https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#sepiaEquivalent
98 // for information on parameters. 100 // for information on parameters.
99 Vector<float> matrix; 101 Vector<float> matrix;
100 matrix.reserveInitialCapacity(20); 102 matrix.reserveInitialCapacity(20);
101 103
102 matrix.uncheckedAppend(clampTo<float>(0.393 + 0.607 * oneMinusAmount)); 104 matrix.uncheckedAppend(clampTo<float>(0.393 + 0.607 * oneMinusAmount));
103 matrix.uncheckedAppend(clampTo<float>(0.769 - 0.769 * oneMinusAmount)); 105 matrix.uncheckedAppend(clampTo<float>(0.769 - 0.769 * oneMinusAmount));
104 matrix.uncheckedAppend(clampTo<float>(0.189 - 0.189 * oneMinusAmount)); 106 matrix.uncheckedAppend(clampTo<float>(0.189 - 0.189 * oneMinusAmount));
105 endMatrixRow(matrix); 107 endMatrixRow(matrix);
106 108
107 matrix.uncheckedAppend(clampTo<float>(0.349 - 0.349 * oneMinusAmount)); 109 matrix.uncheckedAppend(clampTo<float>(0.349 - 0.349 * oneMinusAmount));
(...skipping 21 matching lines...) Expand all
129 m_referenceBox(zoomedReferenceBox), 131 m_referenceBox(zoomedReferenceBox),
130 m_zoom(zoom), 132 m_zoom(zoom),
131 m_fillPaint(fillPaint), 133 m_fillPaint(fillPaint),
132 m_strokePaint(strokePaint) { 134 m_strokePaint(strokePaint) {
133 if (m_zoom != 1) 135 if (m_zoom != 1)
134 m_referenceBox.scale(1 / m_zoom); 136 m_referenceBox.scale(1 / m_zoom);
135 } 137 }
136 138
137 FilterEffect* FilterEffectBuilder::buildFilterEffect( 139 FilterEffect* FilterEffectBuilder::buildFilterEffect(
138 const FilterOperations& operations) const { 140 const FilterOperations& operations) const {
139 // Create a parent filter for shorthand filters. These have already been scale d by the CSS code for page zoom, so scale is 1.0 here. 141 // Create a parent filter for shorthand filters. These have already been
142 // scaled by the CSS code for page zoom, so scale is 1.0 here.
140 Filter* parentFilter = Filter::create(1.0f); 143 Filter* parentFilter = Filter::create(1.0f);
141 FilterEffect* previousEffect = parentFilter->getSourceGraphic(); 144 FilterEffect* previousEffect = parentFilter->getSourceGraphic();
142 for (FilterOperation* filterOperation : operations.operations()) { 145 for (FilterOperation* filterOperation : operations.operations()) {
143 FilterEffect* effect = nullptr; 146 FilterEffect* effect = nullptr;
144 switch (filterOperation->type()) { 147 switch (filterOperation->type()) {
145 case FilterOperation::REFERENCE: { 148 case FilterOperation::REFERENCE: {
146 ReferenceFilterOperation& referenceOperation = 149 ReferenceFilterOperation& referenceOperation =
147 toReferenceFilterOperation(*filterOperation); 150 toReferenceFilterOperation(*filterOperation);
148 if (Filter* referenceFilter = 151 if (Filter* referenceFilter =
149 buildReferenceFilter(referenceOperation, previousEffect)) { 152 buildReferenceFilter(referenceOperation, previousEffect)) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 effect = FEBoxReflect::create(parentFilter, 274 effect = FEBoxReflect::create(parentFilter,
272 boxReflectOperation->reflection()); 275 boxReflectOperation->reflection());
273 break; 276 break;
274 } 277 }
275 default: 278 default:
276 break; 279 break;
277 } 280 }
278 281
279 if (effect) { 282 if (effect) {
280 if (filterOperation->type() != FilterOperation::REFERENCE) { 283 if (filterOperation->type() != FilterOperation::REFERENCE) {
281 // Unlike SVG, filters applied here should not clip to their primitive s ubregions. 284 // Unlike SVG, filters applied here should not clip to their primitive
285 // subregions.
282 effect->setClipsToBounds(false); 286 effect->setClipsToBounds(false);
283 effect->setOperatingColorSpace(ColorSpaceDeviceRGB); 287 effect->setOperatingColorSpace(ColorSpaceDeviceRGB);
284 effect->inputEffects().append(previousEffect); 288 effect->inputEffects().append(previousEffect);
285 } 289 }
286 if (previousEffect->originTainted()) 290 if (previousEffect->originTainted())
287 effect->setOriginTainted(); 291 effect->setOriginTainted();
288 previousEffect = effect; 292 previousEffect = effect;
289 } 293 }
290 } 294 }
291 return previousEffect; 295 return previousEffect;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 Filter::create(m_referenceBox, filterRegion, m_zoom, unitScaling); 434 Filter::create(m_referenceBox, filterRegion, m_zoom, unitScaling);
431 if (!previousEffect) 435 if (!previousEffect)
432 previousEffect = result->getSourceGraphic(); 436 previousEffect = result->getSourceGraphic();
433 SVGFilterBuilder builder(previousEffect, nodeMap, m_fillPaint, m_strokePaint); 437 SVGFilterBuilder builder(previousEffect, nodeMap, m_fillPaint, m_strokePaint);
434 builder.buildGraph(result, filterElement, m_referenceBox); 438 builder.buildGraph(result, filterElement, m_referenceBox);
435 result->setLastEffect(builder.lastEffect()); 439 result->setLastEffect(builder.lastEffect());
436 return result; 440 return result;
437 } 441 }
438 442
439 } // namespace blink 443 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/ClipPathClipper.cpp ('k') | third_party/WebKit/Source/core/paint/FilterPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698