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

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

Issue 134733016: Add support for converting Colors to linear RGB; Fix relevant filters (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase; update TestExpectations 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
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 Color color = adaptColorToOperatingColorSpace(m_shadowColor.combineWithAlpha (m_shadowOpacity));
92 SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(blurRadius.widt h(), blurRadius.height())); 92 SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(blurRadius.widt h(), blurRadius.height()));
93 SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(colo r.rgb(), SkXfermode::kSrcIn_Mode)); 93 SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(colo r.rgb(), SkXfermode::kSrcIn_Mode));
94 SkPaint paint; 94 SkPaint paint;
95 paint.setImageFilter(blurFilter.get()); 95 paint.setImageFilter(blurFilter.get());
96 paint.setColorFilter(colorFilter.get()); 96 paint.setColorFilter(colorFilter.get());
97 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); 97 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
98 RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore); 98 RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
99 99
100 RefPtr<NativeImageSkia> nativeImage = image->nativeImageForCurrentFrame(); 100 RefPtr<NativeImageSkia> nativeImage = image->nativeImageForCurrentFrame();
101 101
102 if (!nativeImage) 102 if (!nativeImage)
103 return; 103 return;
104 104
105 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);
106 resultContext->drawBitmap(nativeImage->bitmap(), drawingRegion.x(), drawingR egion.y()); 106 resultContext->drawBitmap(nativeImage->bitmap(), drawingRegion.x(), drawingR egion.y());
107 } 107 }
108 108
109 PassRefPtr<SkImageFilter> FEDropShadow::createImageFilter(SkiaImageFilterBuilder * builder) 109 PassRefPtr<SkImageFilter> FEDropShadow::createImageFilter(SkiaImageFilterBuilder * builder)
110 { 110 {
111 RefPtr<SkImageFilter> input(builder->build(inputEffect(0), operatingColorSpa ce())); 111 RefPtr<SkImageFilter> input(builder->build(inputEffect(0), operatingColorSpa ce()));
112 float dx = filter()->applyHorizontalScale(m_dx); 112 float dx = filter()->applyHorizontalScale(m_dx);
113 float dy = filter()->applyVerticalScale(m_dy); 113 float dy = filter()->applyVerticalScale(m_dy);
114 float stdX = filter()->applyHorizontalScale(m_stdX); 114 float stdX = filter()->applyHorizontalScale(m_stdX);
115 float stdY = filter()->applyVerticalScale(m_stdY); 115 float stdY = filter()->applyVerticalScale(m_stdY);
116 Color color = m_shadowColor.combineWithAlpha(m_shadowOpacity); 116 Color color = adaptColorToOperatingColorSpace(m_shadowColor.combineWithAlpha (m_shadowOpacity));
117 SkImageFilter::CropRect cropRect = getCropRect(builder->cropOffset()); 117 SkImageFilter::CropRect cropRect = getCropRect(builder->cropOffset());
118 return adoptRef(new SkDropShadowImageFilter(SkFloatToScalar(dx), SkFloatToSc alar(dy), SkFloatToScalar(stdX), SkFloatToScalar(stdY), color.rgb(), input.get() , &cropRect)); 118 return adoptRef(new SkDropShadowImageFilter(SkFloatToScalar(dx), SkFloatToSc alar(dy), SkFloatToScalar(stdX), SkFloatToScalar(stdY), color.rgb(), input.get() , &cropRect));
119 } 119 }
120 120
121 121
122 TextStream& FEDropShadow::externalRepresentation(TextStream& ts, int indent) con st 122 TextStream& FEDropShadow::externalRepresentation(TextStream& ts, int indent) con st
123 { 123 {
124 writeIndent(ts, indent); 124 writeIndent(ts, indent);
125 ts << "[feDropShadow"; 125 ts << "[feDropShadow";
126 FilterEffect::externalRepresentation(ts); 126 FilterEffect::externalRepresentation(ts);
127 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";
128 inputEffect(0)->externalRepresentation(ts, indent + 1); 128 inputEffect(0)->externalRepresentation(ts, indent + 1);
129 return ts; 129 return ts;
130 } 130 }
131 131
132 } // namespace WebCore 132 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/graphics/ImageBuffer.cpp ('k') | Source/platform/graphics/filters/FELighting.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698