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

Side by Side Diff: Source/platform/graphics/filters/FEDropShadow.cpp

Issue 143463002: Apply flood-opacity for feDropShadow (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase. Created 6 years, 11 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
« no previous file with comments | « LayoutTests/svg/filters/feDropShadow-flood-opacity-2-expected.svg ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
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,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return; 81 return;
82 82
83 Filter* filter = this->filter(); 83 Filter* filter = this->filter();
84 FloatSize blurRadius(filter->applyHorizontalScale(m_stdX), filter->applyVert icalScale(m_stdY)); 84 FloatSize blurRadius(filter->applyHorizontalScale(m_stdX), filter->applyVert icalScale(m_stdY));
85 FloatSize offset(filter->applyHorizontalScale(m_dx), filter->applyVerticalSc ale(m_dy)); 85 FloatSize offset(filter->applyHorizontalScale(m_dx), filter->applyVerticalSc ale(m_dy));
86 86
87 FloatRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect()) ; 87 FloatRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect()) ;
88 GraphicsContext* resultContext = resultImage->context(); 88 GraphicsContext* resultContext = resultImage->context();
89 ASSERT(resultContext); 89 ASSERT(resultContext);
90 90
91 Color color = m_shadowColor.combineWithAlpha(m_shadowOpacity);
91 SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(blurRadius.widt h(), blurRadius.height())); 92 SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(blurRadius.widt h(), blurRadius.height()));
92 SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(m_sh adowColor.rgb(), SkXfermode::kSrcIn_Mode)); 93 SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(colo r.rgb(), SkXfermode::kSrcIn_Mode));
93 SkPaint paint; 94 SkPaint paint;
94 paint.setImageFilter(blurFilter.get()); 95 paint.setImageFilter(blurFilter.get());
95 paint.setColorFilter(colorFilter.get()); 96 paint.setColorFilter(colorFilter.get());
96 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); 97 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
97 RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore); 98 RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
98 99
99 RefPtr<NativeImageSkia> nativeImage = image->nativeImageForCurrentFrame(); 100 RefPtr<NativeImageSkia> nativeImage = image->nativeImageForCurrentFrame();
100 101
101 if (!nativeImage) 102 if (!nativeImage)
102 return; 103 return;
103 104
104 resultContext->drawBitmap(nativeImage->bitmap(), drawingRegion.x() + offset. width(), drawingRegion.y() + offset.height(), &paint); 105 resultContext->drawBitmap(nativeImage->bitmap(), drawingRegion.x() + offset. width(), drawingRegion.y() + offset.height(), &paint);
105 resultContext->drawBitmap(nativeImage->bitmap(), drawingRegion.x(), drawingR egion.y()); 106 resultContext->drawBitmap(nativeImage->bitmap(), drawingRegion.x(), drawingR egion.y());
106 } 107 }
107 108
108 PassRefPtr<SkImageFilter> FEDropShadow::createImageFilter(SkiaImageFilterBuilder * builder) 109 PassRefPtr<SkImageFilter> FEDropShadow::createImageFilter(SkiaImageFilterBuilder * builder)
109 { 110 {
110 RefPtr<SkImageFilter> input(builder->build(inputEffect(0), operatingColorSpa ce())); 111 RefPtr<SkImageFilter> input(builder->build(inputEffect(0), operatingColorSpa ce()));
111 float dx = filter()->applyHorizontalScale(m_dx); 112 float dx = filter()->applyHorizontalScale(m_dx);
112 float dy = filter()->applyVerticalScale(m_dy); 113 float dy = filter()->applyVerticalScale(m_dy);
113 float stdX = filter()->applyHorizontalScale(m_stdX); 114 float stdX = filter()->applyHorizontalScale(m_stdX);
114 float stdY = filter()->applyHorizontalScale(m_stdY); 115 float stdY = filter()->applyVerticalScale(m_stdY);
116 Color color = m_shadowColor.combineWithAlpha(m_shadowOpacity);
115 SkImageFilter::CropRect cropRect = getCropRect(builder->cropOffset()); 117 SkImageFilter::CropRect cropRect = getCropRect(builder->cropOffset());
116 return adoptRef(new SkDropShadowImageFilter(SkFloatToScalar(dx), SkFloatToSc alar(dy), SkFloatToScalar(stdX), SkFloatToScalar(stdY), m_shadowColor.rgb(), inp ut.get(), &cropRect)); 118 return adoptRef(new SkDropShadowImageFilter(SkFloatToScalar(dx), SkFloatToSc alar(dy), SkFloatToScalar(stdX), SkFloatToScalar(stdY), color.rgb(), input.get() , &cropRect));
117 } 119 }
118 120
119 121
120 TextStream& FEDropShadow::externalRepresentation(TextStream& ts, int indent) con st 122 TextStream& FEDropShadow::externalRepresentation(TextStream& ts, int indent) con st
121 { 123 {
122 writeIndent(ts, indent); 124 writeIndent(ts, indent);
123 ts << "[feDropShadow"; 125 ts << "[feDropShadow";
124 FilterEffect::externalRepresentation(ts); 126 FilterEffect::externalRepresentation(ts);
125 ts << " stdDeviation=\"" << m_stdX << ", " << m_stdY << "\" dx=\"" << m_dx < < "\" dy=\"" << m_dy << "\" flood-color=\"" << m_shadowColor.nameForRenderTreeAs Text() <<"\" flood-opacity=\"" << m_shadowOpacity << "]\n"; 127 ts << " stdDeviation=\"" << m_stdX << ", " << m_stdY << "\" dx=\"" << m_dx < < "\" dy=\"" << m_dy << "\" flood-color=\"" << m_shadowColor.nameForRenderTreeAs Text() <<"\" flood-opacity=\"" << m_shadowOpacity << "]\n";
126 inputEffect(0)->externalRepresentation(ts, indent + 1); 128 inputEffect(0)->externalRepresentation(ts, indent + 1);
127 return ts; 129 return ts;
128 } 130 }
129 131
130 } // namespace WebCore 132 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/svg/filters/feDropShadow-flood-opacity-2-expected.svg ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698