| OLD | NEW |
| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 { | 122 { |
| 123 } | 123 } |
| 124 | 124 |
| 125 FilterEffectBuilder::~FilterEffectBuilder() | 125 FilterEffectBuilder::~FilterEffectBuilder() |
| 126 { | 126 { |
| 127 } | 127 } |
| 128 | 128 |
| 129 DEFINE_TRACE(FilterEffectBuilder) | 129 DEFINE_TRACE(FilterEffectBuilder) |
| 130 { | 130 { |
| 131 visitor->trace(m_lastEffect); | 131 visitor->trace(m_lastEffect); |
| 132 visitor->trace(m_referenceFilters); | |
| 133 } | 132 } |
| 134 | 133 |
| 135 bool FilterEffectBuilder::build(Element* element, const FilterOperations& operat
ions, float zoom, const FloatSize* referenceBoxSize, const SkPaint* fillPaint, c
onst SkPaint* strokePaint) | 134 bool FilterEffectBuilder::build(Element* element, const FilterOperations& operat
ions, float zoom, const FloatSize* referenceBoxSize, const SkPaint* fillPaint, c
onst SkPaint* strokePaint) |
| 136 { | 135 { |
| 137 // Create a parent filter for shorthand filters. These have already been sca
led by the CSS code for page zoom, so scale is 1.0 here. | 136 // Create a parent filter for shorthand filters. These have already been sca
led by the CSS code for page zoom, so scale is 1.0 here. |
| 138 Filter* parentFilter = Filter::create(1.0f); | 137 Filter* parentFilter = Filter::create(1.0f); |
| 139 FilterEffect* previousEffect = parentFilter->getSourceGraphic(); | 138 FilterEffect* previousEffect = parentFilter->getSourceGraphic(); |
| 140 for (size_t i = 0; i < operations.operations().size(); ++i) { | 139 for (size_t i = 0; i < operations.operations().size(); ++i) { |
| 141 FilterEffect* effect = nullptr; | 140 FilterEffect* effect = nullptr; |
| 142 FilterOperation* filterOperation = operations.operations().at(i).get(); | 141 FilterOperation* filterOperation = operations.operations().at(i).get(); |
| 143 switch (filterOperation->type()) { | 142 switch (filterOperation->type()) { |
| 144 case FilterOperation::REFERENCE: { | 143 case FilterOperation::REFERENCE: { |
| 145 Filter* referenceFilter = ReferenceFilterBuilder::build(zoom, elemen
t, previousEffect, toReferenceFilterOperation(*filterOperation), referenceBoxSiz
e, fillPaint, strokePaint); | 144 Filter* referenceFilter = ReferenceFilterBuilder::build(zoom, elemen
t, previousEffect, toReferenceFilterOperation(*filterOperation), referenceBoxSiz
e, fillPaint, strokePaint); |
| 146 if (referenceFilter) { | 145 if (referenceFilter) |
| 147 effect = referenceFilter->lastEffect(); | 146 effect = referenceFilter->lastEffect(); |
| 148 m_referenceFilters.append(referenceFilter); | |
| 149 } | |
| 150 break; | 147 break; |
| 151 } | 148 } |
| 152 case FilterOperation::GRAYSCALE: { | 149 case FilterOperation::GRAYSCALE: { |
| 153 Vector<float> inputParameters = grayscaleMatrix(toBasicColorMatrixFi
lterOperation(filterOperation)->amount()); | 150 Vector<float> inputParameters = grayscaleMatrix(toBasicColorMatrixFi
lterOperation(filterOperation)->amount()); |
| 154 effect = FEColorMatrix::create(parentFilter, FECOLORMATRIX_TYPE_MATR
IX, inputParameters); | 151 effect = FEColorMatrix::create(parentFilter, FECOLORMATRIX_TYPE_MATR
IX, inputParameters); |
| 155 break; | 152 break; |
| 156 } | 153 } |
| 157 case FilterOperation::SEPIA: { | 154 case FilterOperation::SEPIA: { |
| 158 Vector<float> inputParameters = sepiaMatrix(toBasicColorMatrixFilter
Operation(filterOperation)->amount()); | 155 Vector<float> inputParameters = sepiaMatrix(toBasicColorMatrixFilter
Operation(filterOperation)->amount()); |
| 159 effect = FEColorMatrix::create(parentFilter, FECOLORMATRIX_TYPE_MATR
IX, inputParameters); | 156 effect = FEColorMatrix::create(parentFilter, FECOLORMATRIX_TYPE_MATR
IX, inputParameters); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 effect->setClipsToBounds(false); | 242 effect->setClipsToBounds(false); |
| 246 effect->setOperatingColorSpace(ColorSpaceDeviceRGB); | 243 effect->setOperatingColorSpace(ColorSpaceDeviceRGB); |
| 247 effect->inputEffects().append(previousEffect); | 244 effect->inputEffects().append(previousEffect); |
| 248 } | 245 } |
| 249 if (previousEffect->originTainted()) | 246 if (previousEffect->originTainted()) |
| 250 effect->setOriginTainted(); | 247 effect->setOriginTainted(); |
| 251 previousEffect = effect; | 248 previousEffect = effect; |
| 252 } | 249 } |
| 253 } | 250 } |
| 254 | 251 |
| 255 m_referenceFilters.append(parentFilter); | |
| 256 | |
| 257 // We need to keep the old effects alive until this point, so that SVG refer
ence filters | 252 // We need to keep the old effects alive until this point, so that SVG refer
ence filters |
| 258 // can share cached resources across frames. | 253 // can share cached resources across frames. |
| 259 m_lastEffect = previousEffect; | 254 m_lastEffect = previousEffect; |
| 260 | 255 |
| 261 // If we didn't make any effects, tell our caller we are not valid | 256 // If we didn't make any effects, tell our caller we are not valid |
| 262 if (!m_lastEffect.get()) | 257 if (!m_lastEffect.get()) |
| 263 return false; | 258 return false; |
| 264 | 259 |
| 265 return true; | 260 return true; |
| 266 } | 261 } |
| 267 | 262 |
| 268 } // namespace blink | 263 } // namespace blink |
| 269 | 264 |
| OLD | NEW |