| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 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 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" | 26 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" |
| 27 | 27 |
| 28 #include "SkBlurImageFilter.h" | 28 #include "SkBlurImageFilter.h" |
| 29 #include "SkColorFilterImageFilter.h" | 29 #include "SkColorFilterImageFilter.h" |
| 30 #include "SkColorMatrixFilter.h" | 30 #include "SkColorMatrixFilter.h" |
| 31 #include "SkTableColorFilter.h" | 31 #include "SkTableColorFilter.h" |
| 32 #include "platform/geometry/IntPoint.h" |
| 32 #include "platform/graphics/filters/FilterEffect.h" | 33 #include "platform/graphics/filters/FilterEffect.h" |
| 33 #include "platform/graphics/filters/FilterOperations.h" | 34 #include "platform/graphics/filters/FilterOperations.h" |
| 34 #include "platform/graphics/filters/SourceGraphic.h" | 35 #include "platform/graphics/filters/SourceGraphic.h" |
| 35 #include "platform/graphics/skia/SkiaUtils.h" | 36 #include "platform/graphics/skia/SkiaUtils.h" |
| 36 #include "public/platform/WebPoint.h" | |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 SkiaImageFilterBuilder::~SkiaImageFilterBuilder() | 40 SkiaImageFilterBuilder::~SkiaImageFilterBuilder() |
| 41 { | 41 { |
| 42 } | 42 } |
| 43 | 43 |
| 44 PassRefPtr<SkImageFilter> SkiaImageFilterBuilder::build(FilterEffect* effect, Co
lorSpace colorSpace, bool destinationRequiresValidPreMultipliedPixels) | 44 PassRefPtr<SkImageFilter> SkiaImageFilterBuilder::build(FilterEffect* effect, Co
lorSpace colorSpace, bool destinationRequiresValidPreMultipliedPixels) |
| 45 { | 45 { |
| 46 if (!effect) | 46 if (!effect) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 63 PassRefPtr<SkImageFilter> SkiaImageFilterBuilder::transformColorSpace( | 63 PassRefPtr<SkImageFilter> SkiaImageFilterBuilder::transformColorSpace( |
| 64 SkImageFilter* input, ColorSpace srcColorSpace, ColorSpace dstColorSpace) { | 64 SkImageFilter* input, ColorSpace srcColorSpace, ColorSpace dstColorSpace) { |
| 65 | 65 |
| 66 RefPtr<SkColorFilter> colorFilter = ColorSpaceUtilities::createColorSpaceFil
ter(srcColorSpace, dstColorSpace); | 66 RefPtr<SkColorFilter> colorFilter = ColorSpaceUtilities::createColorSpaceFil
ter(srcColorSpace, dstColorSpace); |
| 67 if (!colorFilter) | 67 if (!colorFilter) |
| 68 return input; | 68 return input; |
| 69 | 69 |
| 70 return adoptRef(SkColorFilterImageFilter::Create(colorFilter.get(), input)); | 70 return adoptRef(SkColorFilterImageFilter::Create(colorFilter.get(), input)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void SkiaImageFilterBuilder::buildFilterOperations(const FilterOperations& opera
tions, WebFilterOperations* filters) | 73 void SkiaImageFilterBuilder::buildFilterOperations(const FilterOperations& opera
tions, CompositorFilterOperations* filters) |
| 74 { | 74 { |
| 75 ColorSpace currentColorSpace = ColorSpaceDeviceRGB; | 75 ColorSpace currentColorSpace = ColorSpaceDeviceRGB; |
| 76 SkImageFilter* const nullFilter = 0; | 76 SkImageFilter* const nullFilter = 0; |
| 77 | 77 |
| 78 for (size_t i = 0; i < operations.size(); ++i) { | 78 for (size_t i = 0; i < operations.size(); ++i) { |
| 79 const FilterOperation& op = *operations.at(i); | 79 const FilterOperation& op = *operations.at(i); |
| 80 switch (op.type()) { | 80 switch (op.type()) { |
| 81 case FilterOperation::REFERENCE: { | 81 case FilterOperation::REFERENCE: { |
| 82 RefPtr<SkImageFilter> filter; | 82 RefPtr<SkImageFilter> filter; |
| 83 Filter* referenceFilter = toReferenceFilterOperation(op).filter(); | 83 Filter* referenceFilter = toReferenceFilterOperation(op).filter(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 150 } |
| 151 break; | 151 break; |
| 152 } | 152 } |
| 153 case FilterOperation::BLUR: { | 153 case FilterOperation::BLUR: { |
| 154 float pixelRadius = toBlurFilterOperation(op).stdDeviation().getFloa
tValue(); | 154 float pixelRadius = toBlurFilterOperation(op).stdDeviation().getFloa
tValue(); |
| 155 filters->appendBlurFilter(pixelRadius); | 155 filters->appendBlurFilter(pixelRadius); |
| 156 break; | 156 break; |
| 157 } | 157 } |
| 158 case FilterOperation::DROP_SHADOW: { | 158 case FilterOperation::DROP_SHADOW: { |
| 159 const DropShadowFilterOperation& drop = toDropShadowFilterOperation(
op); | 159 const DropShadowFilterOperation& drop = toDropShadowFilterOperation(
op); |
| 160 filters->appendDropShadowFilter(WebPoint(drop.x(), drop.y()), drop.s
tdDeviation(), drop.color().rgb()); | 160 filters->appendDropShadowFilter(drop.location(), drop.stdDeviation()
, drop.color()); |
| 161 break; | 161 break; |
| 162 } | 162 } |
| 163 case FilterOperation::NONE: | 163 case FilterOperation::NONE: |
| 164 break; | 164 break; |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 if (currentColorSpace != ColorSpaceDeviceRGB) { | 167 if (currentColorSpace != ColorSpaceDeviceRGB) { |
| 168 // Transform to device color space at the end of processing, if required | 168 // Transform to device color space at the end of processing, if required |
| 169 RefPtr<SkImageFilter> filter = transformColorSpace(nullFilter, currentCo
lorSpace, ColorSpaceDeviceRGB); | 169 RefPtr<SkImageFilter> filter = transformColorSpace(nullFilter, currentCo
lorSpace, ColorSpaceDeviceRGB); |
| 170 filters->appendReferenceFilter(filter.get()); | 170 filters->appendReferenceFilter(filter.get()); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 PassRefPtr<SkImageFilter> SkiaImageFilterBuilder::buildTransform(const AffineTra
nsform& transform, SkImageFilter* input) | 174 PassRefPtr<SkImageFilter> SkiaImageFilterBuilder::buildTransform(const AffineTra
nsform& transform, SkImageFilter* input) |
| 175 { | 175 { |
| 176 return adoptRef(SkImageFilter::CreateMatrixFilter(affineTransformToSkMatrix(
transform), kHigh_SkFilterQuality, input)); | 176 return adoptRef(SkImageFilter::CreateMatrixFilter(affineTransformToSkMatrix(
transform), kHigh_SkFilterQuality, input)); |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace blink | 179 } // namespace blink |
| OLD | NEW |