| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 2 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #include "config.h" | 21 #include "config.h" |
| 22 #include "platform/graphics/filters/SourceAlpha.h" | 22 #include "platform/graphics/filters/SourceAlpha.h" |
| 23 | 23 |
| 24 #include "platform/graphics/Color.h" | |
| 25 #include "platform/graphics/filters/Filter.h" | 24 #include "platform/graphics/filters/Filter.h" |
| 26 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" | 25 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" |
| 27 #include "platform/graphics/filters/SourceGraphic.h" | |
| 28 #include "platform/text/TextStream.h" | 26 #include "platform/text/TextStream.h" |
| 29 #include "third_party/skia/include/effects/SkColorFilterImageFilter.h" | 27 #include "third_party/skia/include/effects/SkColorFilterImageFilter.h" |
| 30 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" | 28 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" |
| 31 #include "wtf/text/WTFString.h" | 29 #include "wtf/text/WTFString.h" |
| 32 | 30 |
| 33 namespace blink { | 31 namespace blink { |
| 34 | 32 |
| 35 PassRefPtrWillBeRawPtr<SourceAlpha> SourceAlpha::create(Filter* filter) | 33 PassRefPtrWillBeRawPtr<SourceAlpha> SourceAlpha::create(FilterEffect* sourceEffe
ct) |
| 36 { | 34 { |
| 37 return adoptRefWillBeNoop(new SourceAlpha(filter)); | 35 return adoptRefWillBeNoop(new SourceAlpha(sourceEffect)); |
| 38 } | 36 } |
| 39 | 37 |
| 40 const AtomicString& SourceAlpha::effectName() | 38 const AtomicString& SourceAlpha::effectName() |
| 41 { | 39 { |
| 42 DEFINE_STATIC_LOCAL(const AtomicString, s_effectName, ("SourceAlpha", Atomic
String::ConstructFromLiteral)); | 40 DEFINE_STATIC_LOCAL(const AtomicString, s_effectName, ("SourceAlpha", Atomic
String::ConstructFromLiteral)); |
| 43 return s_effectName; | 41 return s_effectName; |
| 44 } | 42 } |
| 45 | 43 |
| 44 SourceAlpha::SourceAlpha(FilterEffect* sourceEffect) |
| 45 : FilterEffect(sourceEffect->filter()) |
| 46 { |
| 47 setOperatingColorSpace(sourceEffect->operatingColorSpace()); |
| 48 inputEffects().append(sourceEffect); |
| 49 } |
| 50 |
| 46 FloatRect SourceAlpha::determineAbsolutePaintRect(const FloatRect& requestedRect
) | 51 FloatRect SourceAlpha::determineAbsolutePaintRect(const FloatRect& requestedRect
) |
| 47 { | 52 { |
| 48 FloatRect srcRect = filter()->sourceImageRect(); | 53 return inputEffect(0)->determineAbsolutePaintRect(requestedRect); |
| 49 srcRect.intersect(requestedRect); | |
| 50 addAbsolutePaintRect(srcRect); | |
| 51 return srcRect; | |
| 52 } | 54 } |
| 53 | 55 |
| 54 PassRefPtr<SkImageFilter> SourceAlpha::createImageFilter(SkiaImageFilterBuilder*
builder) | 56 PassRefPtr<SkImageFilter> SourceAlpha::createImageFilter(SkiaImageFilterBuilder*
builder) |
| 55 { | 57 { |
| 56 RefPtr<SkImageFilter> sourceGraphic(builder->build(builder->sourceGraphic(),
operatingColorSpace())); | 58 RefPtr<SkImageFilter> sourceGraphic(builder->build(inputEffect(0), operating
ColorSpace())); |
| 57 SkScalar matrix[20] = { | 59 SkScalar matrix[20] = { |
| 58 0, 0, 0, 0, 0, | 60 0, 0, 0, 0, 0, |
| 59 0, 0, 0, 0, 0, | 61 0, 0, 0, 0, 0, |
| 60 0, 0, 0, 0, 0, | 62 0, 0, 0, 0, 0, |
| 61 0, 0, 0, SK_Scalar1, 0 | 63 0, 0, 0, SK_Scalar1, 0 |
| 62 }; | 64 }; |
| 63 RefPtr<SkColorFilter> colorFilter(adoptRef(SkColorMatrixFilter::Create(matri
x))); | 65 RefPtr<SkColorFilter> colorFilter(adoptRef(SkColorMatrixFilter::Create(matri
x))); |
| 64 return adoptRef(SkColorFilterImageFilter::Create(colorFilter.get(), sourceGr
aphic.get())); | 66 return adoptRef(SkColorFilterImageFilter::Create(colorFilter.get(), sourceGr
aphic.get())); |
| 65 } | 67 } |
| 66 | 68 |
| 67 TextStream& SourceAlpha::externalRepresentation(TextStream& ts, int indent) cons
t | 69 TextStream& SourceAlpha::externalRepresentation(TextStream& ts, int indent) cons
t |
| 68 { | 70 { |
| 69 writeIndent(ts, indent); | 71 writeIndent(ts, indent); |
| 70 ts << "[SourceAlpha]\n"; | 72 ts << "[SourceAlpha]\n"; |
| 71 return ts; | 73 return ts; |
| 72 } | 74 } |
| 73 | 75 |
| 74 } // namespace blink | 76 } // namespace blink |
| OLD | NEW |