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

Side by Side Diff: Source/core/layout/svg/ReferenceFilterBuilder.cpp

Issue 1056353003: Derive the SourceAlpha filter input from SourceGraphic (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix variable name. Created 5 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Adobe Systems Inc. All rights reserved. 2 * Copyright (C) 2013 Adobe Systems Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * Copyright (C) 2011 Apple Inc. All rights reserved. 4 * Copyright (C) 2011 Apple Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 21 matching lines...) Expand all
32 #include "core/css/CSSPrimitiveValue.h" 32 #include "core/css/CSSPrimitiveValue.h"
33 #include "core/css/CSSPrimitiveValueMappings.h" 33 #include "core/css/CSSPrimitiveValueMappings.h"
34 #include "core/css/StylePropertySet.h" 34 #include "core/css/StylePropertySet.h"
35 #include "core/dom/Element.h" 35 #include "core/dom/Element.h"
36 #include "core/dom/ElementTraversal.h" 36 #include "core/dom/ElementTraversal.h"
37 #include "core/fetch/DocumentResource.h" 37 #include "core/fetch/DocumentResource.h"
38 #include "core/layout/svg/LayoutSVGResourceFilter.h" 38 #include "core/layout/svg/LayoutSVGResourceFilter.h"
39 #include "core/svg/SVGDocumentExtensions.h" 39 #include "core/svg/SVGDocumentExtensions.h"
40 #include "core/svg/SVGFilterPrimitiveStandardAttributes.h" 40 #include "core/svg/SVGFilterPrimitiveStandardAttributes.h"
41 #include "core/svg/graphics/filters/SVGFilterBuilder.h" 41 #include "core/svg/graphics/filters/SVGFilterBuilder.h"
42 #include "platform/graphics/filters/SourceAlpha.h"
43 42
44 namespace blink { 43 namespace blink {
45 44
46 HashMap<const FilterOperation*, OwnPtr<DocumentResourceReference>>* ReferenceFil terBuilder::documentResourceReferences = 0; 45 HashMap<const FilterOperation*, OwnPtr<DocumentResourceReference>>* ReferenceFil terBuilder::documentResourceReferences = 0;
47 46
48 DocumentResourceReference* ReferenceFilterBuilder::documentResourceReference(con st FilterOperation* filterOperation) 47 DocumentResourceReference* ReferenceFilterBuilder::documentResourceReference(con st FilterOperation* filterOperation)
49 { 48 {
50 if (!documentResourceReferences) 49 if (!documentResourceReferences)
51 return 0; 50 return 0;
52 51
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // in the document. 134 // in the document.
136 treeScope->document().accessSVGExtensions().addPendingResource(filterOpe ration->fragment(), toElement(layoutObject->node())); 135 treeScope->document().accessSVGExtensions().addPendingResource(filterOpe ration->fragment(), toElement(layoutObject->node()));
137 return nullptr; 136 return nullptr;
138 } 137 }
139 138
140 if (!isSVGFilterElement(*filter)) 139 if (!isSVGFilterElement(*filter))
141 return nullptr; 140 return nullptr;
142 141
143 SVGFilterElement& filterElement = toSVGFilterElement(*filter); 142 SVGFilterElement& filterElement = toSVGFilterElement(*filter);
144 143
145 // FIXME: Figure out what to do with SourceAlpha. Right now, we're 144 RefPtrWillBeRawPtr<SVGFilterBuilder> builder = SVGFilterBuilder::create(prev iousEffect);
146 // using the alpha of the original input layer, which is obviously
147 // wrong. We should probably be extracting the alpha from the
148 // previousEffect, but this requires some more processing.
149 // This may need a spec clarification.
150 RefPtrWillBeRawPtr<SVGFilterBuilder> builder = SVGFilterBuilder::create(prev iousEffect, SourceAlpha::create(parentFilter));
151 145
152 ColorSpace filterColorSpace = ColorSpaceDeviceRGB; 146 ColorSpace filterColorSpace = ColorSpaceDeviceRGB;
153 bool useFilterColorSpace = getSVGElementColorSpace(&filterElement, filterCol orSpace); 147 bool useFilterColorSpace = getSVGElementColorSpace(&filterElement, filterCol orSpace);
154 148
155 for (SVGElement* element = Traversal<SVGElement>::firstChild(filterElement); element; element = Traversal<SVGElement>::nextSibling(*element)) { 149 for (SVGElement* element = Traversal<SVGElement>::firstChild(filterElement); element; element = Traversal<SVGElement>::nextSibling(*element)) {
156 if (!element->isFilterEffect()) 150 if (!element->isFilterEffect())
157 continue; 151 continue;
158 152
159 SVGFilterPrimitiveStandardAttributes* effectElement = static_cast<SVGFil terPrimitiveStandardAttributes*>(element); 153 SVGFilterPrimitiveStandardAttributes* effectElement = static_cast<SVGFil terPrimitiveStandardAttributes*>(element);
160 154
161 RefPtrWillBeRawPtr<FilterEffect> effect = effectElement->build(builder.g et(), parentFilter); 155 RefPtrWillBeRawPtr<FilterEffect> effect = effectElement->build(builder.g et(), parentFilter);
162 if (!effect) 156 if (!effect)
163 continue; 157 continue;
164 158
165 effectElement->setStandardAttributes(effect.get()); 159 effectElement->setStandardAttributes(effect.get());
166 effect->setEffectBoundaries(SVGLengthContext::resolveRectangle<SVGFilter PrimitiveStandardAttributes>(effectElement, filterElement.primitiveUnits()->curr entValue()->enumValue(), parentFilter->sourceImageRect())); 160 effect->setEffectBoundaries(SVGLengthContext::resolveRectangle<SVGFilter PrimitiveStandardAttributes>(effectElement, filterElement.primitiveUnits()->curr entValue()->enumValue(), parentFilter->sourceImageRect()));
167 ColorSpace colorSpace = filterColorSpace; 161 ColorSpace colorSpace = filterColorSpace;
168 if (useFilterColorSpace || getSVGElementColorSpace(effectElement, colorS pace)) 162 if (useFilterColorSpace || getSVGElementColorSpace(effectElement, colorS pace))
169 effect->setOperatingColorSpace(colorSpace); 163 effect->setOperatingColorSpace(colorSpace);
170 builder->add(AtomicString(effectElement->result()->currentValue()->value ()), effect); 164 builder->add(AtomicString(effectElement->result()->currentValue()->value ()), effect);
171 } 165 }
172 return builder->lastEffect(); 166 return builder->lastEffect();
173 } 167 }
174 168
175 } // namespace blink 169 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/svg/LayoutSVGResourceFilter.cpp ('k') | Source/core/paint/SVGFilterPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698