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

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/FilterOperationResolver.cpp

Issue 2326633002: Adds filter support for offscreen canvas (Closed)
Patch Set: Code using ConversionData Created 4 years, 1 month 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
10 * (http://www.torchmobile.com/) 10 * (http://www.torchmobile.com/)
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 feature = UseCounter::CSSFilterBlur; 110 feature = UseCounter::CSSFilterBlur;
111 break; 111 break;
112 case FilterOperation::DROP_SHADOW: 112 case FilterOperation::DROP_SHADOW:
113 feature = UseCounter::CSSFilterDropShadow; 113 feature = UseCounter::CSSFilterDropShadow;
114 break; 114 break;
115 }; 115 };
116 UseCounter::count(document, feature); 116 UseCounter::count(document, feature);
117 } 117 }
118 118
119 FilterOperations FilterOperationResolver::createFilterOperations( 119 FilterOperations FilterOperationResolver::createFilterOperations(
120 StyleResolverState& state, 120 StyleResolverState* state,
121 const CSSValue& inValue) { 121 const CSSValue& inValue) {
122 FilterOperations operations; 122 FilterOperations operations;
123 123
124 if (inValue.isIdentifierValue()) { 124 if (inValue.isIdentifierValue()) {
125 DCHECK_EQ(toCSSIdentifierValue(inValue).getValueID(), CSSValueNone); 125 DCHECK_EQ(toCSSIdentifierValue(inValue).getValueID(), CSSValueNone);
126 return operations; 126 return operations;
127 } 127 }
128 128
129 const CSSToLengthConversionData& conversionData = 129 const CSSToLengthConversionData* conversionData;
130 state.cssToLengthConversionData(); 130 if (state) {
131 conversionData = &(state->cssToLengthConversionData());
132 } else {
133 FontDescription fontDescription;
134 Font font(fontDescription);
135 static CSSToLengthConversionData::FontSizes fontSizes(10, 16, &font);
Justin Novosad 2016/11/08 20:59:23 These hard-coded values should be in constants. A
fserb 2017/01/17 17:58:44 Couldn't find it anywhere. The default on CSS Font
136 static CSSToLengthConversionData::ViewportSize viewportSize(1024, 768);
137 static CSSToLengthConversionData baseData(&ComputedStyle::initialStyle(),
esprehn 2016/11/22 01:38:37 I don't think you can do this, any number of worke
fserb 2017/01/17 17:58:44 I've removed the statics.
138 fontSizes, viewportSize, 1);
139 conversionData = &baseData;
140 }
141
131 for (auto& currValue : toCSSValueList(inValue)) { 142 for (auto& currValue : toCSSValueList(inValue)) {
132 if (currValue->isURIValue()) { 143 if (currValue->isURIValue()) {
133 countFilterUse(FilterOperation::REFERENCE, state.document()); 144 if (!state)
Justin Novosad 2016/11/08 20:59:23 Add a comment here to explain the the !state case
fserb 2017/01/17 17:58:44 done.
145 continue;
146 countFilterUse(FilterOperation::REFERENCE, state->document());
134 147
135 const CSSURIValue& urlValue = toCSSURIValue(*currValue); 148 const CSSURIValue& urlValue = toCSSURIValue(*currValue);
136 SVGElementProxy& elementProxy = 149 SVGElementProxy& elementProxy =
137 state.elementStyleResources().cachedOrPendingFromValue(urlValue); 150 state->elementStyleResources().cachedOrPendingFromValue(urlValue);
138 operations.operations().append( 151 operations.operations().append(
139 ReferenceFilterOperation::create(urlValue.value(), elementProxy)); 152 ReferenceFilterOperation::create(urlValue.value(), elementProxy));
140 continue; 153 continue;
141 } 154 }
142 155
143 const CSSFunctionValue* filterValue = toCSSFunctionValue(currValue.get()); 156 const CSSFunctionValue* filterValue = toCSSFunctionValue(currValue.get());
144 FilterOperation::OperationType operationType = 157 FilterOperation::OperationType operationType =
145 filterOperationForType(filterValue->functionType()); 158 filterOperationForType(filterValue->functionType());
146 countFilterUse(operationType, state.document()); 159 if (state)
160 countFilterUse(operationType, state->document());
esprehn 2016/11/22 01:38:37 I think you actually want to take an ExecutionCont
fserb 2017/01/17 17:58:44 added TODO.
147 DCHECK_LE(filterValue->length(), 1u); 161 DCHECK_LE(filterValue->length(), 1u);
148 162
149 const CSSPrimitiveValue* firstValue = 163 const CSSPrimitiveValue* firstValue =
150 filterValue->length() && filterValue->item(0).isPrimitiveValue() 164 filterValue->length() && filterValue->item(0).isPrimitiveValue()
151 ? &toCSSPrimitiveValue(filterValue->item(0)) 165 ? &toCSSPrimitiveValue(filterValue->item(0))
152 : nullptr; 166 : nullptr;
153 switch (filterValue->functionType()) { 167 switch (filterValue->functionType()) {
154 case CSSValueGrayscale: 168 case CSSValueGrayscale:
155 case CSSValueSepia: 169 case CSSValueSepia:
156 case CSSValueSaturate: { 170 case CSSValueSaturate: {
(...skipping 29 matching lines...) Expand all
186 amount /= 100; 200 amount /= 100;
187 } 201 }
188 202
189 operations.operations().append( 203 operations.operations().append(
190 BasicComponentTransferFilterOperation::create(amount, 204 BasicComponentTransferFilterOperation::create(amount,
191 operationType)); 205 operationType));
192 break; 206 break;
193 } 207 }
194 case CSSValueBlur: { 208 case CSSValueBlur: {
195 Length stdDeviation = Length(0, Fixed); 209 Length stdDeviation = Length(0, Fixed);
196 if (filterValue->length() >= 1) 210 if (filterValue->length() >= 1) {
197 stdDeviation = firstValue->convertToLength(conversionData); 211 stdDeviation = firstValue->convertToLength(*conversionData);
212 }
198 operations.operations().append( 213 operations.operations().append(
199 BlurFilterOperation::create(stdDeviation)); 214 BlurFilterOperation::create(stdDeviation));
200 break; 215 break;
201 } 216 }
202 case CSSValueDropShadow: { 217 case CSSValueDropShadow: {
203 const CSSShadowValue& item = toCSSShadowValue(filterValue->item(0)); 218 const CSSShadowValue& item = toCSSShadowValue(filterValue->item(0));
204 IntPoint location(item.x->computeLength<int>(conversionData), 219 IntPoint location;
205 item.y->computeLength<int>(conversionData)); 220 int blur;
206 int blur = 221
207 item.blur ? item.blur->computeLength<int>(conversionData) : 0; 222 location = IntPoint(item.x->computeLength<int>(*conversionData),
223 item.y->computeLength<int>(*conversionData));
224 blur = item.blur ? item.blur->computeLength<int>(*conversionData) : 0;
208 Color shadowColor = Color::black; 225 Color shadowColor = Color::black;
esprehn 2016/11/22 01:38:37 This is going to force all shadows to be black, th
fserb 2017/01/17 17:58:44 yep. This code got refactored on StyleBuilderConve
209 if (item.color) 226 if (item.color && state) {
210 shadowColor = state.document().textLinkColors().colorFromCSSValue( 227 shadowColor = state->document().textLinkColors().colorFromCSSValue(
211 *item.color, state.style()->color()); 228 *item.color, state->style()->color());
229 }
212 230
213 operations.operations().append( 231 operations.operations().append(
214 DropShadowFilterOperation::create(location, blur, shadowColor)); 232 DropShadowFilterOperation::create(location, blur, shadowColor));
215 break; 233 break;
216 } 234 }
217 default: 235 default:
218 ASSERT_NOT_REACHED(); 236 ASSERT_NOT_REACHED();
219 break; 237 break;
220 } 238 }
221 } 239 }
222 240
223 return operations; 241 return operations;
224 } 242 }
225 243
226 } // namespace blink 244 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698