summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/platform/graphics/filters
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-08-08 14:30:41 +0200
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-08-12 13:49:54 +0200
commitab0a50979b9eb4dfa3320eff7e187e41efedf7a9 (patch)
tree498dfb8a97ff3361a9f7486863a52bb4e26bb898 /chromium/third_party/WebKit/Source/platform/graphics/filters
parent4ce69f7403811819800e7c5ae1318b2647e778d1 (diff)
Update Chromium to beta version 37.0.2062.68
Change-Id: I188e3b5aff1bec75566014291b654eb19f5bc8ca Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/third_party/WebKit/Source/platform/graphics/filters')
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/DistantLightSource.cpp4
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/DistantLightSource.h11
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEBlend.cpp39
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEBlend.h3
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEColorMatrix.cpp130
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEColorMatrix.h34
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEComponentTransfer.cpp59
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEComponentTransfer.h5
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEComposite.cpp100
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEComposite.h8
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEConvolveMatrix.cpp10
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEConvolveMatrix.h4
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEDiffuseLighting.cpp1
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEDiffuseLighting.h2
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEDisplacementMap.cpp52
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEDisplacementMap.h7
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.cpp33
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.h5
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEFlood.cpp6
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEFlood.h8
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEGaussianBlur.cpp257
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEGaussianBlur.h45
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FELighting.cpp93
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FELighting.h15
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEMerge.cpp2
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEMerge.h2
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEMorphology.cpp150
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEMorphology.h8
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEOffset.cpp18
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FEOffset.h3
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FESpecularLighting.cpp2
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FESpecularLighting.h2
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FETile.cpp40
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FETile.h6
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FETurbulence.cpp44
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FETurbulence.h7
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/Filter.h74
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp173
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.h45
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperation.h44
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperations.cpp24
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperations.h1
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperationsTest.cpp61
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/ImageFilterBuilderTest.cpp125
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/LightSource.h7
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/ParallelJobs.h5
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/PointLightSource.cpp4
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/PointLightSource.h12
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/ReferenceFilter.cpp2
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/ReferenceFilter.h4
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.cpp91
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.h23
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/SourceAlpha.cpp32
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/SourceAlpha.h7
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/SourceGraphic.cpp16
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/SourceGraphic.h6
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.cpp23
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.h15
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterArrayParameter.cpp54
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterArrayParameter.h74
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterCompiledProgram.cpp149
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterCompiledProgram.h95
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterConstants.h60
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterGlobalContext.cpp112
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterGlobalContext.h83
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterMesh.cpp68
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterMesh.h76
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterMeshGenerator.cpp171
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterMeshGenerator.h121
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterNumberParameter.cpp50
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterNumberParameter.h73
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterOperation.cpp74
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterOperation.h97
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterParameter.h78
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterParameterList.cpp116
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterParameterList.h63
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgram.cpp85
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgram.h92
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgramClient.cpp39
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgramClient.h49
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgramInfo.cpp106
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgramInfo.h110
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterRenderer.cpp292
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterRenderer.h98
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterTransformParameter.cpp70
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterTransformParameter.h72
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterValidatedProgram.cpp617
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterValidatedProgram.h123
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/FECustomFilter.cpp367
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/FECustomFilter.h101
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/ValidatedCustomFilterOperation.cpp60
-rw-r--r--chromium/third_party/WebKit/Source/platform/graphics/filters/custom/ValidatedCustomFilterOperation.h93
92 files changed, 902 insertions, 5095 deletions
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/DistantLightSource.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/DistantLightSource.cpp
index 6da197cbb89..b44c393ab9b 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/DistantLightSource.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/DistantLightSource.cpp
@@ -35,7 +35,7 @@
namespace WebCore {
-void DistantLightSource::initPaintingData(PaintingData& paintingData)
+void DistantLightSource::initPaintingData(PaintingData& paintingData) const
{
float azimuth = deg2rad(m_azimuth);
float elevation = deg2rad(m_elevation);
@@ -45,7 +45,7 @@ void DistantLightSource::initPaintingData(PaintingData& paintingData)
paintingData.lightVectorLength = 1;
}
-void DistantLightSource::updatePaintingData(PaintingData&, int, int, float)
+void DistantLightSource::updatePaintingData(PaintingData&, int, int, float) const
{
}
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/DistantLightSource.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/DistantLightSource.h
index b64b94da7fb..65814e0504e 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/DistantLightSource.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/DistantLightSource.h
@@ -34,16 +34,21 @@ public:
return adoptRef(new DistantLightSource(azimuth, elevation));
}
+ virtual PassRefPtr<LightSource> create(const FloatPoint3D& scale, const FloatSize& offset) const OVERRIDE
+ {
+ return adoptRef(new DistantLightSource(m_azimuth, m_elevation));
+ }
+
float azimuth() const { return m_azimuth; }
float elevation() const { return m_elevation; }
virtual bool setAzimuth(float) OVERRIDE;
virtual bool setElevation(float) OVERRIDE;
- virtual void initPaintingData(PaintingData&);
- virtual void updatePaintingData(PaintingData&, int x, int y, float z);
+ virtual void initPaintingData(PaintingData&) const OVERRIDE;
+ virtual void updatePaintingData(PaintingData&, int x, int y, float z) const OVERRIDE;
- virtual TextStream& externalRepresentation(TextStream&) const;
+ virtual TextStream& externalRepresentation(TextStream&) const OVERRIDE;
private:
DistantLightSource(float azimuth, float elevation)
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEBlend.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEBlend.cpp
index 88aff9f783e..fbf94c35ebc 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEBlend.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEBlend.cpp
@@ -201,50 +201,13 @@ static SkXfermode::Mode toSkiaMode(BlendModeType mode)
}
}
-bool FEBlend::applySkia()
-{
- // For now, only use the skia implementation for accelerated rendering.
- if (!filter()->isAccelerated())
- return false;
-
- FilterEffect* in = inputEffect(0);
- FilterEffect* in2 = inputEffect(1);
-
- if (!in || !in2)
- return false;
-
- ImageBuffer* resultImage = createImageBufferResult();
- if (!resultImage)
- return false;
-
- RefPtr<Image> foreground = in->asImageBuffer()->copyImage(DontCopyBackingStore);
- RefPtr<Image> background = in2->asImageBuffer()->copyImage(DontCopyBackingStore);
-
- RefPtr<NativeImageSkia> foregroundNativeImage = foreground->nativeImageForCurrentFrame();
- RefPtr<NativeImageSkia> backgroundNativeImage = background->nativeImageForCurrentFrame();
-
- if (!foregroundNativeImage || !backgroundNativeImage)
- return false;
-
- SkBitmap foregroundBitmap = foregroundNativeImage->bitmap();
- SkBitmap backgroundBitmap = backgroundNativeImage->bitmap();
-
- SkAutoTUnref<SkImageFilter> backgroundSource(new SkBitmapSource(backgroundBitmap));
- SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(toSkiaMode(m_mode)));
- SkAutoTUnref<SkImageFilter> blend(new SkXfermodeImageFilter(mode, backgroundSource));
- SkPaint paint;
- paint.setImageFilter(blend);
- resultImage->context()->drawBitmap(foregroundBitmap, 0, 0, &paint);
- return true;
-}
-
PassRefPtr<SkImageFilter> FEBlend::createImageFilter(SkiaImageFilterBuilder* builder)
{
RefPtr<SkImageFilter> foreground(builder->build(inputEffect(0), operatingColorSpace()));
RefPtr<SkImageFilter> background(builder->build(inputEffect(1), operatingColorSpace()));
SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(toSkiaMode(m_mode)));
SkImageFilter::CropRect cropRect = getCropRect(builder->cropOffset());
- return adoptRef(new SkXfermodeImageFilter(mode, background.get(), foreground.get(), &cropRect));
+ return adoptRef(SkXfermodeImageFilter::Create(mode, background.get(), foreground.get(), &cropRect));
}
static TextStream& operator<<(TextStream& ts, const BlendModeType& type)
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEBlend.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEBlend.h
index 628c3ee408f..08e850e069c 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEBlend.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEBlend.h
@@ -50,13 +50,12 @@ public:
unsigned colorArrayLength);
virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE;
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
private:
FEBlend(Filter*, BlendModeType);
virtual void applySoftware() OVERRIDE;
- virtual bool applySkia() OVERRIDE;
BlendModeType m_mode;
};
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEColorMatrix.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEColorMatrix.cpp
index e56df350beb..b87769dd4eb 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEColorMatrix.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEColorMatrix.cpp
@@ -73,109 +73,6 @@ bool FEColorMatrix::setValues(const Vector<float> &values)
return true;
}
-inline void matrix(float& red, float& green, float& blue, float& alpha, const Vector<float>& values)
-{
- float r = values[0] * red + values[1] * green + values[2] * blue + values[3] * alpha + values[4] * 255;
- float g = values[5] * red + values[6] * green + values[7] * blue + values[8] * alpha + values[9] * 255;
- float b = values[10] * red + values[11] * green + values[12] * blue + values[13] * alpha + values[14] * 255;
- float a = values[15] * red + values[16] * green + values[17] * blue + values[18] * alpha + values[19] * 255;
-
- red = r;
- green = g;
- blue = b;
- alpha = a;
-}
-
-inline void saturateAndHueRotate(float& red, float& green, float& blue, const float* components)
-{
- float r = red * components[0] + green * components[1] + blue * components[2];
- float g = red * components[3] + green * components[4] + blue * components[5];
- float b = red * components[6] + green * components[7] + blue * components[8];
-
- red = r;
- green = g;
- blue = b;
-}
-
-inline void luminance(float& red, float& green, float& blue, float& alpha)
-{
- alpha = 0.2125 * red + 0.7154 * green + 0.0721 * blue;
- red = 0;
- green = 0;
- blue = 0;
-}
-
-template<ColorMatrixType filterType>
-void effectType(Uint8ClampedArray* pixelArray, const Vector<float>& values)
-{
- unsigned pixelArrayLength = pixelArray->length();
- float components[9];
-
- if (filterType == FECOLORMATRIX_TYPE_SATURATE)
- FEColorMatrix::calculateSaturateComponents(components, values[0]);
- else if (filterType == FECOLORMATRIX_TYPE_HUEROTATE)
- FEColorMatrix::calculateHueRotateComponents(components, values[0]);
-
- for (unsigned pixelByteOffset = 0; pixelByteOffset < pixelArrayLength; pixelByteOffset += 4) {
- float red = pixelArray->item(pixelByteOffset);
- float green = pixelArray->item(pixelByteOffset + 1);
- float blue = pixelArray->item(pixelByteOffset + 2);
- float alpha = pixelArray->item(pixelByteOffset + 3);
-
- switch (filterType) {
- case FECOLORMATRIX_TYPE_MATRIX:
- matrix(red, green, blue, alpha, values);
- break;
- case FECOLORMATRIX_TYPE_SATURATE:
- case FECOLORMATRIX_TYPE_HUEROTATE:
- saturateAndHueRotate(red, green, blue, components);
- break;
- case FECOLORMATRIX_TYPE_LUMINANCETOALPHA:
- luminance(red, green, blue, alpha);
- break;
- }
-
- pixelArray->set(pixelByteOffset, red);
- pixelArray->set(pixelByteOffset + 1, green);
- pixelArray->set(pixelByteOffset + 2, blue);
- pixelArray->set(pixelByteOffset + 3, alpha);
- }
-}
-
-void FEColorMatrix::applySoftware()
-{
- FilterEffect* in = inputEffect(0);
-
- ImageBuffer* resultImage = createImageBufferResult();
- if (!resultImage)
- return;
-
- resultImage->context()->drawImageBuffer(in->asImageBuffer(), drawingRegionOfInputImage(in->absolutePaintRect()));
-
- IntRect imageRect(IntPoint(), absolutePaintRect().size());
- RefPtr<Uint8ClampedArray> pixelArray = resultImage->getUnmultipliedImageData(imageRect);
-
- switch (m_type) {
- case FECOLORMATRIX_TYPE_UNKNOWN:
- break;
- case FECOLORMATRIX_TYPE_MATRIX:
- effectType<FECOLORMATRIX_TYPE_MATRIX>(pixelArray.get(), m_values);
- break;
- case FECOLORMATRIX_TYPE_SATURATE:
- effectType<FECOLORMATRIX_TYPE_SATURATE>(pixelArray.get(), m_values);
- break;
- case FECOLORMATRIX_TYPE_HUEROTATE:
- effectType<FECOLORMATRIX_TYPE_HUEROTATE>(pixelArray.get(), m_values);
- break;
- case FECOLORMATRIX_TYPE_LUMINANCETOALPHA:
- effectType<FECOLORMATRIX_TYPE_LUMINANCETOALPHA>(pixelArray.get(), m_values);
- setIsAlphaImage(true);
- break;
- }
-
- resultImage->putByteArray(Unmultiplied, pixelArray.get(), imageRect.size(), imageRect, IntPoint());
-}
-
static void saturateMatrix(float s, SkScalar matrix[20])
{
matrix[0] = 0.213f + 0.787f * s;
@@ -249,31 +146,44 @@ static SkColorFilter* createColorFilter(ColorMatrixType type, const float* value
luminanceToAlphaMatrix(matrix);
break;
}
- return new SkColorMatrixFilter(matrix);
+ return SkColorMatrixFilter::Create(matrix);
}
-bool FEColorMatrix::applySkia()
+void FEColorMatrix::applySoftware()
{
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
- return false;
+ return;
FilterEffect* in = inputEffect(0);
- SkRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect());
+ IntRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect());
SkAutoTUnref<SkColorFilter> filter(createColorFilter(m_type, m_values.data()));
RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
RefPtr<NativeImageSkia> nativeImage = image->nativeImageForCurrentFrame();
if (!nativeImage)
- return false;
+ return;
SkPaint paint;
paint.setColorFilter(filter);
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
- resultImage->context()->drawBitmap(nativeImage->bitmap(), drawingRegion.fLeft, drawingRegion.fTop, &paint);
- return true;
+ resultImage->context()->drawBitmap(nativeImage->bitmap(), drawingRegion.x(), drawingRegion.y(), &paint);
+
+ if (affectsTransparentPixels()) {
+ IntRect fullRect = IntRect(IntPoint(), absolutePaintRect().size());
+ resultImage->context()->clipOut(drawingRegion);
+ resultImage->context()->fillRect(fullRect, Color(m_values[4], m_values[9], m_values[14], m_values[19]));
+ }
+ return;
+}
+
+bool FEColorMatrix::affectsTransparentPixels()
+{
+ // Because the input pixels are premultiplied, the only way clear pixels can be
+ // painted is if the additive component for the alpha is not 0.
+ return m_type == FECOLORMATRIX_TYPE_MATRIX && m_values[19] > 0;
}
PassRefPtr<SkImageFilter> FEColorMatrix::createImageFilter(SkiaImageFilterBuilder* builder)
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEColorMatrix.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEColorMatrix.h
index cd7cf1b5d06..4612161960d 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEColorMatrix.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEColorMatrix.h
@@ -49,7 +49,7 @@ public:
virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE;
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
static inline void calculateSaturateComponents(float* components, float value);
static inline void calculateHueRotateComponents(float* components, float value);
@@ -58,41 +58,13 @@ private:
FEColorMatrix(Filter*, ColorMatrixType, const Vector<float>&);
virtual void applySoftware() OVERRIDE;
- virtual bool applySkia() OVERRIDE;
+
+ virtual bool affectsTransparentPixels() OVERRIDE;
ColorMatrixType m_type;
Vector<float> m_values;
};
-inline void FEColorMatrix::calculateSaturateComponents(float* components, float value)
-{
- components[0] = (0.213 + 0.787 * value);
- components[1] = (0.715 - 0.715 * value);
- components[2] = (0.072 - 0.072 * value);
- components[3] = (0.213 - 0.213 * value);
- components[4] = (0.715 + 0.285 * value);
- components[5] = (0.072 - 0.072 * value);
- components[6] = (0.213 - 0.213 * value);
- components[7] = (0.715 - 0.715 * value);
- components[8] = (0.072 + 0.928 * value);
-}
-
-inline void FEColorMatrix::calculateHueRotateComponents(float* components, float value)
-{
- float cosHue = cos(value * piFloat / 180);
- float sinHue = sin(value * piFloat / 180);
- components[0] = 0.213 + cosHue * 0.787 - sinHue * 0.213;
- components[1] = 0.715 - cosHue * 0.715 - sinHue * 0.715;
- components[2] = 0.072 - cosHue * 0.072 + sinHue * 0.928;
- components[3] = 0.213 - cosHue * 0.213 + sinHue * 0.143;
- components[4] = 0.715 + cosHue * 0.285 + sinHue * 0.140;
- components[5] = 0.072 - cosHue * 0.072 - sinHue * 0.283;
- components[6] = 0.213 - cosHue * 0.213 - sinHue * 0.787;
- components[7] = 0.715 - cosHue * 0.715 + sinHue * 0.715;
- components[8] = 0.072 + cosHue * 0.928 + sinHue * 0.072;
-}
-
-
} // namespace WebCore
#endif // FEColorMatrix_h
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEComponentTransfer.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEComponentTransfer.cpp
index c5545830712..2ef679ccc9c 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEComponentTransfer.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEComponentTransfer.cpp
@@ -153,48 +153,51 @@ static void gamma(unsigned char* values, const ComponentTransferFunction& transf
void FEComponentTransfer::applySoftware()
{
FilterEffect* in = inputEffect(0);
-
- Uint8ClampedArray* pixelArray = createUnmultipliedImageResult();
- if (!pixelArray)
- return;
-
- unsigned char rValues[256], gValues[256], bValues[256], aValues[256];
- getValues(rValues, gValues, bValues, aValues);
- unsigned char* tables[] = { rValues, gValues, bValues, aValues };
-
- IntRect drawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
- in->copyUnmultipliedImage(pixelArray, drawingRect);
-
- unsigned pixelArrayLength = pixelArray->length();
- for (unsigned pixelOffset = 0; pixelOffset < pixelArrayLength; pixelOffset += 4) {
- for (unsigned channel = 0; channel < 4; ++channel) {
- unsigned char c = pixelArray->item(pixelOffset + channel);
- pixelArray->set(pixelOffset + channel, tables[channel][c]);
- }
- }
-}
-
-bool FEComponentTransfer::applySkia()
-{
- FilterEffect* in = inputEffect(0);
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
- return false;
+ return;
RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
RefPtr<NativeImageSkia> nativeImage = image->nativeImageForCurrentFrame();
if (!nativeImage)
- return false;
+ return;
unsigned char rValues[256], gValues[256], bValues[256], aValues[256];
getValues(rValues, gValues, bValues, aValues);
+ IntRect destRect = drawingRegionOfInputImage(in->absolutePaintRect());
SkPaint paint;
paint.setColorFilter(SkTableColorFilter::CreateARGB(aValues, rValues, gValues, bValues))->unref();
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
- resultImage->context()->drawBitmap(nativeImage->bitmap(), 0, 0, &paint);
+ resultImage->context()->drawBitmap(nativeImage->bitmap(), destRect.x(), destRect.y(), &paint);
- return true;
+ if (affectsTransparentPixels()) {
+ IntRect fullRect = IntRect(IntPoint(), absolutePaintRect().size());
+ resultImage->context()->clipOut(destRect);
+ resultImage->context()->fillRect(fullRect, Color(rValues[0], gValues[0], bValues[0], aValues[0]));
+ }
+}
+
+bool FEComponentTransfer::affectsTransparentPixels()
+{
+ double intercept = 0;
+ switch (m_alphaFunc.type) {
+ case FECOMPONENTTRANSFER_TYPE_UNKNOWN:
+ case FECOMPONENTTRANSFER_TYPE_IDENTITY:
+ break;
+ case FECOMPONENTTRANSFER_TYPE_TABLE:
+ case FECOMPONENTTRANSFER_TYPE_DISCRETE:
+ if (m_alphaFunc.tableValues.size() > 0)
+ intercept = m_alphaFunc.tableValues[0];
+ break;
+ case FECOMPONENTTRANSFER_TYPE_LINEAR:
+ intercept = m_alphaFunc.intercept;
+ break;
+ case FECOMPONENTTRANSFER_TYPE_GAMMA:
+ intercept = m_alphaFunc.offset;
+ break;
+ }
+ return 255 * intercept >= 1;
}
PassRefPtr<SkImageFilter> FEComponentTransfer::createImageFilter(SkiaImageFilterBuilder* builder)
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEComponentTransfer.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEComponentTransfer.h
index d71e82f02ff..f65cdaca699 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEComponentTransfer.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEComponentTransfer.h
@@ -79,14 +79,15 @@ public:
virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE;
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
private:
FEComponentTransfer(Filter*, const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc,
const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc);
virtual void applySoftware() OVERRIDE;
- virtual bool applySkia() OVERRIDE;
+
+ virtual bool affectsTransparentPixels() OVERRIDE;
void getValues(unsigned char rValues[256], unsigned char gValues[256], unsigned char bValues[256], unsigned char aValues[256]);
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEComposite.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEComposite.cpp
index 2348d80b2bd..a284840343d 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEComposite.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEComposite.cpp
@@ -232,25 +232,61 @@ inline void FEComposite::platformArithmeticSoftware(Uint8ClampedArray* source, U
#endif
}
-void FEComposite::determineAbsolutePaintRect()
+FloatRect FEComposite::determineAbsolutePaintRect(const FloatRect& originalRequestedRect)
{
+ FloatRect requestedRect = originalRequestedRect;
+ if (clipsToBounds())
+ requestedRect.intersect(maxEffectRect());
+
+ // We may be called multiple times if result is used more than once. Return
+ // quickly if nothing new is required.
+ if (absolutePaintRect().contains(enclosingIntRect(requestedRect)))
+ return requestedRect;
+
+ // No mapPaintRect required for FEComposite.
+ FloatRect input1Rect = inputEffect(1)->determineAbsolutePaintRect(requestedRect);
+ FloatRect affectedRect;
switch (m_type) {
case FECOMPOSITE_OPERATOR_IN:
+ // 'in' has output only in the intersection of both inputs.
+ affectedRect = intersection(input1Rect, inputEffect(0)->determineAbsolutePaintRect(input1Rect));
+ break;
case FECOMPOSITE_OPERATOR_ATOP:
- // For In and Atop the first effect just influences the result of
- // the second effect. So just use the absolute paint rect of the second effect here.
- setAbsolutePaintRect(inputEffect(1)->absolutePaintRect());
- return;
+ // 'atop' has output only in the extents of the second input.
+ // Make sure first input knows where it needs to produce output.
+ inputEffect(0)->determineAbsolutePaintRect(input1Rect);
+ affectedRect = input1Rect;
+ break;
case FECOMPOSITE_OPERATOR_ARITHMETIC:
- // Arithmetic may influnce the compele filter primitive region. So we can't
- // optimize the paint region here.
- setAbsolutePaintRect(enclosingIntRect(maxEffectRect()));
- return;
+ if (k4() > 0) {
+ // Make sure first input knows where it needs to produce output.
+ inputEffect(0)->determineAbsolutePaintRect(requestedRect);
+ // Arithmetic with non-zero k4 may influnce the complete filter primitive
+ // region. So we can't optimize the paint region here.
+ affectedRect = requestedRect;
+ break;
+ }
+ if (k2() <= 0) {
+ // Input 0 does not appear where input 1 is not present.
+ FloatRect input0Rect = inputEffect(0)->determineAbsolutePaintRect(input1Rect);
+ if (k3() > 0) {
+ affectedRect = input1Rect;
+ } else {
+ // Just k1 is positive. Use intersection.
+ affectedRect = intersection(input1Rect, input0Rect);
+ }
+ break;
+ }
+ // else fall through to use union
default:
// Take the union of both input effects.
- FilterEffect::determineAbsolutePaintRect();
- return;
+ affectedRect = unionRect(input1Rect, inputEffect(0)->determineAbsolutePaintRect(requestedRect));
+ break;
}
+
+ affectedRect.intersect(requestedRect);
+ addAbsolutePaintRect(affectedRect);
+ return affectedRect;
}
void FEComposite::applySoftware()
@@ -296,25 +332,27 @@ void FEComposite::applySoftware()
if (destinationRect.isEmpty())
break;
IntPoint destinationPoint(destinationRect.x() - absolutePaintRect().x(), destinationRect.y() - absolutePaintRect().y());
- IntRect sourceRect(IntPoint(destinationRect.x() - in->absolutePaintRect().x(),
+ FloatRect sourceRect(IntPoint(destinationRect.x() - in->absolutePaintRect().x(),
destinationRect.y() - in->absolutePaintRect().y()), destinationRect.size());
- IntRect source2Rect(IntPoint(destinationRect.x() - in2->absolutePaintRect().x(),
+ FloatRect source2Rect(IntPoint(destinationRect.x() - in2->absolutePaintRect().x(),
destinationRect.y() - in2->absolutePaintRect().y()), destinationRect.size());
- filterContext->drawImageBuffer(imageBuffer2, destinationPoint, source2Rect);
- filterContext->drawImageBuffer(imageBuffer, destinationPoint, sourceRect, CompositeSourceIn);
+ filterContext->drawImageBuffer(imageBuffer2,
+ FloatRect(destinationPoint, imageBuffer2->size()), &source2Rect);
+ filterContext->drawImageBuffer(imageBuffer,
+ FloatRect(destinationPoint, imageBuffer->size()), &sourceRect, CompositeSourceIn);
break;
}
case FECOMPOSITE_OPERATOR_OUT:
filterContext->drawImageBuffer(imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()));
- filterContext->drawImageBuffer(imageBuffer2, drawingRegionOfInputImage(in2->absolutePaintRect()), IntRect(IntPoint(), imageBuffer2->size()), CompositeDestinationOut);
+ filterContext->drawImageBuffer(imageBuffer2, drawingRegionOfInputImage(in2->absolutePaintRect()), 0, CompositeDestinationOut);
break;
case FECOMPOSITE_OPERATOR_ATOP:
filterContext->drawImageBuffer(imageBuffer2, drawingRegionOfInputImage(in2->absolutePaintRect()));
- filterContext->drawImageBuffer(imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->size()), CompositeSourceAtop);
+ filterContext->drawImageBuffer(imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), 0, CompositeSourceAtop);
break;
case FECOMPOSITE_OPERATOR_XOR:
filterContext->drawImageBuffer(imageBuffer2, drawingRegionOfInputImage(in2->absolutePaintRect()));
- filterContext->drawImageBuffer(imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->size()), CompositeXOR);
+ filterContext->drawImageBuffer(imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), 0, CompositeXOR);
break;
default:
break;
@@ -342,15 +380,25 @@ SkXfermode::Mode toXfermode(WebCore::CompositeOperationType mode)
PassRefPtr<SkImageFilter> FEComposite::createImageFilter(SkiaImageFilterBuilder* builder)
{
- RefPtr<SkImageFilter> foreground(builder->build(inputEffect(0), operatingColorSpace()));
- RefPtr<SkImageFilter> background(builder->build(inputEffect(1), operatingColorSpace()));
- if (m_type == FECOMPOSITE_OPERATOR_ARITHMETIC) {
- SkAutoTUnref<SkXfermode> mode(SkArithmeticMode::Create(SkFloatToScalar(m_k1), SkFloatToScalar(m_k2), SkFloatToScalar(m_k3), SkFloatToScalar(m_k4)));
- return adoptRef(new SkXfermodeImageFilter(mode, background.get(), foreground.get()));
- }
+ return createImageFilterInternal(builder, true);
+}
+
+PassRefPtr<SkImageFilter> FEComposite::createImageFilterWithoutValidation(SkiaImageFilterBuilder* builder)
+{
+ return createImageFilterInternal(builder, false);
+}
+
+PassRefPtr<SkImageFilter> FEComposite::createImageFilterInternal(SkiaImageFilterBuilder* builder, bool requiresPMColorValidation)
+{
+ RefPtr<SkImageFilter> foreground(builder->build(inputEffect(0), operatingColorSpace(), !mayProduceInvalidPreMultipliedPixels()));
+ RefPtr<SkImageFilter> background(builder->build(inputEffect(1), operatingColorSpace(), !mayProduceInvalidPreMultipliedPixels()));
SkImageFilter::CropRect cropRect = getCropRect(builder->cropOffset());
- SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(toXfermode(m_type)));
- return adoptRef(new SkXfermodeImageFilter(mode, background.get(), foreground.get(), &cropRect));
+ RefPtr<SkXfermode> mode;
+ if (m_type == FECOMPOSITE_OPERATOR_ARITHMETIC)
+ mode = adoptRef(SkArithmeticMode::Create(SkFloatToScalar(m_k1), SkFloatToScalar(m_k2), SkFloatToScalar(m_k3), SkFloatToScalar(m_k4), requiresPMColorValidation));
+ else
+ mode = adoptRef(SkXfermode::Create(toXfermode(m_type)));
+ return adoptRef(SkXfermodeImageFilter::Create(mode.get(), background.get(), foreground.get(), &cropRect));
}
static TextStream& operator<<(TextStream& ts, const CompositeOperationType& type)
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEComposite.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEComposite.h
index afe24b7c07e..54a94e2eeca 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEComposite.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEComposite.h
@@ -60,19 +60,21 @@ public:
virtual void correctFilterResultIfNeeded() OVERRIDE;
- virtual void determineAbsolutePaintRect();
+ virtual FloatRect determineAbsolutePaintRect(const FloatRect& requestedRect) OVERRIDE;
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE;
+ virtual PassRefPtr<SkImageFilter> createImageFilterWithoutValidation(SkiaImageFilterBuilder*) OVERRIDE;
protected:
- virtual bool requiresValidPreMultipliedPixels() OVERRIDE { return m_type != FECOMPOSITE_OPERATOR_ARITHMETIC; }
+ virtual bool mayProduceInvalidPreMultipliedPixels() OVERRIDE { return m_type == FECOMPOSITE_OPERATOR_ARITHMETIC; }
private:
FEComposite(Filter*, const CompositeOperationType&, float, float, float, float);
virtual void applySoftware() OVERRIDE;
+ PassRefPtr<SkImageFilter> createImageFilterInternal(SkiaImageFilterBuilder*, bool requiresPMColorValidation);
inline void platformArithmeticSoftware(Uint8ClampedArray* source, Uint8ClampedArray* destination,
float k1, float k2, float k3, float k4);
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEConvolveMatrix.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEConvolveMatrix.cpp
index 454541e0b80..418f19b4604 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEConvolveMatrix.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEConvolveMatrix.cpp
@@ -59,6 +59,14 @@ PassRefPtr<FEConvolveMatrix> FEConvolveMatrix::create(Filter* filter, const IntS
preserveAlpha, kernelMatrix));
}
+FloatRect FEConvolveMatrix::mapPaintRect(const FloatRect& rect, bool forward)
+{
+ FloatRect result = rect;
+
+ result.moveBy(forward ? -m_targetOffset : m_targetOffset - m_kernelSize);
+ result.expand(m_kernelSize);
+ return result;
+}
IntSize FEConvolveMatrix::kernelSize() const
{
@@ -527,7 +535,7 @@ PassRefPtr<SkImageFilter> FEConvolveMatrix::createImageFilter(SkiaImageFilterBui
for (int i = 0; i < numElements; ++i)
kernel[i] = SkFloatToScalar(m_kernelMatrix[numElements - 1 - i]);
SkImageFilter::CropRect cropRect = getCropRect(builder->cropOffset());
- return adoptRef(new SkMatrixConvolutionImageFilter(kernelSize, kernel.get(), gain, bias, target, tileMode, convolveAlpha, input.get(), &cropRect));
+ return adoptRef(SkMatrixConvolutionImageFilter::Create(kernelSize, kernel.get(), gain, bias, target, tileMode, convolveAlpha, input.get(), &cropRect));
}
static TextStream& operator<<(TextStream& ts, const EdgeModeType& type)
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEConvolveMatrix.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEConvolveMatrix.h
index 2191c08a6b8..154ff1ddacb 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEConvolveMatrix.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEConvolveMatrix.h
@@ -71,9 +71,9 @@ public:
virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE;
- virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
+ virtual FloatRect mapPaintRect(const FloatRect&, bool forward = true) OVERRIDE FINAL;
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
private:
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDiffuseLighting.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDiffuseLighting.cpp
index b82fed523a0..cfba8d98260 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDiffuseLighting.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDiffuseLighting.cpp
@@ -78,6 +78,7 @@ float FEDiffuseLighting::diffuseConstant() const
bool FEDiffuseLighting::setDiffuseConstant(float diffuseConstant)
{
+ diffuseConstant = std::max(diffuseConstant, 0.0f);
if (m_diffuseConstant == diffuseConstant)
return false;
m_diffuseConstant = diffuseConstant;
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDiffuseLighting.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDiffuseLighting.h
index f93bc5ac0ed..8f2933bfffa 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDiffuseLighting.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDiffuseLighting.h
@@ -53,7 +53,7 @@ public:
const LightSource* lightSource() const;
void setLightSource(PassRefPtr<LightSource>);
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
private:
FEDiffuseLighting(Filter*, const Color&, float, float, float, float, PassRefPtr<LightSource>);
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDisplacementMap.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDisplacementMap.cpp
index ad31826126c..3c6544e8296 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDisplacementMap.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDisplacementMap.cpp
@@ -49,6 +49,14 @@ PassRefPtr<FEDisplacementMap> FEDisplacementMap::create(Filter* filter, ChannelS
return adoptRef(new FEDisplacementMap(filter, xChannelSelector, yChannelSelector, scale));
}
+FloatRect FEDisplacementMap::mapPaintRect(const FloatRect& rect, bool)
+{
+ FloatRect result = rect;
+ result.inflateX(filter()->applyHorizontalScale(m_scale / 2));
+ result.inflateY(filter()->applyVerticalScale(m_scale / 2));
+ return result;
+}
+
ChannelSelectorType FEDisplacementMap::xChannelSelector() const
{
return m_xChannelSelector;
@@ -168,48 +176,6 @@ static SkDisplacementMapEffect::ChannelSelectorType toSkiaMode(ChannelSelectorTy
}
}
-bool FEDisplacementMap::applySkia()
-{
- // For now, only use the skia implementation for accelerated rendering.
- if (!filter()->isAccelerated())
- return false;
-
- FilterEffect* in = inputEffect(0);
- FilterEffect* in2 = inputEffect(1);
-
- if (!in || !in2)
- return false;
-
- ImageBuffer* resultImage = createImageBufferResult();
- if (!resultImage)
- return false;
-
- RefPtr<Image> color = in->asImageBuffer()->copyImage(DontCopyBackingStore);
- RefPtr<Image> displ = in2->asImageBuffer()->copyImage(DontCopyBackingStore);
-
- RefPtr<NativeImageSkia> colorNativeImage = color->nativeImageForCurrentFrame();
- RefPtr<NativeImageSkia> displNativeImage = displ->nativeImageForCurrentFrame();
-
- if (!colorNativeImage || !displNativeImage)
- return false;
-
- SkBitmap colorBitmap = colorNativeImage->bitmap();
- SkBitmap displBitmap = displNativeImage->bitmap();
-
- SkAutoTUnref<SkImageFilter> colorSource(new SkBitmapSource(colorBitmap));
- SkAutoTUnref<SkImageFilter> displSource(new SkBitmapSource(displBitmap));
- SkDisplacementMapEffect::ChannelSelectorType typeX = toSkiaMode(m_xChannelSelector);
- SkDisplacementMapEffect::ChannelSelectorType typeY = toSkiaMode(m_yChannelSelector);
- // FIXME : Only applyHorizontalScale is used and applyVerticalScale is ignored
- // This can be fixed by adding a 2nd scale parameter to SkDisplacementMapEffect
- SkAutoTUnref<SkImageFilter> displEffect(new SkDisplacementMapEffect(
- typeX, typeY, SkFloatToScalar(filter()->applyHorizontalScale(m_scale)), displSource, colorSource));
- SkPaint paint;
- paint.setImageFilter(displEffect);
- resultImage->context()->drawBitmap(colorBitmap, 0, 0, &paint);
- return true;
-}
-
PassRefPtr<SkImageFilter> FEDisplacementMap::createImageFilter(SkiaImageFilterBuilder* builder)
{
RefPtr<SkImageFilter> color = builder->build(inputEffect(0), operatingColorSpace());
@@ -219,7 +185,7 @@ PassRefPtr<SkImageFilter> FEDisplacementMap::createImageFilter(SkiaImageFilterBu
SkImageFilter::CropRect cropRect = getCropRect(builder->cropOffset());
// FIXME : Only applyHorizontalScale is used and applyVerticalScale is ignored
// This can be fixed by adding a 2nd scale parameter to SkDisplacementMapEffect
- return adoptRef(new SkDisplacementMapEffect(typeX, typeY, SkFloatToScalar(filter()->applyHorizontalScale(m_scale)), displ.get(), color.get(), &cropRect));
+ return adoptRef(SkDisplacementMapEffect::Create(typeX, typeY, SkFloatToScalar(filter()->applyHorizontalScale(m_scale)), displ.get(), color.get(), &cropRect));
}
static TextStream& operator<<(TextStream& ts, const ChannelSelectorType& type)
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDisplacementMap.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDisplacementMap.h
index 91e151ef887..27601d71f9d 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDisplacementMap.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDisplacementMap.h
@@ -50,18 +50,17 @@ public:
float scale() const;
bool setScale(float);
- void setResultColorSpace(ColorSpace) OVERRIDE;
+ virtual void setResultColorSpace(ColorSpace) OVERRIDE;
virtual void transformResultColorSpace(FilterEffect*, const int) OVERRIDE;
- virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
+ virtual FloatRect mapPaintRect(const FloatRect&, bool forward = true) OVERRIDE FINAL;
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
private:
FEDisplacementMap(Filter*, ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float);
virtual void applySoftware() OVERRIDE;
- virtual bool applySkia() OVERRIDE;
virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE;
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.cpp
index 4e645b4f69d..443a52c998b 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.cpp
@@ -49,21 +49,6 @@ PassRefPtr<FEDropShadow> FEDropShadow::create(Filter* filter, float stdX, float
return adoptRef(new FEDropShadow(filter, stdX, stdY, dx, dy, shadowColor, shadowOpacity));
}
-void FEDropShadow::determineAbsolutePaintRect()
-{
- Filter* filter = this->filter();
- ASSERT_UNUSED(filter, filter);
-
- FloatRect absolutePaintRect = mapRect(inputEffect(0)->absolutePaintRect());
-
- if (clipsToBounds())
- absolutePaintRect.intersect(maxEffectRect());
- else
- absolutePaintRect.unite(maxEffectRect());
-
- setAbsolutePaintRect(enclosingIntRect(absolutePaintRect));
-}
-
FloatRect FEDropShadow::mapRect(const FloatRect& rect, bool forward)
{
FloatRect result = rect;
@@ -77,13 +62,11 @@ FloatRect FEDropShadow::mapRect(const FloatRect& rect, bool forward)
offsetRect.move(-filter->applyHorizontalScale(m_dx), -filter->applyVerticalScale(m_dy));
result.unite(offsetRect);
- unsigned kernelSizeX = 0;
- unsigned kernelSizeY = 0;
- FEGaussianBlur::calculateKernelSize(filter, kernelSizeX, kernelSizeY, m_stdX, m_stdY);
+ IntSize kernelSize = FEGaussianBlur::calculateKernelSize(filter, FloatPoint(m_stdX, m_stdY));
// We take the half kernel size and multiply it with three, because we run box blur three times.
- result.inflateX(3 * kernelSizeX * 0.5f);
- result.inflateY(3 * kernelSizeY * 0.5f);
+ result.inflateX(3 * kernelSize.width() * 0.5f);
+ result.inflateY(3 * kernelSize.height() * 0.5f);
return result;
}
@@ -103,8 +86,9 @@ void FEDropShadow::applySoftware()
GraphicsContext* resultContext = resultImage->context();
ASSERT(resultContext);
- SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(blurRadius.width(), blurRadius.height()));
- SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(m_shadowColor.rgb(), SkXfermode::kSrcIn_Mode));
+ Color color = adaptColorToOperatingColorSpace(m_shadowColor.combineWithAlpha(m_shadowOpacity));
+ SkAutoTUnref<SkImageFilter> blurFilter(SkBlurImageFilter::Create(blurRadius.width(), blurRadius.height()));
+ SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(color.rgb(), SkXfermode::kSrcIn_Mode));
SkPaint paint;
paint.setImageFilter(blurFilter.get());
paint.setColorFilter(colorFilter.get());
@@ -126,9 +110,10 @@ PassRefPtr<SkImageFilter> FEDropShadow::createImageFilter(SkiaImageFilterBuilder
float dx = filter()->applyHorizontalScale(m_dx);
float dy = filter()->applyVerticalScale(m_dy);
float stdX = filter()->applyHorizontalScale(m_stdX);
- float stdY = filter()->applyHorizontalScale(m_stdY);
+ float stdY = filter()->applyVerticalScale(m_stdY);
+ Color color = adaptColorToOperatingColorSpace(m_shadowColor.combineWithAlpha(m_shadowOpacity));
SkImageFilter::CropRect cropRect = getCropRect(builder->cropOffset());
- return adoptRef(new SkDropShadowImageFilter(SkFloatToScalar(dx), SkFloatToScalar(dy), SkFloatToScalar(stdX), SkFloatToScalar(stdY), m_shadowColor.rgb(), input.get(), &cropRect));
+ return adoptRef(SkDropShadowImageFilter::Create(SkFloatToScalar(dx), SkFloatToScalar(dy), SkFloatToScalar(stdX), SkFloatToScalar(stdY), color.rgb(), input.get(), &cropRect));
}
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.h
index a3d9d956272..38d643ee135 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.h
@@ -49,12 +49,9 @@ public:
float shadowOpacity() const { return m_shadowOpacity; }
void setShadowOpacity(float shadowOpacity) { m_shadowOpacity = shadowOpacity; }
- static float calculateStdDeviation(float);
-
- virtual void determineAbsolutePaintRect();
virtual FloatRect mapRect(const FloatRect&, bool forward = true) OVERRIDE FINAL;
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE;
private:
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEFlood.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEFlood.cpp
index 03ed1f439c3..3bd7991f542 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEFlood.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEFlood.cpp
@@ -40,7 +40,6 @@ FEFlood::FEFlood(Filter* filter, const Color& floodColor, float floodOpacity)
, m_floodOpacity(floodOpacity)
{
FilterEffect::setOperatingColorSpace(ColorSpaceDeviceRGB);
- FilterEffect::setResultColorSpace(ColorSpaceDeviceRGB);
}
PassRefPtr<FEFlood> FEFlood::create(Filter* filter, const Color& floodColor, float floodOpacity)
@@ -80,13 +79,14 @@ void FEFlood::applySoftware()
if (!resultImage)
return;
- Color color = colorWithOverrideAlpha(floodColor().rgb(), floodOpacity());
+ Color color = floodColor().combineWithAlpha(floodOpacity());
resultImage->context()->fillRect(FloatRect(FloatPoint(), absolutePaintRect().size()), color);
+ FilterEffect::setResultColorSpace(ColorSpaceDeviceRGB);
}
PassRefPtr<SkImageFilter> FEFlood::createImageFilter(SkiaImageFilterBuilder* builder)
{
- Color color = colorWithOverrideAlpha(floodColor().rgb(), floodOpacity());
+ Color color = floodColor().combineWithAlpha(floodOpacity());
SkImageFilter::CropRect rect = getCropRect(builder->cropOffset());
SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(color.rgb(), SkXfermode::kSrc_Mode));
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEFlood.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEFlood.h
index 918811c7ac2..ee91a997d23 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEFlood.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEFlood.h
@@ -41,14 +41,12 @@ public:
// feFlood does not perform color interpolation of any kind, so the result is always in the current
// color space regardless of the value of color-interpolation-filters.
- void setOperatingColorSpace(ColorSpace) OVERRIDE { }
- void setResultColorSpace(ColorSpace) OVERRIDE { }
+ virtual void setOperatingColorSpace(ColorSpace) OVERRIDE { }
+ virtual void setResultColorSpace(ColorSpace) OVERRIDE { }
virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE;
- virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
-
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
private:
FEFlood(Filter*, const Color&, float);
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEGaussianBlur.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEGaussianBlur.cpp
index 150aac53213..82554826e56 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEGaussianBlur.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEGaussianBlur.cpp
@@ -41,10 +41,10 @@ using namespace std;
static inline float gaussianKernelFactor()
{
- return 3 / 4.f * sqrtf(2 * piFloat);
+ return 3 / 4.f * sqrtf(twoPiFloat);
}
-static const unsigned gMaxKernelSize = 1000;
+static const int gMaxKernelSize = 1000;
namespace WebCore {
@@ -80,238 +80,69 @@ void FEGaussianBlur::setStdDeviationY(float y)
m_stdY = y;
}
-inline void boxBlur(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* dstPixelArray,
- unsigned dx, int dxLeft, int dxRight, int stride, int strideLine, int effectWidth, int effectHeight, bool alphaImage)
+IntSize FEGaussianBlur::calculateUnscaledKernelSize(const FloatPoint& std)
{
- for (int y = 0; y < effectHeight; ++y) {
- int line = y * strideLine;
- for (int channel = 3; channel >= 0; --channel) {
- int sum = 0;
- // Fill the kernel
- int maxKernelSize = min(dxRight, effectWidth);
- for (int i = 0; i < maxKernelSize; ++i)
- sum += srcPixelArray->item(line + i * stride + channel);
-
- // Blurring
- for (int x = 0; x < effectWidth; ++x) {
- int pixelByteOffset = line + x * stride + channel;
- dstPixelArray->set(pixelByteOffset, static_cast<unsigned char>(sum / dx));
- if (x >= dxLeft)
- sum -= srcPixelArray->item(pixelByteOffset - dxLeft * stride);
- if (x + dxRight < effectWidth)
- sum += srcPixelArray->item(pixelByteOffset + dxRight * stride);
- }
- if (alphaImage) // Source image is black, it just has different alpha values
- break;
- }
- }
-}
-
-inline void FEGaussianBlur::platformApplyGeneric(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize)
-{
- int stride = 4 * paintSize.width();
- int dxLeft = 0;
- int dxRight = 0;
- int dyLeft = 0;
- int dyRight = 0;
- Uint8ClampedArray* src = srcPixelArray;
- Uint8ClampedArray* dst = tmpPixelArray;
-
- for (int i = 0; i < 3; ++i) {
- if (kernelSizeX) {
- kernelPosition(i, kernelSizeX, dxLeft, dxRight);
-#if HAVE(ARM_NEON_INTRINSICS)
- if (!isAlphaImage())
- boxBlurNEON(src, dst, kernelSizeX, dxLeft, dxRight, 4, stride, paintSize.width(), paintSize.height());
- else
- boxBlur(src, dst, kernelSizeX, dxLeft, dxRight, 4, stride, paintSize.width(), paintSize.height(), true);
-#else
- boxBlur(src, dst, kernelSizeX, dxLeft, dxRight, 4, stride, paintSize.width(), paintSize.height(), isAlphaImage());
-#endif
- swap(src, dst);
- }
-
- if (kernelSizeY) {
- kernelPosition(i, kernelSizeY, dyLeft, dyRight);
-#if HAVE(ARM_NEON_INTRINSICS)
- if (!isAlphaImage())
- boxBlurNEON(src, dst, kernelSizeY, dyLeft, dyRight, stride, 4, paintSize.height(), paintSize.width());
- else
- boxBlur(src, dst, kernelSizeY, dyLeft, dyRight, stride, 4, paintSize.height(), paintSize.width(), true);
-#else
- boxBlur(src, dst, kernelSizeY, dyLeft, dyRight, stride, 4, paintSize.height(), paintSize.width(), isAlphaImage());
-#endif
- swap(src, dst);
- }
- }
-
- // The final result should be stored in srcPixelArray.
- if (dst == srcPixelArray) {
- ASSERT(src->length() == dst->length());
- memcpy(dst->data(), src->data(), src->length());
- }
-
-}
-
-void FEGaussianBlur::platformApplyWorker(PlatformApplyParameters* parameters)
-{
- IntSize paintSize(parameters->width, parameters->height);
- parameters->filter->platformApplyGeneric(parameters->srcPixelArray.get(), parameters->dstPixelArray.get(),
- parameters->kernelSizeX, parameters->kernelSizeY, paintSize);
-}
-
-inline void FEGaussianBlur::platformApply(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize)
-{
- int scanline = 4 * paintSize.width();
- int extraHeight = 3 * kernelSizeY * 0.5f;
- int optimalThreadNumber = (paintSize.width() * paintSize.height()) / (s_minimalRectDimension + extraHeight * paintSize.width());
-
- if (optimalThreadNumber > 1) {
- ParallelJobs<PlatformApplyParameters> parallelJobs(&platformApplyWorker, optimalThreadNumber);
-
- int jobs = parallelJobs.numberOfJobs();
- if (jobs > 1) {
- // Split the job into "blockHeight"-sized jobs but there a few jobs that need to be slightly larger since
- // blockHeight * jobs < total size. These extras are handled by the remainder "jobsWithExtra".
- const int blockHeight = paintSize.height() / jobs;
- const int jobsWithExtra = paintSize.height() % jobs;
-
- int currentY = 0;
- for (int job = 0; job < jobs; job++) {
- PlatformApplyParameters& params = parallelJobs.parameter(job);
- params.filter = this;
-
- int startY = !job ? 0 : currentY - extraHeight;
- currentY += job < jobsWithExtra ? blockHeight + 1 : blockHeight;
- int endY = job == jobs - 1 ? currentY : currentY + extraHeight;
-
- int blockSize = (endY - startY) * scanline;
- if (!job) {
- params.srcPixelArray = srcPixelArray;
- params.dstPixelArray = tmpPixelArray;
- } else {
- params.srcPixelArray = Uint8ClampedArray::createUninitialized(blockSize);
- params.dstPixelArray = Uint8ClampedArray::createUninitialized(blockSize);
- memcpy(params.srcPixelArray->data(), srcPixelArray->data() + startY * scanline, blockSize);
- }
-
- params.width = paintSize.width();
- params.height = endY - startY;
- params.kernelSizeX = kernelSizeX;
- params.kernelSizeY = kernelSizeY;
- }
-
- parallelJobs.execute();
-
- // Copy together the parts of the image.
- currentY = 0;
- for (int job = 1; job < jobs; job++) {
- PlatformApplyParameters& params = parallelJobs.parameter(job);
- int sourceOffset;
- int destinationOffset;
- int size;
- int adjustedBlockHeight = job < jobsWithExtra ? blockHeight + 1 : blockHeight;
-
- currentY += adjustedBlockHeight;
- sourceOffset = extraHeight * scanline;
- destinationOffset = currentY * scanline;
- size = adjustedBlockHeight * scanline;
-
- memcpy(srcPixelArray->data() + destinationOffset, params.srcPixelArray->data() + sourceOffset, size);
- }
- return;
- }
- // Fallback to single threaded mode.
- }
-
- // The selection here eventually should happen dynamically on some platforms.
- platformApplyGeneric(srcPixelArray, tmpPixelArray, kernelSizeX, kernelSizeY, paintSize);
-}
-
-void FEGaussianBlur::calculateUnscaledKernelSize(unsigned& kernelSizeX, unsigned& kernelSizeY, float stdX, float stdY)
-{
- ASSERT(stdX >= 0 && stdY >= 0);
-
- kernelSizeX = 0;
- if (stdX)
- kernelSizeX = max<unsigned>(2, static_cast<unsigned>(floorf(stdX * gaussianKernelFactor() + 0.5f)));
- kernelSizeY = 0;
- if (stdY)
- kernelSizeY = max<unsigned>(2, static_cast<unsigned>(floorf(stdY * gaussianKernelFactor() + 0.5f)));
+ ASSERT(std.x() >= 0 && std.y() >= 0);
+ IntSize kernelSize;
// Limit the kernel size to 1000. A bigger radius won't make a big difference for the result image but
// inflates the absolute paint rect to much. This is compatible with Firefox' behavior.
- if (kernelSizeX > gMaxKernelSize)
- kernelSizeX = gMaxKernelSize;
- if (kernelSizeY > gMaxKernelSize)
- kernelSizeY = gMaxKernelSize;
-}
+ if (std.x()) {
+ int size = max<unsigned>(2, static_cast<unsigned>(floorf(std.x() * gaussianKernelFactor() + 0.5f)));
+ kernelSize.setWidth(min(size, gMaxKernelSize));
+ }
-void FEGaussianBlur::calculateKernelSize(Filter* filter, unsigned& kernelSizeX, unsigned& kernelSizeY, float stdX, float stdY)
-{
- stdX = filter->applyHorizontalScale(stdX);
- stdY = filter->applyVerticalScale(stdY);
+ if (std.y()) {
+ int size = max<unsigned>(2, static_cast<unsigned>(floorf(std.y() * gaussianKernelFactor() + 0.5f)));
+ kernelSize.setHeight(min(size, gMaxKernelSize));
+ }
- calculateUnscaledKernelSize(kernelSizeX, kernelSizeY, stdX, stdY);
+ return kernelSize;
}
-void FEGaussianBlur::determineAbsolutePaintRect()
+IntSize FEGaussianBlur::calculateKernelSize(Filter* filter, const FloatPoint& std)
{
- FloatRect absolutePaintRect = mapRect(inputEffect(0)->absolutePaintRect());
-
- if (clipsToBounds())
- absolutePaintRect.intersect(maxEffectRect());
- else
- absolutePaintRect.unite(maxEffectRect());
+ FloatPoint stdError(filter->applyHorizontalScale(std.x()), filter->applyVerticalScale(std.y()));
- setAbsolutePaintRect(enclosingIntRect(absolutePaintRect));
+ return calculateUnscaledKernelSize(stdError);
}
FloatRect FEGaussianBlur::mapRect(const FloatRect& rect, bool)
{
FloatRect result = rect;
- unsigned kernelSizeX = 0;
- unsigned kernelSizeY = 0;
- calculateKernelSize(filter(), kernelSizeX, kernelSizeY, m_stdX, m_stdY);
+ IntSize kernelSize = calculateKernelSize(filter(), FloatPoint(m_stdX, m_stdY));
// We take the half kernel size and multiply it with three, because we run box blur three times.
- result.inflateX(3 * kernelSizeX * 0.5f);
- result.inflateY(3 * kernelSizeY * 0.5f);
+ result.inflateX(3 * kernelSize.width() * 0.5f);
+ result.inflateY(3 * kernelSize.height() * 0.5f);
return result;
}
-void FEGaussianBlur::applySoftware()
+FloatRect FEGaussianBlur::determineAbsolutePaintRect(const FloatRect& originalRequestedRect)
{
- FilterEffect* in = inputEffect(0);
-
- Uint8ClampedArray* srcPixelArray = createPremultipliedImageResult();
- if (!srcPixelArray)
- return;
-
- setIsAlphaImage(in->isAlphaImage());
-
- IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
- in->copyPremultipliedImage(srcPixelArray, effectDrawingRect);
-
- if (!m_stdX && !m_stdY)
- return;
-
- unsigned kernelSizeX = 0;
- unsigned kernelSizeY = 0;
- calculateKernelSize(filter(), kernelSizeX, kernelSizeY, m_stdX, m_stdY);
+ FloatRect requestedRect = originalRequestedRect;
+ if (clipsToBounds())
+ requestedRect.intersect(maxEffectRect());
- IntSize paintSize = absolutePaintRect().size();
- RefPtr<Uint8ClampedArray> tmpImageData = Uint8ClampedArray::createUninitialized(paintSize.width() * paintSize.height() * 4);
- Uint8ClampedArray* tmpPixelArray = tmpImageData.get();
+ FilterEffect* input = inputEffect(0);
+ FloatRect inputRect = input->determineAbsolutePaintRect(mapRect(requestedRect, false));
+ FloatRect outputRect = mapRect(inputRect, true);
+ outputRect.intersect(requestedRect);
+ addAbsolutePaintRect(outputRect);
- platformApply(srcPixelArray, tmpPixelArray, kernelSizeX, kernelSizeY, paintSize);
+ // Blur needs space for both input and output pixels in the paint area.
+ // Input is also clipped to subregion.
+ if (clipsToBounds())
+ inputRect.intersect(maxEffectRect());
+ addAbsolutePaintRect(inputRect);
+ return outputRect;
}
-bool FEGaussianBlur::applySkia()
+void FEGaussianBlur::applySoftware()
{
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
- return false;
+ return;
FilterEffect* in = inputEffect(0);
@@ -326,13 +157,13 @@ bool FEGaussianBlur::applySkia()
SkPaint paint;
GraphicsContext* dstContext = resultImage->context();
- paint.setImageFilter(new SkBlurImageFilter(stdX, stdY))->unref();
+ paint.setImageFilter(SkBlurImageFilter::Create(stdX, stdY))->unref();
- dstContext->saveLayer(0, &paint);
+ SkRect bounds = SkRect::MakeWH(absolutePaintRect().width(), absolutePaintRect().height());
+ dstContext->saveLayer(&bounds, &paint);
paint.setColor(0xFFFFFFFF);
dstContext->drawImage(image.get(), drawingRegion.location(), CompositeCopy);
dstContext->restoreLayer();
- return true;
}
PassRefPtr<SkImageFilter> FEGaussianBlur::createImageFilter(SkiaImageFilterBuilder* builder)
@@ -341,7 +172,7 @@ PassRefPtr<SkImageFilter> FEGaussianBlur::createImageFilter(SkiaImageFilterBuild
float stdX = filter()->applyHorizontalScale(m_stdX);
float stdY = filter()->applyVerticalScale(m_stdY);
SkImageFilter::CropRect rect = getCropRect(builder->cropOffset());
- return adoptRef(new SkBlurImageFilter(SkFloatToScalar(stdX), SkFloatToScalar(stdY), input.get(), &rect));
+ return adoptRef(SkBlurImageFilter::Create(SkFloatToScalar(stdX), SkFloatToScalar(stdY), input.get(), &rect));
}
TextStream& FEGaussianBlur::externalRepresentation(TextStream& ts, int indent) const
@@ -354,10 +185,4 @@ TextStream& FEGaussianBlur::externalRepresentation(TextStream& ts, int indent) c
return ts;
}
-float FEGaussianBlur::calculateStdDeviation(float radius)
-{
- // Blur radius represents 2/3 times the kernel size, the dest pixel is half of the radius applied 3 times
- return max((radius * 2 / 3.f - 0.5f) / gaussianKernelFactor(), 0.f);
-}
-
} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEGaussianBlur.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEGaussianBlur.h
index 1974bea46d6..c10d220d941 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEGaussianBlur.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEGaussianBlur.h
@@ -38,14 +38,12 @@ public:
float stdDeviationY() const;
void setStdDeviationY(float);
- static float calculateStdDeviation(float);
-
- virtual void determineAbsolutePaintRect();
virtual FloatRect mapRect(const FloatRect&, bool forward = true) OVERRIDE FINAL;
- static void calculateKernelSize(Filter*, unsigned& kernelSizeX, unsigned& kernelSizeY, float stdX, float stdY);
- static void calculateUnscaledKernelSize(unsigned& kernelSizeX, unsigned& kernelSizeY, float stdX, float stdY);
+ virtual FloatRect determineAbsolutePaintRect(const FloatRect& requestedRect) OVERRIDE;
+ static IntSize calculateKernelSize(Filter*, const FloatPoint& std);
+ static IntSize calculateUnscaledKernelSize(const FloatPoint& std);
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
private:
static const int s_minimalRectDimension = 100 * 100; // Empirical data limit for parallel jobs
@@ -63,51 +61,16 @@ private:
unsigned kernelSizeY;
};
- static void platformApplyWorker(PlatformApplyParameters*);
-
FEGaussianBlur(Filter*, float, float);
virtual void applySoftware() OVERRIDE;
- virtual bool applySkia() OVERRIDE;
- static inline void kernelPosition(int boxBlur, unsigned& std, int& dLeft, int& dRight);
- inline void platformApply(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize);
-
- inline void platformApplyGeneric(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize);
virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE;
float m_stdX;
float m_stdY;
};
-inline void FEGaussianBlur::kernelPosition(int boxBlur, unsigned& std, int& dLeft, int& dRight)
-{
- // check http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement for details
- switch (boxBlur) {
- case 0:
- if (!(std % 2)) {
- dLeft = std / 2 - 1;
- dRight = std - dLeft;
- } else {
- dLeft = std / 2;
- dRight = std - dLeft;
- }
- break;
- case 1:
- if (!(std % 2)) {
- dLeft++;
- dRight--;
- }
- break;
- case 2:
- if (!(std % 2)) {
- dRight++;
- std++;
- }
- break;
- }
-}
-
} // namespace WebCore
#endif // FEGaussianBlur_h
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FELighting.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FELighting.cpp
index 92efec12059..8e6bc1818ac 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FELighting.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FELighting.cpp
@@ -29,7 +29,6 @@
#include "platform/graphics/filters/FELighting.h"
#include "SkLightingImageFilter.h"
-#include "platform/graphics/cpu/arm/filters/FELightingNEON.h"
#include "platform/graphics/filters/DistantLightSource.h"
#include "platform/graphics/filters/ParallelJobs.h"
#include "platform/graphics/filters/SkiaImageFilterBuilder.h"
@@ -45,14 +44,22 @@ FELighting::FELighting(Filter* filter, LightingType lightingType, const Color& l
, m_lightSource(lightSource)
, m_lightingColor(lightingColor)
, m_surfaceScale(surfaceScale)
- , m_diffuseConstant(diffuseConstant)
- , m_specularConstant(specularConstant)
- , m_specularExponent(specularExponent)
+ , m_diffuseConstant(std::max(diffuseConstant, 0.0f))
+ , m_specularConstant(std::max(specularConstant, 0.0f))
+ , m_specularExponent(std::min(std::max(specularExponent, 1.0f), 128.0f))
, m_kernelUnitLengthX(kernelUnitLengthX)
, m_kernelUnitLengthY(kernelUnitLengthY)
{
}
+FloatRect FELighting::mapPaintRect(const FloatRect& rect, bool)
+{
+ FloatRect result = rect;
+ // The areas affected need to be a pixel bigger to accommodate the Sobel kernel.
+ result.inflate(1);
+ return result;
+}
+
const static int cPixelSize = 4;
const static int cAlphaChannelOffset = 3;
const static unsigned char cOpaqueAlpha = static_cast<unsigned char>(0xff);
@@ -179,7 +186,7 @@ inline void FELighting::LightingData::bottomRight(int offset, IntPoint& normalVe
inline void FELighting::inlineSetPixel(int offset, LightingData& data, LightSource::PaintingData& paintingData,
int lightX, int lightY, float factorX, float factorY, IntPoint& normal2DVector)
{
- m_lightSource->updatePaintingData(paintingData, lightX, lightY, static_cast<float>(data.pixels->item(offset + cAlphaChannelOffset)) * data.surfaceScale);
+ data.lightSource->updatePaintingData(paintingData, lightX, lightY, static_cast<float>(data.pixels->item(offset + cAlphaChannelOffset)) * data.surfaceScale);
float lightStrength;
if (!normal2DVector.x() && !normal2DVector.y()) {
@@ -286,12 +293,21 @@ inline void FELighting::platformApplyGeneric(LightingData& data, LightSource::Pa
inline void FELighting::platformApply(LightingData& data, LightSource::PaintingData& paintingData)
{
- // The selection here eventually should happen dynamically on some platforms.
-#if CPU(ARM_NEON) && CPU(ARM_TRADITIONAL) && COMPILER(GCC)
- platformApplyNeon(data, paintingData);
-#else
platformApplyGeneric(data, paintingData);
-#endif
+}
+
+void FELighting::getTransform(FloatPoint3D* scale, FloatSize* offset) const
+{
+ FloatRect initialEffectRect = effectBoundaries();
+ FloatRect absoluteEffectRect = filter()->mapLocalRectToAbsoluteRect(initialEffectRect);
+ FloatPoint absoluteLocation(absolutePaintRect().location());
+ FloatSize positionOffset(absoluteLocation - absoluteEffectRect.location());
+ offset->setWidth(positionOffset.width());
+ offset->setHeight(positionOffset.height());
+ scale->setX(initialEffectRect.width() > 0.0f && initialEffectRect.width() > 0.0f ? absoluteEffectRect.width() / initialEffectRect.width() : 1.0f);
+ scale->setY(initialEffectRect.height() > 0.0f && initialEffectRect.height() > 0.0f ? absoluteEffectRect.height() / initialEffectRect.height() : 1.0f);
+ // X and Y scale should be the same, but, if not, do a best effort by averaging the 2 for Z scale
+ scale->setZ(0.5f * (scale->x() + scale->y()));
}
bool FELighting::drawLighting(Uint8ClampedArray* pixels, int width, int height)
@@ -312,8 +328,14 @@ bool FELighting::drawLighting(Uint8ClampedArray* pixels, int width, int height)
data.widthMultipliedByPixelSize = width * cPixelSize;
data.widthDecreasedByOne = width - 1;
data.heightDecreasedByOne = height - 1;
- paintingData.colorVector = FloatPoint3D(m_lightingColor.red(), m_lightingColor.green(), m_lightingColor.blue());
- m_lightSource->initPaintingData(paintingData);
+ FloatPoint3D worldScale;
+ FloatSize originOffset;
+ getTransform(&worldScale, &originOffset);
+ RefPtr<LightSource> lightSource = m_lightSource->create(worldScale, originOffset);
+ data.lightSource = lightSource.get();
+ Color lightColor = adaptColorToOperatingColorSpace(m_lightingColor);
+ paintingData.colorVector = FloatPoint3D(lightColor.red(), lightColor.green(), lightColor.blue());
+ data.lightSource->initPaintingData(paintingData);
// Top/Left corner.
IntPoint normalVector;
@@ -413,7 +435,8 @@ void FELighting::applySoftware()
PassRefPtr<SkImageFilter> FELighting::createImageFilter(SkiaImageFilterBuilder* builder)
{
SkImageFilter::CropRect rect = getCropRect(builder ? builder->cropOffset() : FloatSize());
- RefPtr<SkImageFilter> input(builder ? builder->build(inputEffect(0), operatingColorSpace()) : 0);
+ Color lightColor = adaptColorToOperatingColorSpace(m_lightingColor);
+ RefPtr<SkImageFilter> input(builder ? builder->build(inputEffect(0), operatingColorSpace()) : nullptr);
switch (m_lightSource->type()) {
case LS_DISTANT: {
DistantLightSource* distantLightSource = static_cast<DistantLightSource*>(m_lightSource.get());
@@ -423,16 +446,16 @@ PassRefPtr<SkImageFilter> FELighting::createImageFilter(SkiaImageFilterBuilder*
sinf(azimuthRad) * cosf(elevationRad),
sinf(elevationRad));
if (m_specularConstant > 0)
- return adoptRef(SkLightingImageFilter::CreateDistantLitSpecular(direction, m_lightingColor.rgb(), m_surfaceScale, m_specularConstant, m_specularExponent, input.get(), &rect));
- return adoptRef(SkLightingImageFilter::CreateDistantLitDiffuse(direction, m_lightingColor.rgb(), m_surfaceScale, m_diffuseConstant, input.get(), &rect));
+ return adoptRef(SkLightingImageFilter::CreateDistantLitSpecular(direction, lightColor.rgb(), m_surfaceScale, m_specularConstant, m_specularExponent, input.get(), &rect));
+ return adoptRef(SkLightingImageFilter::CreateDistantLitDiffuse(direction, lightColor.rgb(), m_surfaceScale, m_diffuseConstant, input.get(), &rect));
}
case LS_POINT: {
PointLightSource* pointLightSource = static_cast<PointLightSource*>(m_lightSource.get());
FloatPoint3D position = pointLightSource->position();
SkPoint3 skPosition(position.x(), position.y(), position.z());
if (m_specularConstant > 0)
- return adoptRef(SkLightingImageFilter::CreatePointLitSpecular(skPosition, m_lightingColor.rgb(), m_surfaceScale, m_specularConstant, m_specularExponent, input.get(), &rect));
- return adoptRef(SkLightingImageFilter::CreatePointLitDiffuse(skPosition, m_lightingColor.rgb(), m_surfaceScale, m_diffuseConstant, input.get(), &rect));
+ return adoptRef(SkLightingImageFilter::CreatePointLitSpecular(skPosition, lightColor.rgb(), m_surfaceScale, m_specularConstant, m_specularExponent, input.get(), &rect));
+ return adoptRef(SkLightingImageFilter::CreatePointLitDiffuse(skPosition, lightColor.rgb(), m_surfaceScale, m_diffuseConstant, input.get(), &rect));
}
case LS_SPOT: {
SpotLightSource* spotLightSource = static_cast<SpotLightSource*>(m_lightSource.get());
@@ -443,43 +466,13 @@ PassRefPtr<SkImageFilter> FELighting::createImageFilter(SkiaImageFilterBuilder*
if (!limitingConeAngle || limitingConeAngle > 90 || limitingConeAngle < -90)
limitingConeAngle = 90;
if (m_specularConstant > 0)
- return adoptRef(SkLightingImageFilter::CreateSpotLitSpecular(location, target, specularExponent, limitingConeAngle, m_lightingColor.rgb(), m_surfaceScale, m_specularConstant, m_specularExponent, input.get(), &rect));
- return adoptRef(SkLightingImageFilter::CreateSpotLitDiffuse(location, target, specularExponent, limitingConeAngle, m_lightingColor.rgb(), m_surfaceScale, m_diffuseConstant, input.get(), &rect));
+ return adoptRef(SkLightingImageFilter::CreateSpotLitSpecular(location, target, specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale, m_specularConstant, m_specularExponent, input.get(), &rect));
+ return adoptRef(SkLightingImageFilter::CreateSpotLitDiffuse(location, target, specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale, m_diffuseConstant, input.get(), &rect));
}
default:
ASSERT_NOT_REACHED();
- return 0;
+ return nullptr;
}
}
-bool FELighting::applySkia()
-{
- // For now, only use the skia implementation for accelerated rendering.
- if (!filter()->isAccelerated())
- return false;
-
- ImageBuffer* resultImage = createImageBufferResult();
- if (!resultImage)
- return false;
-
- FilterEffect* in = inputEffect(0);
-
- IntRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect());
-
- setIsAlphaImage(in->isAlphaImage());
-
- RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
- RefPtr<NativeImageSkia> nativeImage = image->nativeImageForCurrentFrame();
- if (!nativeImage)
- return false;
-
- GraphicsContext* dstContext = resultImage->context();
-
- SkPaint paint;
- RefPtr<SkImageFilter> filter = createImageFilter(0);
- paint.setImageFilter(filter.get());
- dstContext->drawBitmap(nativeImage->bitmap(), drawingRegion.location().x(), drawingRegion.location().y(), &paint);
- return true;
-}
-
} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FELighting.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FELighting.h
index 32fdc122005..123fe51619f 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FELighting.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FELighting.h
@@ -40,14 +40,10 @@
namespace WebCore {
-struct FELightingPaintingDataForNeon;
-
class PLATFORM_EXPORT FELighting : public FilterEffect {
public:
virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE;
- virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
-
protected:
static const int s_minimalRectDimension = 100 * 100; // Empirical data limit for parallel jobs
@@ -63,6 +59,7 @@ protected:
int widthMultipliedByPixelSize;
int widthDecreasedByOne;
int heightDecreasedByOne;
+ const LightSource* lightSource;
inline void topLeft(int offset, IntPoint& normalVector);
inline void topRow(int offset, IntPoint& normalVector);
@@ -86,8 +83,10 @@ protected:
int yEnd;
};
+ virtual FloatRect mapPaintRect(const FloatRect&, bool forward = true) OVERRIDE FINAL;
+ virtual bool affectsTransparentPixels() OVERRIDE { return true; }
+
static void platformApplyGenericWorker(PlatformApplyGenericParameters*);
- static void platformApplyNeonWorker(FELightingPaintingDataForNeon*);
FELighting(Filter*, LightingType, const Color&, float, float, float, float, float, float, PassRefPtr<LightSource>);
@@ -104,9 +103,6 @@ protected:
inline void platformApplyGenericPaint(LightingData&, LightSource::PaintingData&, int startX, int startY);
inline void platformApplyGeneric(LightingData&, LightSource::PaintingData&);
- static int getPowerCoefficients(float exponent);
- inline void platformApplyNeon(LightingData&, LightSource::PaintingData&);
-
LightingType m_lightingType;
RefPtr<LightSource> m_lightSource;
@@ -120,7 +116,8 @@ protected:
private:
virtual void applySoftware() OVERRIDE;
- virtual bool applySkia() OVERRIDE;
+
+ void getTransform(FloatPoint3D* scale, FloatSize* offset) const;
};
} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEMerge.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEMerge.cpp
index c31440d44c4..3845ffe0e22 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEMerge.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEMerge.cpp
@@ -68,7 +68,7 @@ PassRefPtr<SkImageFilter> FEMerge::createImageFilter(SkiaImageFilterBuilder* bui
inputs[i] = inputRefs[i].get();
}
SkImageFilter::CropRect rect = getCropRect(builder->cropOffset());
- return adoptRef(new SkMergeImageFilter(inputs.get(), size, 0, &rect));
+ return adoptRef(SkMergeImageFilter::Create(inputs.get(), size, 0, &rect));
}
TextStream& FEMerge::externalRepresentation(TextStream& ts, int indent) const
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEMerge.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEMerge.h
index 05e374e58e4..22fd7fc560f 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEMerge.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEMerge.h
@@ -35,7 +35,7 @@ public:
virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE;
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
private:
FEMerge(Filter*);
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEMorphology.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEMorphology.cpp
index 5201a45dcde..00483e803b0 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEMorphology.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEMorphology.cpp
@@ -26,6 +26,8 @@
#include "platform/graphics/filters/FEMorphology.h"
#include "SkMorphologyImageFilter.h"
+#include "platform/graphics/GraphicsContext.h"
+#include "platform/graphics/Image.h"
#include "platform/graphics/filters/ParallelJobs.h"
#include "platform/graphics/filters/SkiaImageFilterBuilder.h"
#include "platform/text/TextStream.h"
@@ -80,16 +82,6 @@ float FEMorphology::radiusY() const
return m_radiusY;
}
-void FEMorphology::determineAbsolutePaintRect()
-{
- FloatRect paintRect = mapRect(inputEffect(0)->absolutePaintRect());
- if (clipsToBounds())
- paintRect.intersect(maxEffectRect());
- else
- paintRect.unite(maxEffectRect());
- setAbsolutePaintRect(enclosingIntRect(paintRect));
-}
-
FloatRect FEMorphology::mapRect(const FloatRect& rect, bool)
{
FloatRect result = rect;
@@ -106,135 +98,11 @@ bool FEMorphology::setRadiusY(float radiusY)
return true;
}
-void FEMorphology::platformApplyGeneric(PaintingData* paintingData, int yStart, int yEnd)
-{
- Uint8ClampedArray* srcPixelArray = paintingData->srcPixelArray;
- Uint8ClampedArray* dstPixelArray = paintingData->dstPixelArray;
- const int width = paintingData->width;
- const int height = paintingData->height;
- const int effectWidth = width * 4;
- const int radiusX = paintingData->radiusX;
- const int radiusY = paintingData->radiusY;
-
- Vector<unsigned char> extrema;
- for (int y = yStart; y < yEnd; ++y) {
- int extremaStartY = max(0, y - radiusY);
- int extremaEndY = min(height - 1, y + radiusY);
- for (unsigned clrChannel = 0; clrChannel < 4; ++clrChannel) {
- extrema.clear();
- // Compute extremas for each columns
- for (int x = 0; x <= radiusX; ++x) {
- unsigned char columnExtrema = srcPixelArray->item(extremaStartY * effectWidth + 4 * x + clrChannel);
- for (int eY = extremaStartY + 1; eY < extremaEndY; ++eY) {
- unsigned char pixel = srcPixelArray->item(eY * effectWidth + 4 * x + clrChannel);
- if ((m_type == FEMORPHOLOGY_OPERATOR_ERODE && pixel <= columnExtrema)
- || (m_type == FEMORPHOLOGY_OPERATOR_DILATE && pixel >= columnExtrema)) {
- columnExtrema = pixel;
- }
- }
-
- extrema.append(columnExtrema);
- }
-
- // Kernel is filled, get extrema of next column
- for (int x = 0; x < width; ++x) {
- const int endX = min(x + radiusX, width - 1);
- unsigned char columnExtrema = srcPixelArray->item(extremaStartY * effectWidth + endX * 4 + clrChannel);
- for (int i = extremaStartY + 1; i <= extremaEndY; ++i) {
- unsigned char pixel = srcPixelArray->item(i * effectWidth + endX * 4 + clrChannel);
- if ((m_type == FEMORPHOLOGY_OPERATOR_ERODE && pixel <= columnExtrema)
- || (m_type == FEMORPHOLOGY_OPERATOR_DILATE && pixel >= columnExtrema))
- columnExtrema = pixel;
- }
- if (x - radiusX >= 0)
- extrema.remove(0);
- if (x + radiusX <= width)
- extrema.append(columnExtrema);
-
- unsigned char entireExtrema = extrema[0];
- for (unsigned kernelIndex = 1; kernelIndex < extrema.size(); ++kernelIndex) {
- if ((m_type == FEMORPHOLOGY_OPERATOR_ERODE && extrema[kernelIndex] <= entireExtrema)
- || (m_type == FEMORPHOLOGY_OPERATOR_DILATE && extrema[kernelIndex] >= entireExtrema))
- entireExtrema = extrema[kernelIndex];
- }
- dstPixelArray->set(y * effectWidth + 4 * x + clrChannel, entireExtrema);
- }
- }
- }
-}
-
-void FEMorphology::platformApplyWorker(PlatformApplyParameters* param)
-{
- param->filter->platformApplyGeneric(param->paintingData, param->startY, param->endY);
-}
-
-void FEMorphology::platformApply(PaintingData* paintingData)
-{
- int optimalThreadNumber = (paintingData->width * paintingData->height) / s_minimalArea;
- if (optimalThreadNumber > 1) {
- ParallelJobs<PlatformApplyParameters> parallelJobs(&WebCore::FEMorphology::platformApplyWorker, optimalThreadNumber);
- int numOfThreads = parallelJobs.numberOfJobs();
- if (numOfThreads > 1) {
- // Split the job into "jobSize"-sized jobs but there a few jobs that need to be slightly larger since
- // jobSize * jobs < total size. These extras are handled by the remainder "jobsWithExtra".
- const int jobSize = paintingData->height / numOfThreads;
- const int jobsWithExtra = paintingData->height % numOfThreads;
- int currentY = 0;
- for (int job = numOfThreads - 1; job >= 0; --job) {
- PlatformApplyParameters& param = parallelJobs.parameter(job);
- param.filter = this;
- param.startY = currentY;
- currentY += job < jobsWithExtra ? jobSize + 1 : jobSize;
- param.endY = currentY;
- param.paintingData = paintingData;
- }
- parallelJobs.execute();
- return;
- }
- // Fallback to single thread model
- }
-
- platformApplyGeneric(paintingData, 0, paintingData->height);
-}
-
-
void FEMorphology::applySoftware()
{
- FilterEffect* in = inputEffect(0);
-
- Uint8ClampedArray* dstPixelArray = createPremultipliedImageResult();
- if (!dstPixelArray)
- return;
-
- setIsAlphaImage(in->isAlphaImage());
- if (m_radiusX <= 0 || m_radiusY <= 0) {
- dstPixelArray->zeroFill();
- return;
- }
-
- Filter* filter = this->filter();
- int radiusX = static_cast<int>(floorf(filter->applyHorizontalScale(m_radiusX)));
- int radiusY = static_cast<int>(floorf(filter->applyVerticalScale(m_radiusY)));
-
- IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
- RefPtr<Uint8ClampedArray> srcPixelArray = in->asPremultipliedImage(effectDrawingRect);
-
- PaintingData paintingData;
- paintingData.srcPixelArray = srcPixelArray.get();
- paintingData.dstPixelArray = dstPixelArray;
- paintingData.width = effectDrawingRect.width();
- paintingData.height = effectDrawingRect.height();
- paintingData.radiusX = min(effectDrawingRect.width() - 1, radiusX);
- paintingData.radiusY = min(effectDrawingRect.height() - 1, radiusY);
-
- platformApply(&paintingData);
-}
-
-bool FEMorphology::applySkia()
-{
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
- return false;
+ return;
FilterEffect* in = inputEffect(0);
@@ -250,14 +118,14 @@ bool FEMorphology::applySkia()
SkPaint paint;
GraphicsContext* dstContext = resultImage->context();
if (m_type == FEMORPHOLOGY_OPERATOR_DILATE)
- paint.setImageFilter(new SkDilateImageFilter(radiusX, radiusY))->unref();
+ paint.setImageFilter(SkDilateImageFilter::Create(radiusX, radiusY))->unref();
else if (m_type == FEMORPHOLOGY_OPERATOR_ERODE)
- paint.setImageFilter(new SkErodeImageFilter(radiusX, radiusY))->unref();
+ paint.setImageFilter(SkErodeImageFilter::Create(radiusX, radiusY))->unref();
- dstContext->saveLayer(0, &paint);
+ SkRect bounds = SkRect::MakeWH(absolutePaintRect().width(), absolutePaintRect().height());
+ dstContext->saveLayer(&bounds, &paint);
dstContext->drawImage(image.get(), drawingRegion.location(), CompositeCopy);
dstContext->restoreLayer();
- return true;
}
PassRefPtr<SkImageFilter> FEMorphology::createImageFilter(SkiaImageFilterBuilder* builder)
@@ -267,8 +135,8 @@ PassRefPtr<SkImageFilter> FEMorphology::createImageFilter(SkiaImageFilterBuilder
SkScalar radiusY = SkFloatToScalar(filter()->applyVerticalScale(m_radiusY));
SkImageFilter::CropRect rect = getCropRect(builder->cropOffset());
if (m_type == FEMORPHOLOGY_OPERATOR_DILATE)
- return adoptRef(new SkDilateImageFilter(radiusX, radiusY, input.get(), &rect));
- return adoptRef(new SkErodeImageFilter(radiusX, radiusY, input.get(), &rect));
+ return adoptRef(SkDilateImageFilter::Create(radiusX, radiusY, input.get(), &rect));
+ return adoptRef(SkErodeImageFilter::Create(radiusX, radiusY, input.get(), &rect));
}
static TextStream& operator<<(TextStream& ts, const MorphologyOperatorType& type)
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEMorphology.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEMorphology.h
index 6b596bf6ea5..6ed926a3341 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEMorphology.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEMorphology.h
@@ -48,10 +48,9 @@ public:
virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE;
- virtual void determineAbsolutePaintRect();
virtual FloatRect mapRect(const FloatRect&, bool forward = true) OVERRIDE FINAL;
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
struct PaintingData {
Uint8ClampedArray* srcPixelArray;
@@ -71,15 +70,10 @@ public:
PaintingData* paintingData;
};
- static void platformApplyWorker(PlatformApplyParameters*);
-
- inline void platformApply(PaintingData*);
- inline void platformApplyGeneric(PaintingData*, const int yStart, const int yEnd);
private:
FEMorphology(Filter*, MorphologyOperatorType, float radiusX, float radiusY);
virtual void applySoftware() OVERRIDE;
- virtual bool applySkia() OVERRIDE;
MorphologyOperatorType m_type;
float m_radiusX;
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEOffset.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEOffset.cpp
index d9a27788890..a978882eae4 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEOffset.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEOffset.cpp
@@ -66,25 +66,13 @@ void FEOffset::setDy(float dy)
m_dy = dy;
}
-void FEOffset::determineAbsolutePaintRect()
-{
- FloatRect paintRect = inputEffect(0)->absolutePaintRect();
- Filter* filter = this->filter();
- paintRect.move(filter->applyHorizontalScale(m_dx), filter->applyVerticalScale(m_dy));
- if (clipsToBounds())
- paintRect.intersect(maxEffectRect());
- else
- paintRect.unite(maxEffectRect());
- setAbsolutePaintRect(enclosingIntRect(paintRect));
-}
-
FloatRect FEOffset::mapRect(const FloatRect& rect, bool forward)
{
FloatRect result = rect;
if (forward)
- result.move(filter()->applyHorizontalScale(m_dx), filter()->applyHorizontalScale(m_dy));
+ result.move(filter()->applyHorizontalScale(m_dx), filter()->applyVerticalScale(m_dy));
else
- result.move(-filter()->applyHorizontalScale(m_dx), -filter()->applyHorizontalScale(m_dy));
+ result.move(-filter()->applyHorizontalScale(m_dx), -filter()->applyVerticalScale(m_dy));
return result;
}
@@ -109,7 +97,7 @@ PassRefPtr<SkImageFilter> FEOffset::createImageFilter(SkiaImageFilterBuilder* bu
RefPtr<SkImageFilter> input(builder->build(inputEffect(0), operatingColorSpace()));
Filter* filter = this->filter();
SkImageFilter::CropRect cropRect = getCropRect(builder->cropOffset());
- return adoptRef(new SkOffsetImageFilter(SkFloatToScalar(filter->applyHorizontalScale(m_dx)), SkFloatToScalar(filter->applyVerticalScale(m_dy)), input.get(), &cropRect));
+ return adoptRef(SkOffsetImageFilter::Create(SkFloatToScalar(filter->applyHorizontalScale(m_dx)), SkFloatToScalar(filter->applyVerticalScale(m_dy)), input.get(), &cropRect));
}
TextStream& FEOffset::externalRepresentation(TextStream& ts, int indent) const
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEOffset.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEOffset.h
index 6ed388d8cb8..774497c6f53 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FEOffset.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FEOffset.h
@@ -38,10 +38,9 @@ public:
float dy() const;
void setDy(float);
- virtual void determineAbsolutePaintRect();
virtual FloatRect mapRect(const FloatRect&, bool forward = true) OVERRIDE FINAL;
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE;
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FESpecularLighting.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FESpecularLighting.cpp
index 5a87f10d0d8..cc3ed427d44 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FESpecularLighting.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FESpecularLighting.cpp
@@ -80,6 +80,7 @@ float FESpecularLighting::specularConstant() const
bool FESpecularLighting::setSpecularConstant(float specularConstant)
{
+ specularConstant = std::max(specularConstant, 0.0f);
if (m_specularConstant == specularConstant)
return false;
m_specularConstant = specularConstant;
@@ -93,6 +94,7 @@ float FESpecularLighting::specularExponent() const
bool FESpecularLighting::setSpecularExponent(float specularExponent)
{
+ specularExponent = std::min(std::max(specularExponent, 1.0f), 128.0f);
if (m_specularExponent == specularExponent)
return false;
m_specularExponent = specularExponent;
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FESpecularLighting.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FESpecularLighting.h
index fd33b0c086b..fd314ab8432 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FESpecularLighting.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FESpecularLighting.h
@@ -54,7 +54,7 @@ public:
const LightSource* lightSource() const;
void setLightSource(PassRefPtr<LightSource>);
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
private:
FESpecularLighting(Filter*, const Color&, float, float, float, float, float, PassRefPtr<LightSource>);
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FETile.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FETile.cpp
index 2e865d3141f..bcbe9fb7d80 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FETile.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FETile.cpp
@@ -29,7 +29,6 @@
#include "platform/graphics/Pattern.h"
#include "platform/graphics/UnacceleratedImageBufferSurface.h"
#include "platform/graphics/filters/SkiaImageFilterBuilder.h"
-#include "platform/graphics/gpu/AcceleratedImageBufferSurface.h"
#include "platform/text/TextStream.h"
#include "platform/transforms/AffineTransform.h"
#include "third_party/skia/include/core/SkDevice.h"
@@ -46,6 +45,11 @@ PassRefPtr<FETile> FETile::create(Filter* filter)
return adoptRef(new FETile(filter));
}
+FloatRect FETile::mapPaintRect(const FloatRect& rect, bool forward)
+{
+ return forward ? maxEffectRect() : inputEffect(0)->maxEffectRect();
+}
+
void FETile::applySoftware()
{
FilterEffect* in = inputEffect(0);
@@ -64,25 +68,21 @@ void FETile::applySoftware()
if (in->filterEffectType() == FilterEffectTypeSourceInput) {
Filter* filter = this->filter();
tileRect = filter->absoluteFilterRegion();
- tileRect.scale(filter->filterResolution().width(), filter->filterResolution().height());
}
OwnPtr<ImageBufferSurface> surface;
IntSize intTileSize = roundedIntSize(tileRect.size());
- if (filter()->isAccelerated()) {
- surface = adoptPtr(new AcceleratedImageBufferSurface(intTileSize));
- }
- if (!surface || !surface->isValid()) {
- surface = adoptPtr(new UnacceleratedImageBufferSurface(intTileSize));
- }
+ surface = adoptPtr(new UnacceleratedImageBufferSurface(intTileSize));
OwnPtr<ImageBuffer> tileImage = ImageBuffer::create(surface.release());
if (!tileImage)
return;
GraphicsContext* tileImageContext = tileImage->context();
- tileImageContext->scale(FloatSize(intTileSize.width() / tileRect.width(), intTileSize.height() / tileRect.height()));
+ tileImageContext->scale(intTileSize.width() / tileRect.width(), intTileSize.height() / tileRect.height());
tileImageContext->translate(-inMaxEffectLocation.x(), -inMaxEffectLocation.y());
- tileImageContext->drawImageBuffer(in->asImageBuffer(), in->absolutePaintRect().location());
+
+ if (ImageBuffer* tileImageBuffer = in->asImageBuffer())
+ tileImageContext->drawImageBuffer(tileImageBuffer, IntRect(in->absolutePaintRect().location(), tileImageBuffer->size()));
RefPtr<Pattern> pattern = Pattern::create(tileImage->copyImage(CopyBackingStore), true, true);
@@ -94,11 +94,27 @@ void FETile::applySoftware()
filterContext->fillRect(FloatRect(FloatPoint(), absolutePaintRect().size()));
}
+static FloatRect getRect(FilterEffect* effect)
+{
+ FloatRect result = effect->filter()->filterRegion();
+ FloatRect boundaries = effect->effectBoundaries();
+ if (effect->hasX())
+ result.setX(boundaries.x());
+ if (effect->hasY())
+ result.setY(boundaries.y());
+ if (effect->hasWidth())
+ result.setWidth(boundaries.width());
+ if (effect->hasHeight())
+ result.setHeight(boundaries.height());
+ return result;
+}
+
PassRefPtr<SkImageFilter> FETile::createImageFilter(SkiaImageFilterBuilder* builder)
{
RefPtr<SkImageFilter> input(builder->build(inputEffect(0), operatingColorSpace()));
- FloatRect srcRect = inputEffect(0) ? inputEffect(0)->effectBoundaries() : FloatRect();
- return adoptRef(new SkTileImageFilter(srcRect, effectBoundaries(), input.get()));
+ FloatRect srcRect = inputEffect(0) ? getRect(inputEffect(0)) : filter()->filterRegion();
+ FloatRect dstRect = getRect(this);
+ return adoptRef(SkTileImageFilter::Create(srcRect, dstRect, input.get()));
}
TextStream& FETile::externalRepresentation(TextStream& ts, int indent) const
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FETile.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FETile.h
index ece013c816d..5d882338ca7 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FETile.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FETile.h
@@ -34,11 +34,11 @@ public:
virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE;
- virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
+ virtual FloatRect mapPaintRect(const FloatRect&, bool forward = true) OVERRIDE FINAL;
- virtual FilterEffectType filterEffectType() const { return FilterEffectTypeTile; }
+ virtual FilterEffectType filterEffectType() const OVERRIDE { return FilterEffectTypeTile; }
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
private:
FETile(Filter*);
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FETurbulence.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FETurbulence.cpp
index a6a4e826182..cb123da3e2b 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FETurbulence.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FETurbulence.cpp
@@ -364,8 +364,6 @@ void FETurbulence::applySoftware()
PaintingData paintingData(m_seed, roundedIntSize(filterPrimitiveSubregion().size()));
initPaint(paintingData);
- float baseFrequencyX = 1.0f / filter()->applyHorizontalScale(1.0f / m_baseFrequencyX);
- float baseFrequencyY = 1.0f / filter()->applyVerticalScale(1.0f / m_baseFrequencyY);
int optimalThreadNumber = (absolutePaintRect().width() * absolutePaintRect().height()) / s_minimalRectDimension;
if (optimalThreadNumber > 1) {
@@ -389,8 +387,8 @@ void FETurbulence::applySoftware()
params.startY = startY;
startY += i < jobsWithExtra ? stepY + 1 : stepY;
params.endY = startY;
- params.baseFrequencyX = baseFrequencyX;
- params.baseFrequencyY = baseFrequencyY;
+ params.baseFrequencyX = m_baseFrequencyX;
+ params.baseFrequencyY = m_baseFrequencyY;
}
// Execute parallel jobs
@@ -400,44 +398,32 @@ void FETurbulence::applySoftware()
}
// Fallback to single threaded mode if there is no room for a new thread or the paint area is too small.
- fillRegion(pixelArray, paintingData, 0, absolutePaintRect().height(), baseFrequencyX, baseFrequencyY);
+ fillRegion(pixelArray, paintingData, 0, absolutePaintRect().height(), m_baseFrequencyX, m_baseFrequencyY);
}
-SkShader* FETurbulence::createShader(const IntRect& filterRegion)
+SkShader* FETurbulence::createShader()
{
- const SkISize size = SkISize::Make(filterRegion.width(), filterRegion.height());
- float baseFrequencyX = 1.0f / filter()->applyHorizontalScale(1.0f / m_baseFrequencyX);
- const float baseFrequencyY = 1.0f / filter()->applyVerticalScale(1.0f / m_baseFrequencyY);
+ const SkISize size = SkISize::Make(effectBoundaries().width(), effectBoundaries().height());
+ // Frequency should be scaled by page zoom, but not by primitiveUnits.
+ // So we apply only the transform scale (as Filter::apply*Scale() do)
+ // and not the target bounding box scale (as SVGFilter::apply*Scale()
+ // would do). Note also that we divide by the scale since this is
+ // a frequency, not a period.
+ const AffineTransform& absoluteTransform = filter()->absoluteTransform();
+ float baseFrequencyX = m_baseFrequencyX / absoluteTransform.a();
+ float baseFrequencyY = m_baseFrequencyY / absoluteTransform.d();
return (type() == FETURBULENCE_TYPE_FRACTALNOISE) ?
SkPerlinNoiseShader::CreateFractalNoise(SkFloatToScalar(baseFrequencyX),
SkFloatToScalar(baseFrequencyY), numOctaves(), SkFloatToScalar(seed()),
stitchTiles() ? &size : 0) :
- SkPerlinNoiseShader::CreateTubulence(SkFloatToScalar(baseFrequencyX),
+ SkPerlinNoiseShader::CreateTurbulence(SkFloatToScalar(baseFrequencyX),
SkFloatToScalar(baseFrequencyY), numOctaves(), SkFloatToScalar(seed()),
stitchTiles() ? &size : 0);
}
-bool FETurbulence::applySkia()
-{
- // For now, only use the skia implementation for accelerated rendering.
- if (!filter()->isAccelerated())
- return false;
-
- ImageBuffer* resultImage = createImageBufferResult();
- if (!resultImage)
- return false;
-
- const IntRect filterRegion(IntPoint::zero(), absolutePaintRect().size());
-
- SkPaint paint;
- paint.setShader(createShader(filterRegion))->unref();
- resultImage->context()->drawRect((SkRect)filterRegion, paint);
- return true;
-}
-
PassRefPtr<SkImageFilter> FETurbulence::createImageFilter(SkiaImageFilterBuilder* builder)
{
- SkAutoTUnref<SkShader> shader(createShader(IntRect()));
+ SkAutoTUnref<SkShader> shader(createShader());
SkImageFilter::CropRect rect = getCropRect(builder->cropOffset());
return adoptRef(SkRectShaderImageFilter::Create(shader, &rect));
}
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FETurbulence.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FETurbulence.h
index 6b249e454c9..f5c230b26a7 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FETurbulence.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FETurbulence.h
@@ -60,9 +60,7 @@ public:
static void fillRegionWorker(void*);
- virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
-
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
private:
static const int s_blockSize = 256;
@@ -118,9 +116,8 @@ private:
FETurbulence(Filter*, TurbulenceType, float, float, int, float, bool);
virtual void applySoftware() OVERRIDE;
- virtual bool applySkia() OVERRIDE;
virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE;
- SkShader* createShader(const IntRect& filterRegion);
+ SkShader* createShader();
inline void initPaint(PaintingData&);
float noise2D(int channel, PaintingData&, StitchData&, const FloatPoint&);
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/Filter.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/Filter.h
index 705aa5e19e4..d16659a0aff 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/Filter.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/Filter.h
@@ -25,6 +25,7 @@
#include "platform/geometry/FloatRect.h"
#include "platform/geometry/FloatSize.h"
#include "platform/graphics/ImageBuffer.h"
+#include "third_party/skia/include/core/SkImageFilter.h"
#include "wtf/RefCounted.h"
namespace WebCore {
@@ -33,50 +34,85 @@ class FilterEffect;
class PLATFORM_EXPORT Filter : public RefCounted<Filter> {
public:
- Filter(const AffineTransform& absoluteTransform) : m_isAccelerated(false), m_absoluteTransform(absoluteTransform) { }
+ Filter(const AffineTransform& absoluteTransform)
+ : m_absoluteTransform(absoluteTransform)
+ , m_inverseTransform(absoluteTransform.inverse())
+ {
+ // Filters can only accept scaling and translating transformations, as coordinates
+ // in most primitives are given in horizontal and vertical directions.
+ ASSERT(!absoluteTransform.b() && !absoluteTransform.c());
+ }
virtual ~Filter() { }
void setSourceImage(PassOwnPtr<ImageBuffer> sourceImage) { m_sourceImage = sourceImage; }
ImageBuffer* sourceImage() { return m_sourceImage.get(); }
- FloatSize filterResolution() const { return m_filterResolution; }
- void setFilterResolution(const FloatSize& filterResolution) { m_filterResolution = filterResolution; }
-
const AffineTransform& absoluteTransform() const { return m_absoluteTransform; }
- void setAbsoluteTransform(const AffineTransform& absoluteTransform) { m_absoluteTransform = absoluteTransform; }
- FloatPoint mapAbsolutePointToLocalPoint(const FloatPoint& point) const { return m_absoluteTransform.inverse().mapPoint(point); }
- bool isAccelerated() const { return m_isAccelerated; }
- void setIsAccelerated(bool isAccelerated) { m_isAccelerated = isAccelerated; }
+ void setAbsoluteTransform(const AffineTransform& absoluteTransform)
+ {
+ // Filters can only accept scaling and translating transformations, as coordinates
+ // in most primitives are given in horizontal and vertical directions.
+ ASSERT(!absoluteTransform.b() && !absoluteTransform.c());
+ m_absoluteTransform = absoluteTransform;
+ m_inverseTransform = absoluteTransform.inverse();
+ m_absoluteFilterRegion = m_absoluteTransform.mapRect(m_filterRegion);
+ }
+ FloatPoint mapAbsolutePointToLocalPoint(const FloatPoint& point) const { return m_inverseTransform.mapPoint(point); }
+ FloatRect mapLocalRectToAbsoluteRect(const FloatRect& rect) const { return m_absoluteTransform.mapRect(rect); }
+ FloatRect mapAbsoluteRectToLocalRect(const FloatRect& rect) const { return m_inverseTransform.mapRect(rect); }
virtual float applyHorizontalScale(float value) const
{
- float filterRegionScale = absoluteFilterRegion().isEmpty() || filterRegion().isEmpty() ?
- 1.0f : absoluteFilterRegion().width() / filterRegion().width();
- return value * m_filterResolution.width() * filterRegionScale;
+ return value * m_absoluteTransform.a();
}
virtual float applyVerticalScale(float value) const
{
- float filterRegionScale = absoluteFilterRegion().isEmpty() || filterRegion().isEmpty() ?
- 1.0f : absoluteFilterRegion().height() / filterRegion().height();
- return value * m_filterResolution.height() * filterRegionScale;
+ return value * m_absoluteTransform.d();
}
+ virtual FloatPoint3D resolve3dPoint(const FloatPoint3D& point) const { return point; }
- virtual FloatRect sourceImageRect() const = 0;
+ virtual IntRect sourceImageRect() const = 0;
FloatRect absoluteFilterRegion() const { return m_absoluteFilterRegion; }
- void setAbsoluteFilterRegion(const FloatRect& rect) { m_absoluteFilterRegion = rect; }
FloatRect filterRegion() const { return m_filterRegion; }
- void setFilterRegion(const FloatRect& rect) { m_filterRegion = rect; }
+ void setFilterRegion(const FloatRect& rect)
+ {
+ m_filterRegion = rect;
+ m_absoluteFilterRegion = m_absoluteTransform.mapRect(m_filterRegion);
+ }
+
+ // The methods enableCache() and disableCache() are temporary, and we
+ // should address the real issue inside skia, thus simplifying what the
+ // clients have to know, and can remove these.
+ // Also note that this cache should no longer be used by Blink once the
+ // NON impl-side painting path is removed.
+ void enableCache()
+ {
+ if (!m_cache)
+ m_cache = adoptRef(SkImageFilter::Cache::Create(1));
+ SkImageFilter::SetExternalCache(m_cache.get());
+ }
+
+ void disableCache()
+ {
+ SkImageFilter::SetExternalCache(0);
+ }
+
+ void removeFromCache(SkImageFilter* filter)
+ {
+ if (m_cache)
+ m_cache->remove(filter);
+ }
private:
OwnPtr<ImageBuffer> m_sourceImage;
- FloatSize m_filterResolution;
- bool m_isAccelerated;
AffineTransform m_absoluteTransform;
+ AffineTransform m_inverseTransform;
FloatRect m_absoluteFilterRegion;
FloatRect m_filterRegion;
+ RefPtr<SkImageFilter::Cache> m_cache;
};
} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp
index 2b1324298ac..518173bebe3 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp
@@ -28,7 +28,6 @@
#include "platform/graphics/ImageBuffer.h"
#include "platform/graphics/UnacceleratedImageBufferSurface.h"
#include "platform/graphics/filters/Filter.h"
-#include "platform/graphics/gpu/AcceleratedImageBufferSurface.h"
#if HAVE(ARM_NEON_INTRINSICS)
#include <arm_neon.h>
@@ -36,6 +35,8 @@
namespace WebCore {
+static const float kMaxFilterArea = 4096 * 4096;
+
FilterEffect::FilterEffect(Filter* filter)
: m_alphaImage(false)
, m_filter(filter)
@@ -54,27 +55,49 @@ FilterEffect::~FilterEffect()
{
}
-inline bool isFilterSizeValid(IntRect rect)
+float FilterEffect::maxFilterArea()
+{
+ return kMaxFilterArea;
+}
+
+bool FilterEffect::isFilterSizeValid(const FloatRect& rect)
{
- if (rect.width() < 0 || rect.width() > kMaxFilterSize
- || rect.height() < 0 || rect.height() > kMaxFilterSize)
+ if (rect.width() < 0 || rect.height() < 0
+ || (rect.height() * rect.width() > kMaxFilterArea))
return false;
+
return true;
}
-void FilterEffect::determineAbsolutePaintRect()
+FloatRect FilterEffect::determineAbsolutePaintRect(const FloatRect& originalRequestedRect)
{
- m_absolutePaintRect = IntRect();
+ FloatRect requestedRect = originalRequestedRect;
+ // Filters in SVG clip to primitive subregion, while CSS doesn't.
+ if (m_clipsToBounds)
+ requestedRect.intersect(maxEffectRect());
+
+ // We may be called multiple times if result is used more than once. Return
+ // quickly if if nothing new is required.
+ if (absolutePaintRect().contains(enclosingIntRect(requestedRect)))
+ return requestedRect;
+
+ FloatRect inputRect = mapPaintRect(requestedRect, false);
+ FloatRect inputUnion;
unsigned size = m_inputEffects.size();
+
for (unsigned i = 0; i < size; ++i)
- m_absolutePaintRect.unite(m_inputEffects.at(i)->absolutePaintRect());
+ inputUnion.unite(m_inputEffects.at(i)->determineAbsolutePaintRect(inputRect));
+ inputUnion = mapPaintRect(inputUnion, true);
- // Filters in SVG clip to primitive subregion, while CSS doesn't.
- if (m_clipsToBounds)
- m_absolutePaintRect.intersect(enclosingIntRect(m_maxEffectRect));
- else
- m_absolutePaintRect.unite(enclosingIntRect(m_maxEffectRect));
+ if (affectsTransparentPixels() || !size) {
+ inputUnion = requestedRect;
+ } else {
+ // Rect may have inflated. Re-intersect with request.
+ inputUnion.intersect(requestedRect);
+ }
+ addAbsolutePaintRect(inputUnion);
+ return inputUnion;
}
FloatRect FilterEffect::mapRectRecursive(const FloatRect& rect)
@@ -94,7 +117,7 @@ FloatRect FilterEffect::getSourceRect(const FloatRect& destRect, const FloatRect
FloatRect sourceRect = mapRect(destRect, false);
FloatRect sourceClipRect = mapRect(destClipRect, false);
- FloatRect boundaries = effectBoundaries();
+ FloatRect boundaries = filter()->mapLocalRectToAbsoluteRect(effectBoundaries());
if (hasX())
sourceClipRect.setX(boundaries.x());
if (hasY())
@@ -136,14 +159,33 @@ FilterEffect* FilterEffect::inputEffect(unsigned number) const
return m_inputEffects.at(number).get();
}
+void FilterEffect::addAbsolutePaintRect(const FloatRect& paintRect)
+{
+ IntRect intPaintRect(enclosingIntRect(paintRect));
+ if (m_absolutePaintRect.contains(intPaintRect))
+ return;
+ intPaintRect.unite(m_absolutePaintRect);
+ // Make sure we are not holding on to a smaller rendering.
+ clearResult();
+ m_absolutePaintRect = intPaintRect;
+}
+
void FilterEffect::apply()
{
+ // Recursively determine paint rects first, so that we don't redraw images
+ // if a smaller section is requested first.
+ determineAbsolutePaintRect(maxEffectRect());
+ applyRecursive();
+}
+
+void FilterEffect::applyRecursive()
+{
if (hasResult())
return;
unsigned size = m_inputEffects.size();
for (unsigned i = 0; i < size; ++i) {
FilterEffect* in = m_inputEffects.at(i).get();
- in->apply();
+ in->applyRecursive();
if (!in->hasResult())
return;
@@ -151,20 +193,16 @@ void FilterEffect::apply()
transformResultColorSpace(in, i);
}
- determineAbsolutePaintRect();
setResultColorSpace(m_operatingColorSpace);
if (!isFilterSizeValid(m_absolutePaintRect))
return;
- if (requiresValidPreMultipliedPixels()) {
+ if (!mayProduceInvalidPreMultipliedPixels()) {
for (unsigned i = 0; i < size; ++i)
inputEffect(i)->correctFilterResultIfNeeded();
}
- if (applySkia())
- return;
-
applySoftware();
}
@@ -225,6 +263,12 @@ void FilterEffect::clearResult()
m_unmultipliedImageResult.clear();
if (m_premultipliedImageResult)
m_premultipliedImageResult.clear();
+
+ m_absolutePaintRect = IntRect();
+ for (int i = 0; i < 4; i++) {
+ filter()->removeFromCache(m_imageFilters[i].get());
+ m_imageFilters[i] = nullptr;
+ }
}
void FilterEffect::clearResultsRecursive()
@@ -246,10 +290,7 @@ ImageBuffer* FilterEffect::asImageBuffer()
if (m_imageBufferResult)
return m_imageBufferResult.get();
OwnPtr<ImageBufferSurface> surface;
- if (m_filter->isAccelerated())
- surface = adoptPtr(new AcceleratedImageBufferSurface(m_absolutePaintRect.size()));
- if (!m_filter->isAccelerated() || !surface->isValid())
- surface = adoptPtr(new UnacceleratedImageBufferSurface(m_absolutePaintRect.size()));
+ surface = adoptPtr(new UnacceleratedImageBufferSurface(m_absolutePaintRect.size()));
m_imageBufferResult = ImageBuffer::create(surface.release());
if (!m_imageBufferResult)
return 0;
@@ -387,13 +428,11 @@ void FilterEffect::copyPremultipliedImage(Uint8ClampedArray* destination, const
ImageBuffer* FilterEffect::createImageBufferResult()
{
// Only one result type is allowed.
- if (m_absolutePaintRect.isEmpty())
- return 0;
+ ASSERT(!hasResult());
+ ASSERT(isFilterSizeValid(m_absolutePaintRect));
+
OwnPtr<ImageBufferSurface> surface;
- if (m_filter->isAccelerated())
- surface = adoptPtr(new AcceleratedImageBufferSurface(m_absolutePaintRect.size()));
- if (!m_filter->isAccelerated() || !surface->isValid())
- surface = adoptPtr(new UnacceleratedImageBufferSurface(m_absolutePaintRect.size()));
+ surface = adoptPtr(new UnacceleratedImageBufferSurface(m_absolutePaintRect.size()));
m_imageBufferResult = ImageBuffer::create(surface.release());
return m_imageBufferResult.get();
}
@@ -422,6 +461,12 @@ Uint8ClampedArray* FilterEffect::createPremultipliedImageResult()
return m_premultipliedImageResult.get();
}
+Color FilterEffect::adaptColorToOperatingColorSpace(const Color& deviceColor)
+{
+ // |deviceColor| is assumed to be DeviceRGB.
+ return ColorSpaceUtilities::convertColor(deviceColor, operatingColorSpace());
+}
+
void FilterEffect::transformResultColorSpace(ColorSpace dstColorSpace)
{
if (!hasResult() || dstColorSpace == m_resultColorSpace)
@@ -448,7 +493,8 @@ TextStream& FilterEffect::externalRepresentation(TextStream& ts, int) const
FloatRect FilterEffect::determineFilterPrimitiveSubregion(DetermineSubregionFlags flags)
{
- ASSERT(filter());
+ Filter* filter = this->filter();
+ ASSERT(filter);
// FETile, FETurbulence, FEFlood don't have input effects, take the filter region as unite rect.
FloatRect subregion;
@@ -456,15 +502,19 @@ FloatRect FilterEffect::determineFilterPrimitiveSubregion(DetermineSubregionFlag
subregion = inputEffect(0)->determineFilterPrimitiveSubregion(flags);
for (unsigned i = 1; i < numberOfInputEffects; ++i)
subregion.unite(inputEffect(i)->determineFilterPrimitiveSubregion(flags));
- } else
- subregion = filter()->filterRegion();
+ } else {
+ subregion = filter->filterRegion();
+ }
// After calling determineFilterPrimitiveSubregion on the target effect, reset the subregion again for <feTile>.
if (filterEffectType() == FilterEffectTypeTile)
- subregion = filter()->filterRegion();
+ subregion = filter->filterRegion();
- if (flags & MapRectForward)
- subregion = mapRect(subregion);
+ if (flags & MapRectForward) {
+ // mapRect works on absolute rectangles.
+ subregion = filter->mapAbsoluteRectToLocalRect(mapRect(
+ filter->mapLocalRectToAbsoluteRect(subregion)));
+ }
FloatRect boundaries = effectBoundaries();
if (hasX())
@@ -478,15 +528,11 @@ FloatRect FilterEffect::determineFilterPrimitiveSubregion(DetermineSubregionFlag
setFilterPrimitiveSubregion(subregion);
- FloatRect absoluteSubregion = filter()->absoluteTransform().mapRect(subregion);
- FloatSize filterResolution = filter()->filterResolution();
- absoluteSubregion.scale(filterResolution.width(), filterResolution.height());
+ FloatRect absoluteSubregion = filter->mapLocalRectToAbsoluteRect(subregion);
// Clip every filter effect to the filter region.
if (flags & ClipToFilterRegion) {
- FloatRect absoluteScaledFilterRegion = filter()->absoluteFilterRegion();
- absoluteScaledFilterRegion.scale(filterResolution.width(), filterResolution.height());
- absoluteSubregion.intersect(absoluteScaledFilterRegion);
+ absoluteSubregion.intersect(filter->absoluteFilterRegion());
}
setMaxEffectRect(absoluteSubregion);
@@ -495,34 +541,63 @@ FloatRect FilterEffect::determineFilterPrimitiveSubregion(DetermineSubregionFlag
PassRefPtr<SkImageFilter> FilterEffect::createImageFilter(SkiaImageFilterBuilder* builder)
{
- return 0;
+ return nullptr;
+}
+
+PassRefPtr<SkImageFilter> FilterEffect::createImageFilterWithoutValidation(SkiaImageFilterBuilder* builder)
+{
+ return createImageFilter(builder);
}
SkImageFilter::CropRect FilterEffect::getCropRect(const FloatSize& cropOffset) const
{
- SkRect rect = SkRect::MakeEmpty();
+ FloatRect rect = filter()->filterRegion();
uint32_t flags = 0;
FloatRect boundaries = effectBoundaries();
- FloatSize resolution = filter()->filterResolution();
- boundaries.scale(resolution.width(), resolution.height());
boundaries.move(cropOffset);
if (hasX()) {
- rect.fLeft = boundaries.x();
+ rect.setX(boundaries.x());
flags |= SkImageFilter::CropRect::kHasLeft_CropEdge;
+ flags |= SkImageFilter::CropRect::kHasRight_CropEdge;
}
if (hasY()) {
- rect.fTop = boundaries.y();
+ rect.setY(boundaries.y());
flags |= SkImageFilter::CropRect::kHasTop_CropEdge;
+ flags |= SkImageFilter::CropRect::kHasBottom_CropEdge;
}
if (hasWidth()) {
- rect.fRight = rect.fLeft + boundaries.width();
+ rect.setWidth(boundaries.width());
flags |= SkImageFilter::CropRect::kHasRight_CropEdge;
}
if (hasHeight()) {
- rect.fBottom = rect.fTop + boundaries.height();
+ rect.setHeight(boundaries.height());
flags |= SkImageFilter::CropRect::kHasBottom_CropEdge;
}
+ rect = filter()->mapLocalRectToAbsoluteRect(rect);
return SkImageFilter::CropRect(rect, flags);
}
+static int getImageFilterIndex(ColorSpace colorSpace, bool requiresPMColorValidation)
+{
+ // Map the (colorspace, bool) tuple to an integer index as follows:
+ // 0 == linear colorspace, no PM validation
+ // 1 == device colorspace, no PM validation
+ // 2 == linear colorspace, PM validation
+ // 3 == device colorspace, PM validation
+ return (colorSpace == ColorSpaceLinearRGB ? 0x1 : 0x0) | (requiresPMColorValidation ? 0x2 : 0x0);
+}
+
+SkImageFilter* FilterEffect::getImageFilter(ColorSpace colorSpace, bool requiresPMColorValidation) const
+{
+ int index = getImageFilterIndex(colorSpace, requiresPMColorValidation);
+ return m_imageFilters[index].get();
+}
+
+void FilterEffect::setImageFilter(ColorSpace colorSpace, bool requiresPMColorValidation, PassRefPtr<SkImageFilter> imageFilter)
+{
+ int index = getImageFilterIndex(colorSpace, requiresPMColorValidation);
+ filter()->removeFromCache(m_imageFilters[index].get());
+ m_imageFilters[index] = imageFilter;
+}
+
} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.h
index 3f0d2c4ccf1..7e050fa2427 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.h
@@ -26,6 +26,7 @@
#include "platform/PlatformExport.h"
#include "platform/geometry/FloatRect.h"
#include "platform/geometry/IntRect.h"
+#include "platform/graphics/Color.h"
#include "platform/graphics/ColorSpace.h"
#include "third_party/skia/include/core/SkImageFilter.h"
@@ -36,8 +37,6 @@
#include "wtf/Uint8ClampedArray.h"
#include "wtf/Vector.h"
-static const float kMaxFilterSize = 5000.0f;
-
namespace WebCore {
class Filter;
@@ -68,6 +67,9 @@ class PLATFORM_EXPORT FilterEffect : public RefCounted<FilterEffect> {
public:
virtual ~FilterEffect();
+ static bool isFilterSizeValid(const FloatRect&);
+ static float maxFilterArea();
+
void clearResult();
void clearResultsRecursive();
@@ -88,6 +90,10 @@ public:
|| m_unmultipliedImageResult
|| m_premultipliedImageResult;
}
+ inline bool hasImageFilter() const
+ {
+ return m_imageFilters[0] || m_imageFilters[1] || m_imageFilters[2] || m_imageFilters[3];
+ }
IntRect drawingRegionOfInputImage(const IntRect&) const;
IntRect requestedRegionOfInputImageData(const IntRect&) const;
@@ -97,7 +103,6 @@ public:
void setIsAlphaImage(bool alphaImage) { m_alphaImage = alphaImage; }
IntRect absolutePaintRect() const { return m_absolutePaintRect; }
- void setAbsolutePaintRect(const IntRect& absolutePaintRect) { m_absolutePaintRect = absolutePaintRect; }
FloatRect maxEffectRect() const { return m_maxEffectRect; }
void setMaxEffectRect(const FloatRect& maxEffectRect) { m_maxEffectRect = maxEffectRect; }
@@ -110,8 +115,7 @@ public:
virtual void correctFilterResultIfNeeded() { }
virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*);
-
- virtual void determineAbsolutePaintRect();
+ virtual PassRefPtr<SkImageFilter> createImageFilterWithoutValidation(SkiaImageFilterBuilder*);
// Mapping a rect forwards determines which which destination pixels a
// given source rect would affect. Mapping a rect backwards determines
@@ -120,10 +124,19 @@ public:
// each other. For example, for FEGaussianBlur, they are the same
// transformation.
virtual FloatRect mapRect(const FloatRect& rect, bool forward = true) { return rect; }
+ // A version of the above that is used for calculating paint rects. We can't
+ // use mapRect above for that, because that is also used for calculating effect
+ // regions for CSS filters and has undesirable effects for tile and
+ // displacement map.
+ virtual FloatRect mapPaintRect(const FloatRect& rect, bool forward)
+ {
+ return mapRect(rect, forward);
+ }
FloatRect mapRectRecursive(const FloatRect&);
// This is a recursive version of a backwards mapRect(), which also takes
// into account the filter primitive subregion of each effect.
+ // Note: This works in absolute coordinates!
FloatRect getSourceRect(const FloatRect& destRect, const FloatRect& clipRect);
virtual FilterEffectType filterEffectType() const { return FilterEffectTypeUnknown; }
@@ -165,25 +178,35 @@ public:
void transformResultColorSpace(ColorSpace);
FloatRect determineFilterPrimitiveSubregion(DetermineSubregionFlags = DetermineSubregionNone);
+ void determineAllAbsolutePaintRects();
+
+ virtual FloatRect determineAbsolutePaintRect(const FloatRect& requestedAbsoluteRect);
+ virtual bool affectsTransparentPixels() { return false; }
+
+ // Return false if the filter will only operate correctly on valid RGBA values, with
+ // alpha in [0,255] and each color component in [0, alpha].
+ virtual bool mayProduceInvalidPreMultipliedPixels() { return false; }
+
+ SkImageFilter* getImageFilter(ColorSpace, bool requiresPMColorValidation) const;
+ void setImageFilter(ColorSpace, bool requiresPMColorValidation, PassRefPtr<SkImageFilter>);
protected:
FilterEffect(Filter*);
-
ImageBuffer* createImageBufferResult();
Uint8ClampedArray* createUnmultipliedImageResult();
Uint8ClampedArray* createPremultipliedImageResult();
- // Return true if the filter will only operate correctly on valid RGBA values, with
- // alpha in [0,255] and each color component in [0, alpha].
- virtual bool requiresValidPreMultipliedPixels() { return true; }
+ Color adaptColorToOperatingColorSpace(const Color& deviceColor);
// If a pre-multiplied image, check every pixel for validity and correct if necessary.
void forceValidPreMultipliedPixels();
SkImageFilter::CropRect getCropRect(const FloatSize& cropOffset) const;
+ void addAbsolutePaintRect(const FloatRect& absolutePaintRect);
+
private:
+ void applyRecursive();
virtual void applySoftware() = 0;
- virtual bool applySkia() { return false; }
inline void copyImageBytes(Uint8ClampedArray* source, Uint8ClampedArray* destination, const IntRect&);
@@ -221,6 +244,8 @@ private:
ColorSpace m_operatingColorSpace;
ColorSpace m_resultColorSpace;
+
+ RefPtr<SkImageFilter> m_imageFilters[4];
};
} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperation.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperation.h
index ddc69dd3dde..b0559ddb0fa 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperation.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperation.h
@@ -54,8 +54,6 @@ public:
CONTRAST,
BLUR,
DROP_SHADOW,
- CUSTOM,
- VALIDATED_CUSTOM,
NONE
};
@@ -72,8 +70,6 @@ public:
case CONTRAST:
case BLUR:
case DROP_SHADOW:
- case CUSTOM:
- case VALIDATED_CUSTOM:
return true;
case REFERENCE:
return false;
@@ -115,16 +111,16 @@ private:
class PLATFORM_EXPORT ReferenceFilterOperation : public FilterOperation {
public:
- static PassRefPtr<ReferenceFilterOperation> create(const String& url, const String& fragment)
+ static PassRefPtr<ReferenceFilterOperation> create(const String& url, const AtomicString& fragment)
{
return adoptRef(new ReferenceFilterOperation(url, fragment));
}
- virtual bool affectsOpacity() const { return true; }
- virtual bool movesPixels() const { return true; }
+ virtual bool affectsOpacity() const OVERRIDE { return true; }
+ virtual bool movesPixels() const OVERRIDE { return true; }
const String& url() const { return m_url; }
- const String& fragment() const { return m_fragment; }
+ const AtomicString& fragment() const { return m_fragment; }
ReferenceFilter* filter() const { return m_filter.get(); }
void setFilter(PassRefPtr<ReferenceFilter> filter) { m_filter = filter; }
@@ -133,10 +129,10 @@ private:
virtual PassRefPtr<FilterOperation> blend(const FilterOperation* from, double progress) const OVERRIDE
{
ASSERT_NOT_REACHED();
- return 0;
+ return nullptr;
}
- virtual bool operator==(const FilterOperation& o) const
+ virtual bool operator==(const FilterOperation& o) const OVERRIDE
{
if (!isSameType(o))
return false;
@@ -144,7 +140,7 @@ private:
return m_url == other->m_url;
}
- ReferenceFilterOperation(const String& url, const String& fragment)
+ ReferenceFilterOperation(const String& url, const AtomicString& fragment)
: FilterOperation(REFERENCE)
, m_url(url)
, m_fragment(fragment)
@@ -152,7 +148,7 @@ private:
}
String m_url;
- String m_fragment;
+ AtomicString m_fragment;
RefPtr<ReferenceFilter> m_filter;
};
@@ -172,7 +168,7 @@ public:
private:
virtual PassRefPtr<FilterOperation> blend(const FilterOperation* from, double progress) const OVERRIDE;
- virtual bool operator==(const FilterOperation& o) const
+ virtual bool operator==(const FilterOperation& o) const OVERRIDE
{
if (!isSameType(o))
return false;
@@ -207,12 +203,12 @@ public:
double amount() const { return m_amount; }
- virtual bool affectsOpacity() const { return m_type == OPACITY; }
+ virtual bool affectsOpacity() const OVERRIDE { return m_type == OPACITY; }
private:
virtual PassRefPtr<FilterOperation> blend(const FilterOperation* from, double progress) const OVERRIDE;
- virtual bool operator==(const FilterOperation& o) const
+ virtual bool operator==(const FilterOperation& o) const OVERRIDE
{
if (!isSameType(o))
return false;
@@ -239,20 +235,20 @@ DEFINE_TYPE_CASTS(BasicComponentTransferFilterOperation, FilterOperation, op, is
class PLATFORM_EXPORT BlurFilterOperation : public FilterOperation {
public:
- static PassRefPtr<BlurFilterOperation> create(Length stdDeviation)
+ static PassRefPtr<BlurFilterOperation> create(const Length& stdDeviation)
{
return adoptRef(new BlurFilterOperation(stdDeviation));
}
- Length stdDeviation() const { return m_stdDeviation; }
+ const Length& stdDeviation() const { return m_stdDeviation; }
- virtual bool affectsOpacity() const { return true; }
- virtual bool movesPixels() const { return true; }
+ virtual bool affectsOpacity() const OVERRIDE { return true; }
+ virtual bool movesPixels() const OVERRIDE { return true; }
private:
virtual PassRefPtr<FilterOperation> blend(const FilterOperation* from, double progress) const OVERRIDE;
- virtual bool operator==(const FilterOperation& o) const
+ virtual bool operator==(const FilterOperation& o) const OVERRIDE
{
if (!isSameType(o))
return false;
@@ -260,7 +256,7 @@ private:
return m_stdDeviation == other->m_stdDeviation;
}
- BlurFilterOperation(Length stdDeviation)
+ BlurFilterOperation(const Length& stdDeviation)
: FilterOperation(BLUR)
, m_stdDeviation(stdDeviation)
{
@@ -284,13 +280,13 @@ public:
int stdDeviation() const { return m_stdDeviation; }
Color color() const { return m_color; }
- virtual bool affectsOpacity() const { return true; }
- virtual bool movesPixels() const { return true; }
+ virtual bool affectsOpacity() const OVERRIDE { return true; }
+ virtual bool movesPixels() const OVERRIDE { return true; }
private:
virtual PassRefPtr<FilterOperation> blend(const FilterOperation* from, double progress) const OVERRIDE;
- virtual bool operator==(const FilterOperation& o) const
+ virtual bool operator==(const FilterOperation& o) const OVERRIDE
{
if (!isSameType(o))
return false;
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperations.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperations.cpp
index d2692bd3167..08c8709ffab 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperations.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperations.cpp
@@ -34,14 +34,12 @@ namespace WebCore {
static inline IntSize outsetSizeForBlur(float stdDeviation)
{
- unsigned kernelSizeX = 0;
- unsigned kernelSizeY = 0;
- FEGaussianBlur::calculateUnscaledKernelSize(kernelSizeX, kernelSizeY, stdDeviation, stdDeviation);
+ IntSize kernelSize = FEGaussianBlur::calculateUnscaledKernelSize(FloatPoint(stdDeviation, stdDeviation));
IntSize outset;
// We take the half kernel size and multiply it with three, because we run box blur three times.
- outset.setWidth(3 * kernelSizeX * 0.5f);
- outset.setHeight(3 * kernelSizeY * 0.5f);
+ outset.setWidth(3 * kernelSize.width() * 0.5f);
+ outset.setHeight(3 * kernelSize.height() * 0.5f);
return outset;
}
@@ -90,16 +88,6 @@ bool FilterOperations::canInterpolateWith(const FilterOperations& other) const
return true;
}
-bool FilterOperations::hasCustomFilter() const
-{
- for (size_t i = 0; i < m_operations.size(); ++i) {
- FilterOperation::OperationType type = m_operations.at(i)->type();
- if (type == FilterOperation::CUSTOM || type == FilterOperation::VALIDATED_CUSTOM)
- return true;
- }
- return false;
-}
-
bool FilterOperations::hasReferenceFilter() const
{
for (size_t i = 0; i < m_operations.size(); ++i) {
@@ -160,12 +148,6 @@ FilterOutsets FilterOperations::outsets() const
}
break;
}
- case FilterOperation::CUSTOM:
- case FilterOperation::VALIDATED_CUSTOM: {
- // FIXME: Need to include the filter margins here.
- // https://bugs.webkit.org/show_bug.cgi?id=71400
- break;
- }
default:
break;
}
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperations.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperations.h
index c220b828adb..4413b1d868b 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperations.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperations.h
@@ -70,7 +70,6 @@ public:
bool hasFilterThatAffectsOpacity() const;
bool hasFilterThatMovesPixels() const;
- bool hasCustomFilter() const;
bool hasReferenceFilter() const;
private:
Vector<RefPtr<FilterOperation> > m_operations;
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperationsTest.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperationsTest.cpp
new file mode 100644
index 00000000000..93bcf28fe1f
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/FilterOperationsTest.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "platform/graphics/filters/FilterOperations.h"
+
+#include <gtest/gtest.h>
+
+using namespace WebCore;
+using namespace blink;
+
+namespace {
+
+TEST(FilterOperationsTest, getOutsetsBlur)
+{
+ FilterOperations ops;
+ ops.operations().append(BlurFilterOperation::create(Length(20.0, WebCore::Fixed)));
+ EXPECT_TRUE(ops.hasOutsets());
+ FilterOutsets outsets = ops.outsets();
+ EXPECT_EQ(57, outsets.top());
+ EXPECT_EQ(57, outsets.right());
+ EXPECT_EQ(57, outsets.bottom());
+ EXPECT_EQ(57, outsets.left());
+}
+
+TEST(FilterOperationsTest, getOutsetsDropShadow)
+{
+ FilterOperations ops;
+ ops.operations().append(DropShadowFilterOperation::create(IntPoint(3, 8), 20, Color(1, 2, 3)));
+ EXPECT_TRUE(ops.hasOutsets());
+ FilterOutsets outsets = ops.outsets();
+ EXPECT_EQ(49, outsets.top());
+ EXPECT_EQ(60, outsets.right());
+ EXPECT_EQ(65, outsets.bottom());
+ EXPECT_EQ(54, outsets.left());
+}
+
+}
+
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/ImageFilterBuilderTest.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/ImageFilterBuilderTest.cpp
new file mode 100644
index 00000000000..5c131e9899b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/ImageFilterBuilderTest.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "SkImageFilter.h"
+#include "platform/graphics/filters/FEBlend.h"
+#include "platform/graphics/filters/FEGaussianBlur.h"
+#include "platform/graphics/filters/FEMerge.h"
+#include "platform/graphics/filters/FilterOperations.h"
+#include "platform/graphics/filters/ReferenceFilter.h"
+#include "platform/graphics/filters/SkiaImageFilterBuilder.h"
+#include "platform/graphics/filters/SourceGraphic.h"
+#include <gtest/gtest.h>
+
+using testing::Test;
+using namespace WebCore;
+
+class ImageFilterBuilderTest : public Test {
+protected:
+ void colorSpaceTest()
+ {
+ // Build filter tree
+ RefPtr<ReferenceFilter> referenceFilter = ReferenceFilter::create();
+
+ // Add a dummy source graphic input
+ RefPtr<FilterEffect> sourceEffect = referenceFilter->sourceGraphic();
+ sourceEffect->setOperatingColorSpace(ColorSpaceDeviceRGB);
+
+ // Add a blur effect (with input : source)
+ RefPtr<FilterEffect> blurEffect =
+ FEGaussianBlur::create(referenceFilter.get(), 3.0f, 3.0f);
+ blurEffect->setOperatingColorSpace(ColorSpaceLinearRGB);
+ blurEffect->inputEffects().append(sourceEffect);
+
+ // Add a blend effect (with inputs : blur, source)
+ RefPtr<FilterEffect> blendEffect =
+ FEBlend::create(referenceFilter.get(), FEBLEND_MODE_NORMAL);
+ blendEffect->setOperatingColorSpace(ColorSpaceDeviceRGB);
+ FilterEffectVector& blendInputs = blendEffect->inputEffects();
+ blendInputs.reserveCapacity(2);
+ blendInputs.append(sourceEffect);
+ blendInputs.append(blurEffect);
+
+ // Add a merge effect (with inputs : blur, blend)
+ RefPtr<FilterEffect> mergeEffect = FEMerge::create(referenceFilter.get());
+ mergeEffect->setOperatingColorSpace(ColorSpaceLinearRGB);
+ FilterEffectVector& mergeInputs = mergeEffect->inputEffects();
+ mergeInputs.reserveCapacity(2);
+ mergeInputs.append(blurEffect);
+ mergeInputs.append(blendEffect);
+ referenceFilter->setLastEffect(mergeEffect);
+
+ // Get SkImageFilter resulting tree
+ SkiaImageFilterBuilder builder;
+ RefPtr<SkImageFilter> filter = builder.build(referenceFilter->lastEffect(), ColorSpaceDeviceRGB);
+
+ // Let's check that the resulting tree looks like this :
+ // ColorSpace (Linear->Device) : CS (L->D)
+ // |
+ // Merge (L)
+ // | |
+ // | CS (D->L)
+ // | |
+ // | Blend (D)
+ // | / |
+ // | CS (L->D) |
+ // | / |
+ // Blur (L) |
+ // \ |
+ // CS (D->L) |
+ // \ |
+ // Source Graphic (D)
+
+ EXPECT_EQ(filter->countInputs(), 1); // Should be CS (L->D)
+ SkImageFilter* child = filter->getInput(0); // Should be Merge
+ EXPECT_EQ(child->asColorFilter(0), false);
+ EXPECT_EQ(child->countInputs(), 2);
+ child = child->getInput(1); // Should be CS (D->L)
+ EXPECT_EQ(child->asColorFilter(0), true);
+ EXPECT_EQ(child->countInputs(), 1);
+ child = child->getInput(0); // Should be Blend
+ EXPECT_EQ(child->asColorFilter(0), false);
+ EXPECT_EQ(child->countInputs(), 2);
+ child = child->getInput(0); // Should be CS (L->D)
+ EXPECT_EQ(child->asColorFilter(0), true);
+ EXPECT_EQ(child->countInputs(), 1);
+ child = child->getInput(0); // Should be Blur
+ EXPECT_EQ(child->asColorFilter(0), false);
+ EXPECT_EQ(child->countInputs(), 1);
+ child = child->getInput(0); // Should be CS (D->L)
+ EXPECT_EQ(child->asColorFilter(0), true);
+ EXPECT_EQ(child->countInputs(), 1);
+ }
+};
+
+namespace {
+
+TEST_F(ImageFilterBuilderTest, testColorSpace)
+{
+ colorSpaceTest();
+}
+
+} // namespace
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/LightSource.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/LightSource.h
index 255f66935b1..ecd9271c408 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/LightSource.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/LightSource.h
@@ -57,7 +57,6 @@ public:
FloatPoint3D privateColorVector;
float coneCutOffLimit;
float coneFullLight;
- int specularExponent;
};
LightSource(LightType type)
@@ -69,10 +68,12 @@ public:
LightType type() const { return m_type; }
virtual TextStream& externalRepresentation(TextStream&) const = 0;
- virtual void initPaintingData(PaintingData&) = 0;
+ virtual PassRefPtr<LightSource> create(const FloatPoint3D& scale, const FloatSize& offset) const = 0;
+
+ virtual void initPaintingData(PaintingData&) const = 0;
// z is a float number, since it is the alpha value scaled by a user
// specified "surfaceScale" constant, which type is <number> in the SVG standard
- virtual void updatePaintingData(PaintingData&, int x, int y, float z) = 0;
+ virtual void updatePaintingData(PaintingData&, int x, int y, float z) const = 0;
virtual bool setAzimuth(float) { return false; }
virtual bool setElevation(float) { return false; }
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/ParallelJobs.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/ParallelJobs.h
index 17909017bc6..5c3d17f050a 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/ParallelJobs.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/ParallelJobs.h
@@ -64,9 +64,10 @@ public:
ParallelJobs(WorkerFunction func, size_t requestedJobNumber)
: m_func(func)
{
- m_parameters.grow(requestedJobNumber);
+ size_t numberOfJobs = std::max(static_cast<size_t>(2), std::min(requestedJobNumber, blink::Platform::current()->numberOfProcessors()));
+ m_parameters.grow(numberOfJobs);
// The main thread can execute one job, so only create requestJobNumber - 1 threads.
- for (size_t i = 0; i < requestedJobNumber - 1; ++i) {
+ for (size_t i = 0; i < numberOfJobs - 1; ++i) {
OwnPtr<blink::WebThread> thread = adoptPtr(blink::Platform::current()->createThread("Unfortunate parallel worker"));
m_threads.append(thread.release());
}
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/PointLightSource.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/PointLightSource.cpp
index c88c2ea4b19..5acacbc43c4 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/PointLightSource.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/PointLightSource.cpp
@@ -35,11 +35,11 @@
namespace WebCore {
-void PointLightSource::initPaintingData(PaintingData&)
+void PointLightSource::initPaintingData(PaintingData&) const
{
}
-void PointLightSource::updatePaintingData(PaintingData& paintingData, int x, int y, float z)
+void PointLightSource::updatePaintingData(PaintingData& paintingData, int x, int y, float z) const
{
paintingData.lightVector.setX(m_position.x() - x);
paintingData.lightVector.setY(m_position.y() - y);
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/PointLightSource.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/PointLightSource.h
index 6638e89ede8..112f0168e7a 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/PointLightSource.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/PointLightSource.h
@@ -34,15 +34,21 @@ public:
return adoptRef(new PointLightSource(position));
}
+ virtual PassRefPtr<LightSource> create(const FloatPoint3D& scale, const FloatSize& offset) const OVERRIDE
+ {
+ FloatPoint3D position(m_position.x() * scale.x() - offset.width(), m_position.y() * scale.y() - offset.height(), m_position.z() * scale.z());
+ return adoptRef(new PointLightSource(position));
+ }
+
const FloatPoint3D& position() const { return m_position; }
virtual bool setX(float) OVERRIDE;
virtual bool setY(float) OVERRIDE;
virtual bool setZ(float) OVERRIDE;
- virtual void initPaintingData(PaintingData&);
- virtual void updatePaintingData(PaintingData&, int x, int y, float z);
+ virtual void initPaintingData(PaintingData&) const OVERRIDE;
+ virtual void updatePaintingData(PaintingData&, int x, int y, float z) const OVERRIDE;
- virtual TextStream& externalRepresentation(TextStream&) const;
+ virtual TextStream& externalRepresentation(TextStream&) const OVERRIDE;
private:
PointLightSource(const FloatPoint3D& position)
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/ReferenceFilter.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/ReferenceFilter.cpp
index 3367d7ce836..9a3788b7e65 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/ReferenceFilter.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/ReferenceFilter.cpp
@@ -41,8 +41,6 @@ ReferenceFilter::ReferenceFilter()
: Filter(AffineTransform())
, m_sourceGraphic(SourceGraphic::create(this))
{
- // FIXME: This should come from the filter DOM node's filterRes attribute.
- setFilterResolution(FloatSize(1, 1));
}
void ReferenceFilter::setLastEffect(PassRefPtr<FilterEffect> effect)
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/ReferenceFilter.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/ReferenceFilter.h
index bc9fa3159ef..450490d58e2 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/ReferenceFilter.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/ReferenceFilter.h
@@ -48,7 +48,7 @@ public:
return adoptRef(new ReferenceFilter());
}
- virtual FloatRect sourceImageRect() const { return FloatRect(); };
+ virtual IntRect sourceImageRect() const OVERRIDE { return IntRect(); };
void setLastEffect(PassRefPtr<FilterEffect>);
FilterEffect* lastEffect() const { return m_lastEffect.get(); }
@@ -57,7 +57,7 @@ public:
private:
ReferenceFilter();
- ~ReferenceFilter();
+ virtual ~ReferenceFilter();
RefPtr<SourceGraphic> m_sourceGraphic;
RefPtr<FilterEffect> m_lastEffect;
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.cpp
index abbaf2bba59..5c6404c6c12 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.cpp
@@ -30,26 +30,24 @@
#include "SkColorFilterImageFilter.h"
#include "SkColorMatrixFilter.h"
#include "SkDropShadowImageFilter.h"
+#include "SkMatrixImageFilter.h"
#include "SkTableColorFilter.h"
#include "platform/graphics/ImageBuffer.h"
#include "platform/graphics/filters/FilterEffect.h"
#include "platform/graphics/filters/FilterOperations.h"
#include "platform/graphics/filters/SourceGraphic.h"
+#include "platform/graphics/skia/SkiaUtils.h"
#include "public/platform/WebPoint.h"
-namespace {
+namespace WebCore {
-PassRefPtr<SkImageFilter> createMatrixImageFilter(SkScalar matrix[20], SkImageFilter* input)
+SkiaImageFilterBuilder::SkiaImageFilterBuilder()
+ : m_context(0)
{
- RefPtr<SkColorFilter> colorFilter(adoptRef(new SkColorMatrixFilter(matrix)));
- return adoptRef(SkColorFilterImageFilter::Create(colorFilter.get(), input));
}
-};
-
-namespace WebCore {
-
-SkiaImageFilterBuilder::SkiaImageFilterBuilder()
+SkiaImageFilterBuilder::SkiaImageFilterBuilder(GraphicsContext* context)
+ : m_context(context)
{
}
@@ -57,22 +55,23 @@ SkiaImageFilterBuilder::~SkiaImageFilterBuilder()
{
}
-PassRefPtr<SkImageFilter> SkiaImageFilterBuilder::build(FilterEffect* effect, ColorSpace colorSpace)
+PassRefPtr<SkImageFilter> SkiaImageFilterBuilder::build(FilterEffect* effect, ColorSpace colorSpace, bool destinationRequiresValidPreMultipliedPixels)
{
if (!effect)
- return 0;
-
- FilterColorSpacePair key(effect, colorSpace);
- FilterBuilderHashMap::iterator it = m_map.find(key);
- if (it != m_map.end()) {
- return it->value;
- } else {
- // Note that we may still need the color transform even if the filter is null
- RefPtr<SkImageFilter> origFilter = effect->createImageFilter(this);
- RefPtr<SkImageFilter> filter = transformColorSpace(origFilter.get(), effect->operatingColorSpace(), colorSpace);
- m_map.set(key, filter);
- return filter.release();
- }
+ return nullptr;
+
+ bool requiresPMColorValidation = effect->mayProduceInvalidPreMultipliedPixels() && destinationRequiresValidPreMultipliedPixels;
+
+ if (SkImageFilter* filter = effect->getImageFilter(colorSpace, requiresPMColorValidation))
+ return filter;
+
+ // Note that we may still need the color transform even if the filter is null
+ RefPtr<SkImageFilter> origFilter = requiresPMColorValidation ? effect->createImageFilter(this) : effect->createImageFilterWithoutValidation(this);
+ RefPtr<SkImageFilter> filter = transformColorSpace(origFilter.get(), effect->operatingColorSpace(), colorSpace);
+ effect->setImageFilter(colorSpace, requiresPMColorValidation, filter.get());
+ if (filter.get() != origFilter.get())
+ effect->setImageFilter(effect->operatingColorSpace(), requiresPMColorValidation, origFilter.get());
+ return filter.release();
}
PassRefPtr<SkImageFilter> SkiaImageFilterBuilder::transformColorSpace(
@@ -91,12 +90,7 @@ bool SkiaImageFilterBuilder::buildFilterOperations(const FilterOperations& opera
return false;
ColorSpace currentColorSpace = ColorSpaceDeviceRGB;
-
- RefPtr<SkImageFilter> noopFilter;
- SkScalar matrix[20];
- memset(matrix, 0, 20 * sizeof(SkScalar));
- matrix[0] = matrix[6] = matrix[12] = matrix[18] = 1.f;
- noopFilter = createMatrixImageFilter(matrix, 0);
+ SkImageFilter* const nullFilter = 0;
for (size_t i = 0; i < operations.size(); ++i) {
const FilterOperation& op = *operations.at(i);
@@ -106,21 +100,22 @@ bool SkiaImageFilterBuilder::buildFilterOperations(const FilterOperations& opera
ReferenceFilter* referenceFilter = toReferenceFilterOperation(op).filter();
if (referenceFilter && referenceFilter->lastEffect()) {
FilterEffect* filterEffect = referenceFilter->lastEffect();
- // Link SourceGraphic to a noop filter that serves as a placholder for
- // the previous filter in the chain. We don't know what color space the
- // interior nodes will request, so we have to populate the map with both
- // options. (Only one of these will actually have a color transform on it.)
- FilterColorSpacePair deviceKey(referenceFilter->sourceGraphic(), ColorSpaceDeviceRGB);
- FilterColorSpacePair linearKey(referenceFilter->sourceGraphic(), ColorSpaceLinearRGB);
- m_map.set(deviceKey, transformColorSpace(noopFilter.get(), currentColorSpace, ColorSpaceDeviceRGB));
- m_map.set(linearKey, transformColorSpace(noopFilter.get(), currentColorSpace, ColorSpaceLinearRGB));
+ // Prepopulate SourceGraphic with two image filters: one with a null image
+ // filter, and the other with a colorspace conversion filter.
+ // We don't know what color space the interior nodes will request, so we have to
+ // initialize SourceGraphic with both options.
+ // Since we know SourceGraphic is always PM-valid, we also use
+ // these for the PM-validated options.
+ RefPtr<SkImageFilter> deviceFilter = transformColorSpace(nullFilter, currentColorSpace, ColorSpaceDeviceRGB);
+ RefPtr<SkImageFilter> linearFilter = transformColorSpace(nullFilter, currentColorSpace, ColorSpaceLinearRGB);
+ FilterEffect* sourceGraphic = referenceFilter->sourceGraphic();
+ sourceGraphic->setImageFilter(ColorSpaceDeviceRGB, false, deviceFilter.get());
+ sourceGraphic->setImageFilter(ColorSpaceLinearRGB, false, linearFilter.get());
+ sourceGraphic->setImageFilter(ColorSpaceDeviceRGB, true, deviceFilter.get());
+ sourceGraphic->setImageFilter(ColorSpaceLinearRGB, true, linearFilter.get());
currentColorSpace = filterEffect->operatingColorSpace();
filter = SkiaImageFilterBuilder::build(filterEffect, currentColorSpace);
- // We might have no reference to the SourceGraphic's Skia filter now, so make
- // sure we don't keep it in the map anymore.
- m_map.remove(deviceKey);
- m_map.remove(linearKey);
filters->appendReferenceFilter(filter.get());
}
break;
@@ -181,21 +176,21 @@ bool SkiaImageFilterBuilder::buildFilterOperations(const FilterOperations& opera
filters->appendDropShadowFilter(blink::WebPoint(drop.x(), drop.y()), drop.stdDeviation(), drop.color().rgb());
break;
}
- case FilterOperation::VALIDATED_CUSTOM:
- case FilterOperation::CUSTOM:
- return false; // Not supported.
case FilterOperation::NONE:
break;
}
}
if (currentColorSpace != ColorSpaceDeviceRGB) {
// Transform to device color space at the end of processing, if required
- RefPtr<SkImageFilter> filter;
- filter = transformColorSpace(noopFilter.get(), currentColorSpace, ColorSpaceDeviceRGB);
- if (filter != noopFilter)
- filters->appendReferenceFilter(filter.get());
+ RefPtr<SkImageFilter> filter = transformColorSpace(nullFilter, currentColorSpace, ColorSpaceDeviceRGB);
+ filters->appendReferenceFilter(filter.get());
}
return true;
}
+PassRefPtr<SkImageFilter> SkiaImageFilterBuilder::buildTransform(const AffineTransform& transform, SkImageFilter* input)
+{
+ return adoptRef(SkMatrixImageFilter::Create(affineTransformToSkMatrix(transform), SkPaint::kHigh_FilterLevel, input));
+}
+
};
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.h
index 33adf2026e6..a44280b181d 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.h
@@ -30,46 +30,37 @@
#include "platform/geometry/FloatSize.h"
#include "platform/graphics/ColorSpace.h"
#include "public/platform/WebFilterOperations.h"
-#include "wtf/HashMap.h"
class SkImageFilter;
namespace WebCore {
+class AffineTransform;
class FilterEffect;
class FilterOperations;
+class GraphicsContext;
class PLATFORM_EXPORT SkiaImageFilterBuilder {
public:
SkiaImageFilterBuilder();
+ explicit SkiaImageFilterBuilder(GraphicsContext*);
~SkiaImageFilterBuilder();
- PassRefPtr<SkImageFilter> build(FilterEffect*, ColorSpace);
+ PassRefPtr<SkImageFilter> build(FilterEffect*, ColorSpace, bool requiresPMColorValidation = true);
bool buildFilterOperations(const FilterOperations&, blink::WebFilterOperations*);
+ PassRefPtr<SkImageFilter> buildTransform(const AffineTransform&, SkImageFilter* input);
PassRefPtr<SkImageFilter> transformColorSpace(
SkImageFilter* input, ColorSpace srcColorSpace, ColorSpace dstColorSpace);
void setCropOffset(const FloatSize& cropOffset) { m_cropOffset = cropOffset; };
FloatSize cropOffset() { return m_cropOffset; }
+ GraphicsContext* context() { return m_context; }
private:
- typedef std::pair<FilterEffect*, ColorSpace> FilterColorSpacePair;
- typedef HashMap<FilterColorSpacePair, RefPtr<SkImageFilter> > FilterBuilderHashMap;
- FilterBuilderHashMap m_map;
FloatSize m_cropOffset;
+ GraphicsContext* m_context;
};
} // namespace WebCore
-namespace WTF {
-
-template<> struct DefaultHash<WebCore::FilterEffect*> {
- typedef PtrHash<WebCore::FilterEffect*> Hash;
-};
-template<> struct DefaultHash<WebCore::ColorSpace> {
- typedef IntHash<unsigned> Hash;
-};
-
-} // namespace WTF
-
#endif
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/SourceAlpha.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/SourceAlpha.cpp
index 1a1df1ba8bb..f00370fbef2 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/SourceAlpha.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/SourceAlpha.cpp
@@ -25,6 +25,8 @@
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/filters/Filter.h"
#include "platform/text/TextStream.h"
+#include "third_party/skia/include/effects/SkColorFilterImageFilter.h"
+#include "third_party/skia/include/effects/SkColorMatrixFilter.h"
#include "wtf/StdLibExtras.h"
#include "wtf/text/WTFString.h"
@@ -41,12 +43,12 @@ const AtomicString& SourceAlpha::effectName()
return s_effectName;
}
-void SourceAlpha::determineAbsolutePaintRect()
+FloatRect SourceAlpha::determineAbsolutePaintRect(const FloatRect& requestedRect)
{
- Filter* filter = this->filter();
- FloatRect paintRect = filter->sourceImageRect();
- paintRect.scale(filter->filterResolution().width(), filter->filterResolution().height());
- setAbsolutePaintRect(enclosingIntRect(paintRect));
+ FloatRect srcRect = filter()->sourceImageRect();
+ srcRect.intersect(requestedRect);
+ addAbsolutePaintRect(srcRect);
+ return srcRect;
}
void SourceAlpha::applySoftware()
@@ -61,7 +63,25 @@ void SourceAlpha::applySoftware()
FloatRect imageRect(FloatPoint(), absolutePaintRect().size());
GraphicsContext* filterContext = resultImage->context();
filterContext->fillRect(imageRect, Color::black);
- filterContext->drawImageBuffer(filter->sourceImage(), IntPoint(), CompositeDestinationIn);
+
+ IntRect srcRect = filter->sourceImageRect();
+ if (ImageBuffer* sourceImageBuffer = filter->sourceImage()) {
+ filterContext->drawImageBuffer(sourceImageBuffer,
+ FloatRect(IntPoint(srcRect.location() - absolutePaintRect().location()), sourceImageBuffer->size()),
+ 0, CompositeDestinationIn);
+ }
+}
+
+PassRefPtr<SkImageFilter> SourceAlpha::createImageFilter(SkiaImageFilterBuilder* builder)
+{
+ SkScalar matrix[20] = {
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, SK_Scalar1, 0
+ };
+ RefPtr<SkColorFilter> colorFilter(adoptRef(SkColorMatrixFilter::Create(matrix)));
+ return adoptRef(SkColorFilterImageFilter::Create(colorFilter.get()));
}
TextStream& SourceAlpha::externalRepresentation(TextStream& ts, int indent) const
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/SourceAlpha.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/SourceAlpha.h
index 519a31af32f..ee1de7f5379 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/SourceAlpha.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/SourceAlpha.h
@@ -32,11 +32,12 @@ public:
static const AtomicString& effectName();
- virtual void determineAbsolutePaintRect();
+ virtual FloatRect determineAbsolutePaintRect(const FloatRect& requestedRect) OVERRIDE;
- virtual FilterEffectType filterEffectType() const { return FilterEffectTypeSourceInput; }
+ virtual FilterEffectType filterEffectType() const OVERRIDE { return FilterEffectTypeSourceInput; }
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
+ virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE;
private:
SourceAlpha(Filter* filter)
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/SourceGraphic.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/SourceGraphic.cpp
index c1d69768c04..f9c1195e5bc 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/SourceGraphic.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/SourceGraphic.cpp
@@ -40,12 +40,12 @@ const AtomicString& SourceGraphic::effectName()
return s_effectName;
}
-void SourceGraphic::determineAbsolutePaintRect()
+FloatRect SourceGraphic::determineAbsolutePaintRect(const FloatRect& requestedRect)
{
- Filter* filter = this->filter();
- FloatRect paintRect = filter->sourceImageRect();
- paintRect.scale(filter->filterResolution().width(), filter->filterResolution().height());
- setAbsolutePaintRect(enclosingIntRect(paintRect));
+ FloatRect srcRect = filter()->sourceImageRect();
+ srcRect.intersect(requestedRect);
+ addAbsolutePaintRect(srcRect);
+ return srcRect;
}
void SourceGraphic::applySoftware()
@@ -55,7 +55,11 @@ void SourceGraphic::applySoftware()
if (!resultImage || !filter->sourceImage())
return;
- resultImage->context()->drawImageBuffer(filter->sourceImage(), IntPoint());
+ IntRect srcRect = filter->sourceImageRect();
+ if (ImageBuffer* sourceImageBuffer = filter->sourceImage()) {
+ resultImage->context()->drawImageBuffer(sourceImageBuffer,
+ FloatRect(IntPoint(srcRect.location() - absolutePaintRect().location()), sourceImageBuffer->size()));
+ }
}
TextStream& SourceGraphic::externalRepresentation(TextStream& ts, int indent) const
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/SourceGraphic.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/SourceGraphic.h
index eeeae633f77..582ab51e722 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/SourceGraphic.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/SourceGraphic.h
@@ -33,11 +33,11 @@ public:
static const AtomicString& effectName();
- virtual void determineAbsolutePaintRect();
+ virtual FloatRect determineAbsolutePaintRect(const FloatRect& requestedRect) OVERRIDE;
- virtual FilterEffectType filterEffectType() const { return FilterEffectTypeSourceInput; }
+ virtual FilterEffectType filterEffectType() const OVERRIDE { return FilterEffectTypeSourceInput; }
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ virtual TextStream& externalRepresentation(TextStream&, int indention) const OVERRIDE;
private:
SourceGraphic(Filter* filter)
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.cpp
index 9aeb26341ae..aec1320062f 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.cpp
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.cpp
@@ -40,7 +40,7 @@ namespace WebCore {
// according to the SVG 1.1 SE light regression tests
static const float antiAliasTreshold = 0.016f;
-void SpotLightSource::initPaintingData(PaintingData& paintingData)
+void SpotLightSource::initPaintingData(PaintingData& paintingData) const
{
paintingData.privateColorVector = paintingData.colorVector;
paintingData.directionVector.setX(m_direction.x() - m_position.x());
@@ -60,17 +60,9 @@ void SpotLightSource::initPaintingData(PaintingData& paintingData)
paintingData.coneCutOffLimit = cosf(deg2rad(180.0f - limitingConeAngle));
paintingData.coneFullLight = paintingData.coneCutOffLimit - antiAliasTreshold;
}
-
- // Optimization for common specularExponent values
- if (!m_specularExponent)
- paintingData.specularExponent = 0;
- else if (m_specularExponent == 1.0f)
- paintingData.specularExponent = 1;
- else // It is neither 0.0f nor 1.0f
- paintingData.specularExponent = 2;
}
-void SpotLightSource::updatePaintingData(PaintingData& paintingData, int x, int y, float z)
+void SpotLightSource::updatePaintingData(PaintingData& paintingData, int x, int y, float z) const
{
paintingData.lightVector.setX(m_position.x() - x);
paintingData.lightVector.setY(m_position.y() - y);
@@ -88,16 +80,10 @@ void SpotLightSource::updatePaintingData(PaintingData& paintingData, int x, int
// Set the color of the pixel
float lightStrength;
- switch (paintingData.specularExponent) {
- case 0:
- lightStrength = 1.0f; // -cosineOfAngle ^ 0 == 1
- break;
- case 1:
+ if (1.0f == m_specularExponent) {
lightStrength = -cosineOfAngle; // -cosineOfAngle ^ 1 == -cosineOfAngle
- break;
- default:
+ } else {
lightStrength = powf(-cosineOfAngle, m_specularExponent);
- break;
}
if (cosineOfAngle > paintingData.coneFullLight)
@@ -161,6 +147,7 @@ bool SpotLightSource::setPointsAtZ(float pointsAtZ)
bool SpotLightSource::setSpecularExponent(float specularExponent)
{
+ specularExponent = std::min(std::max(specularExponent, 1.0f), 128.0f);
if (m_specularExponent == specularExponent)
return false;
m_specularExponent = specularExponent;
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.h
index ce8ce27f1ef..2b8599457f5 100644
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.h
+++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.h
@@ -35,6 +35,13 @@ public:
return adoptRef(new SpotLightSource(position, direction, specularExponent, limitingConeAngle));
}
+ virtual PassRefPtr<LightSource> create(const FloatPoint3D& scale, const FloatSize& offset) const OVERRIDE
+ {
+ FloatPoint3D position(m_position.x() * scale.x() - offset.width(), m_position.y() * scale.y() - offset.height(), m_position.z() * scale.z());
+ FloatPoint3D direction(m_direction.x() * scale.x() - offset.width(), m_direction.y() * scale.y() - offset.height(), m_direction.z() * scale.z());
+ return adoptRef(new SpotLightSource(position, direction, m_specularExponent, m_limitingConeAngle));
+ }
+
const FloatPoint3D& position() const { return m_position; }
const FloatPoint3D& direction() const { return m_direction; }
float specularExponent() const { return m_specularExponent; }
@@ -50,10 +57,10 @@ public:
virtual bool setSpecularExponent(float) OVERRIDE;
virtual bool setLimitingConeAngle(float) OVERRIDE;
- virtual void initPaintingData(PaintingData&);
- virtual void updatePaintingData(PaintingData&, int x, int y, float z);
+ virtual void initPaintingData(PaintingData&) const OVERRIDE;
+ virtual void updatePaintingData(PaintingData&, int x, int y, float z) const OVERRIDE;
- virtual TextStream& externalRepresentation(TextStream&) const;
+ virtual TextStream& externalRepresentation(TextStream&) const OVERRIDE;
private:
SpotLightSource(const FloatPoint3D& position, const FloatPoint3D& direction,
@@ -61,7 +68,7 @@ private:
: LightSource(LS_SPOT)
, m_position(position)
, m_direction(direction)
- , m_specularExponent(specularExponent)
+ , m_specularExponent(std::min(std::max(specularExponent, 1.0f), 128.0f))
, m_limitingConeAngle(limitingConeAngle)
{
}
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterArrayParameter.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterArrayParameter.cpp
deleted file mode 100644
index 138fef6ef36..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterArrayParameter.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "platform/graphics/filters/custom/CustomFilterArrayParameter.h"
-
-#include "platform/animation/AnimationUtilities.h"
-
-namespace WebCore {
-
-PassRefPtr<CustomFilterParameter> CustomFilterArrayParameter::blend(const CustomFilterParameter* from, double progress)
-{
- if (!from || !isSameType(*from))
- return this;
-
- const CustomFilterArrayParameter* fromArray = static_cast<const CustomFilterArrayParameter*>(from);
-
- if (size() != fromArray->size())
- return this;
-
- RefPtr<CustomFilterArrayParameter> result = CustomFilterArrayParameter::create(name());
- for (size_t i = 0; i < size(); ++i)
- result->addValue(WebCore::blend(fromArray->valueAt(i), valueAt(i), progress));
-
- return result.release();
-}
-
-} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterArrayParameter.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterArrayParameter.h
deleted file mode 100644
index a58d1525c30..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterArrayParameter.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef CustomFilterArrayParameter_h
-#define CustomFilterArrayParameter_h
-
-#include "platform/PlatformExport.h"
-#include "platform/graphics/filters/custom/CustomFilterParameter.h"
-#include "wtf/Vector.h"
-
-namespace WebCore {
-
-class PLATFORM_EXPORT CustomFilterArrayParameter : public CustomFilterParameter {
-public:
- static PassRefPtr<CustomFilterArrayParameter> create(const String& name)
- {
- return adoptRef(new CustomFilterArrayParameter(name));
- }
-
- unsigned size() const { return m_data.size(); }
- double valueAt(unsigned index) const { return m_data.at(index); }
-
- void addValue(double value) { m_data.append(value); }
-
- virtual PassRefPtr<CustomFilterParameter> blend(const CustomFilterParameter* from, double progress);
-
- virtual bool operator==(const CustomFilterParameter& o) const
- {
- if (!isSameType(o))
- return false;
-
- const CustomFilterArrayParameter* other = static_cast<const CustomFilterArrayParameter*>(&o);
- return m_data == other->m_data;
- }
-
-private:
- CustomFilterArrayParameter(const String& name)
- : CustomFilterParameter(Array, name)
- {
- }
-
- Vector<double> m_data;
-};
-
-} // namespace WebCore
-
-
-#endif // CustomFilterArrayParameter_h
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterCompiledProgram.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterCompiledProgram.cpp
deleted file mode 100644
index 2e5d853dcc9..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterCompiledProgram.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "platform/graphics/filters/custom/CustomFilterCompiledProgram.h"
-
-namespace WebCore {
-
-CustomFilterCompiledProgram::CustomFilterCompiledProgram(PassRefPtr<GraphicsContext3D> context, const String& validatedVertexShader, const String& validatedFragmentShader, CustomFilterProgramType programType)
- : m_context(context)
- , m_program(0)
- , m_positionAttribLocation(-1)
- , m_texAttribLocation(-1)
- , m_meshAttribLocation(-1)
- , m_triangleAttribLocation(-1)
- , m_meshBoxLocation(-1)
- , m_projectionMatrixLocation(-1)
- , m_tileSizeLocation(-1)
- , m_meshSizeLocation(-1)
- , m_samplerLocation(-1)
- , m_samplerSizeLocation(-1)
- , m_contentSamplerLocation(-1)
- , m_isInitialized(false)
-{
- m_context->makeContextCurrent();
-
- Platform3DObject vertexShader = compileShader(GL_VERTEX_SHADER, validatedVertexShader);
- if (!vertexShader)
- return;
-
- Platform3DObject fragmentShader = compileShader(GL_FRAGMENT_SHADER, validatedFragmentShader);
- if (!fragmentShader) {
- m_context->deleteShader(vertexShader);
- return;
- }
-
- m_program = linkProgram(vertexShader, fragmentShader);
-
- m_context->deleteShader(vertexShader);
- m_context->deleteShader(fragmentShader);
-
- if (!m_program)
- return;
-
- initializeParameterLocations(programType);
-
- m_isInitialized = true;
-}
-
-Platform3DObject CustomFilterCompiledProgram::compileShader(GC3Denum shaderType, const String& shaderString)
-{
- ASSERT(!shaderString.isNull());
-
- Platform3DObject shader = m_context->createShader(shaderType);
- m_context->shaderSource(shader, shaderString);
- m_context->compileShader(shader);
-
- int compiled = 0;
- m_context->getShaderiv(shader, GL_COMPILE_STATUS, &compiled);
- if (!compiled) {
- // FIXME: This is an invalid shader. Throw some errors.
- // https://bugs.webkit.org/show_bug.cgi?id=74416
- m_context->deleteShader(shader);
- return 0;
- }
-
- return shader;
-}
-
-Platform3DObject CustomFilterCompiledProgram::linkProgram(Platform3DObject vertexShader, Platform3DObject fragmentShader)
-{
- Platform3DObject program = m_context->createProgram();
- m_context->attachShader(program, vertexShader);
- m_context->attachShader(program, fragmentShader);
- m_context->linkProgram(program);
-
- int linked = 0;
- m_context->getProgramiv(program, GL_LINK_STATUS, &linked);
- if (!linked) {
- // FIXME: Invalid vertex/fragment shader combination. Throw some errors here.
- // https://bugs.webkit.org/show_bug.cgi?id=74416
- m_context->deleteProgram(program);
- return 0;
- }
-
- return program;
-}
-
-void CustomFilterCompiledProgram::initializeParameterLocations(CustomFilterProgramType programType)
-{
- m_positionAttribLocation = m_context->getAttribLocation(m_program, "a_position");
- m_texAttribLocation = m_context->getAttribLocation(m_program, "a_texCoord");
- m_meshAttribLocation = m_context->getAttribLocation(m_program, "a_meshCoord");
- m_triangleAttribLocation = m_context->getAttribLocation(m_program, "a_triangleCoord");
- m_meshBoxLocation = m_context->getUniformLocation(m_program, "u_meshBox");
- m_tileSizeLocation = m_context->getUniformLocation(m_program, "u_tileSize");
- m_meshSizeLocation = m_context->getUniformLocation(m_program, "u_meshSize");
- m_projectionMatrixLocation = m_context->getUniformLocation(m_program, "u_projectionMatrix");
- m_samplerSizeLocation = m_context->getUniformLocation(m_program, "u_textureSize");
- m_contentSamplerLocation = m_context->getUniformLocation(m_program, "u_contentTexture");
- if (programType == ProgramTypeBlendsElementTexture) {
- // When the author uses the CSS mix function in a custom filter, WebKit adds the internal
- // symbol css_u_texture to the shader code, which references the texture of the element.
- m_samplerLocation = m_context->getUniformLocation(m_program, "css_u_texture");
- }
-}
-
-int CustomFilterCompiledProgram::uniformLocationByName(const String& name)
-{
- ASSERT(m_isInitialized);
- // FIXME: Improve this by caching the uniform locations.
- return m_context->getUniformLocation(m_program, name);
-}
-
-CustomFilterCompiledProgram::~CustomFilterCompiledProgram()
-{
- if (m_program) {
- m_context->makeContextCurrent();
- m_context->deleteProgram(m_program);
- }
-}
-
-} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterCompiledProgram.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterCompiledProgram.h
deleted file mode 100644
index 54b6a0a7f6c..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterCompiledProgram.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef CustomFilterCompiledProgram_h
-#define CustomFilterCompiledProgram_h
-
-#include "platform/graphics/GraphicsContext3D.h"
-#include "platform/graphics/filters/custom/CustomFilterProgramInfo.h"
-#include "wtf/RefCounted.h"
-#include "wtf/text/WTFString.h"
-
-namespace WebCore {
-
-class CustomFilterGlobalContext;
-
-class CustomFilterCompiledProgram: public RefCounted<CustomFilterCompiledProgram> {
-public:
- static PassRefPtr<CustomFilterCompiledProgram> create(PassRefPtr<GraphicsContext3D> context, const String& validatedVertexShader, const String& validatedFragmentShader, CustomFilterProgramType programType)
- {
- return adoptRef(new CustomFilterCompiledProgram(context, validatedVertexShader, validatedFragmentShader, programType));
- }
-
- ~CustomFilterCompiledProgram();
-
- int positionAttribLocation() const { return m_positionAttribLocation; }
- int texAttribLocation() const { return m_texAttribLocation; }
- int meshAttribLocation() const { return m_meshAttribLocation; }
- int triangleAttribLocation() const { return m_triangleAttribLocation; }
- int meshBoxLocation() const { return m_meshBoxLocation; }
- int projectionMatrixLocation() const { return m_projectionMatrixLocation; }
- int tileSizeLocation() const { return m_tileSizeLocation; }
- int meshSizeLocation() const { return m_meshSizeLocation; }
- int samplerLocation() const { return m_samplerLocation; }
- int contentSamplerLocation() const { return m_contentSamplerLocation; }
- int samplerSizeLocation() const { return m_samplerSizeLocation; }
-
- int uniformLocationByName(const String&);
-
- bool isInitialized() const { return m_isInitialized; }
-
- Platform3DObject program() const { return m_program; }
-private:
- CustomFilterCompiledProgram(PassRefPtr<GraphicsContext3D>, const String& validatedVertexShader, const String& validatedFragmentShader, CustomFilterProgramType);
-
- Platform3DObject compileShader(GC3Denum shaderType, const String& shaderString);
- Platform3DObject linkProgram(Platform3DObject vertexShader, Platform3DObject fragmentShader);
- void initializeParameterLocations(CustomFilterProgramType);
-
- RefPtr<GraphicsContext3D> m_context;
- Platform3DObject m_program;
-
- int m_positionAttribLocation;
- int m_texAttribLocation;
- int m_meshAttribLocation;
- int m_triangleAttribLocation;
- int m_meshBoxLocation;
- int m_projectionMatrixLocation;
- int m_tileSizeLocation;
- int m_meshSizeLocation;
- int m_samplerLocation;
- int m_samplerSizeLocation;
- int m_contentSamplerLocation;
-
- bool m_isInitialized;
-};
-
-}
-
-#endif
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterConstants.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterConstants.h
deleted file mode 100644
index 5c3b2143e2a..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterConstants.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef CustomFilterConstants_h
-#define CustomFilterConstants_h
-
-namespace WebCore {
-
-enum CustomFilterMeshConstants {
- // Vertex attribute sizes
- PositionAttribSize = 4,
- TexAttribSize = 2,
- MeshAttribSize = 2,
- TriangleAttribSize = 3,
- // Vertex attribute offsets
- PositionAttribOffset = 0,
- TexAttribOffset = PositionAttribOffset + PositionAttribSize * sizeof(float),
- MeshAttribOffset = TexAttribOffset + TexAttribSize * sizeof(float),
- TriangleAttribOffset = MeshAttribOffset + MeshAttribSize * sizeof(float)
-};
-
-enum CustomFilterMeshType {
- MeshTypeAttached,
- MeshTypeDetached
-};
-
-enum CustomFilterProgramType {
- ProgramTypeNoElementTexture,
- ProgramTypeBlendsElementTexture
-};
-
-} // namespace WebCore
-
-#endif // CustomFilterConstants_h
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterGlobalContext.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterGlobalContext.cpp
deleted file mode 100644
index a3727ae3446..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterGlobalContext.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "platform/graphics/filters/custom/CustomFilterGlobalContext.h"
-
-#include "platform/graphics/GraphicsContext3D.h"
-#include "platform/graphics/filters/custom/CustomFilterValidatedProgram.h"
-
-namespace WebCore {
-
-CustomFilterGlobalContext::CustomFilterGlobalContext()
-{
-}
-
-CustomFilterGlobalContext::~CustomFilterGlobalContext()
-{
- for (CustomFilterValidatedProgramsMap::iterator iter = m_programs.begin(); iter != m_programs.end(); ++iter)
- iter->value->detachFromGlobalContext();
-}
-
-ANGLEPlatformBridge* CustomFilterGlobalContext::webglShaderValidator()
-{
- if (!m_webglShaderValidator)
- m_webglShaderValidator = createShaderValidator(SH_WEBGL_SPEC);
- return m_webglShaderValidator.get();
-}
-
-ANGLEPlatformBridge* CustomFilterGlobalContext::mixShaderValidator()
-{
- if (!m_mixShaderValidator)
- m_mixShaderValidator = createShaderValidator(SH_CSS_SHADERS_SPEC);
- return m_mixShaderValidator.get();
-}
-
-PassOwnPtr<ANGLEPlatformBridge> CustomFilterGlobalContext::createShaderValidator(ShShaderSpec shaderSpec)
-{
- OwnPtr<ANGLEPlatformBridge> validator = adoptPtr(new ANGLEPlatformBridge(SH_ESSL_OUTPUT, shaderSpec));
- ShBuiltInResources resources;
- ShInitBuiltInResources(&resources);
- validator->setResources(resources);
- return validator.release();
-}
-
-void CustomFilterGlobalContext::prepareContextIfNeeded()
-{
- if (m_context.get())
- return;
-
- GraphicsContext3D::Attributes attributes;
- attributes.preserveDrawingBuffer = true;
- attributes.premultipliedAlpha = false;
- attributes.shareResources = true;
- attributes.preferDiscreteGPU = true;
- m_context = GraphicsContext3D::create(attributes);
- if (!m_context)
- return;
- m_context->makeContextCurrent();
- m_context->enable(GL_DEPTH_TEST);
-}
-
-PassRefPtr<CustomFilterValidatedProgram> CustomFilterGlobalContext::getValidatedProgram(const CustomFilterProgramInfo& programInfo)
-{
- CustomFilterValidatedProgramsMap::iterator iter = m_programs.find(programInfo);
- if (iter != m_programs.end())
- return iter->value;
-
- RefPtr<CustomFilterValidatedProgram> validatedProgram = CustomFilterValidatedProgram::create(this, programInfo);
- m_programs.set(programInfo, validatedProgram.get());
- return validatedProgram.release();
-}
-
-void CustomFilterGlobalContext::removeValidatedProgram(const CustomFilterValidatedProgram* program)
-{
- CustomFilterValidatedProgramsMap::iterator iter = m_programs.find(program->programInfo());
- ASSERT_WITH_SECURITY_IMPLICATION(iter != m_programs.end());
- m_programs.remove(iter);
-
-#ifndef NDEBUG
- // Check that there's no way we could have the same program under a different key.
- for (iter = m_programs.begin(); iter != m_programs.end(); ++iter)
- ASSERT(iter->value != program);
-#endif
-}
-
-} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterGlobalContext.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterGlobalContext.h
deleted file mode 100644
index 01f54d5fa92..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterGlobalContext.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef CustomFilterGlobalContext_h
-#define CustomFilterGlobalContext_h
-
-#include "platform/graphics/angle/ANGLEPlatformBridge.h"
-#include "platform/graphics/filters/custom/CustomFilterProgramInfo.h"
-#include "wtf/HashMap.h"
-#include "wtf/Noncopyable.h"
-#include "wtf/RefPtr.h"
-
-namespace WebCore {
-
-class CustomFilterValidatedProgram;
-class GraphicsContext3D;
-
-typedef HashMap<CustomFilterProgramInfo, CustomFilterValidatedProgram*> CustomFilterValidatedProgramsMap;
-
-class PLATFORM_EXPORT CustomFilterGlobalContext {
- WTF_MAKE_NONCOPYABLE(CustomFilterGlobalContext);
-public:
- CustomFilterGlobalContext();
- ~CustomFilterGlobalContext();
-
- GraphicsContext3D* context() const { return m_context.get(); }
-
- // CSS shaders not referenced from the CSS mix function should be validated just like regular WebGL shaders.
- // This ANGLE validator uses the SH_WEBGL_SPEC flag.
- ANGLEPlatformBridge* webglShaderValidator();
-
- // CSS shaders referenced from the CSS mix function should be validated slightly differently than WebGL shaders.
- // This ANGLE validator uses the SH_CSS_SHADERS_SPEC flag.
- // Under this flag, most notably:
- // - The "gl_FragColor" built-in is not available.
- // - Instead, the "css_MixColor" and "css_ColorMatrix" built-ins are available.
- // - The "css_" prefix is reserved.
- // - In the translated source that ANGLE returns, ANGLE renames the author's "main" function to "css_main".
- // The complete details are documented in ANGLE/ShaderLang.h.
- ANGLEPlatformBridge* mixShaderValidator();
-
- void prepareContextIfNeeded();
-
- PassRefPtr<CustomFilterValidatedProgram> getValidatedProgram(const CustomFilterProgramInfo&);
- void removeValidatedProgram(const CustomFilterValidatedProgram*);
-private:
- static PassOwnPtr<ANGLEPlatformBridge> createShaderValidator(ShShaderSpec);
-
- RefPtr<GraphicsContext3D> m_context;
- OwnPtr<ANGLEPlatformBridge> m_webglShaderValidator;
- OwnPtr<ANGLEPlatformBridge> m_mixShaderValidator;
- CustomFilterValidatedProgramsMap m_programs;
-};
-
-} // namespace WebCore
-
-#endif // CustomFilterGlobalContext_h
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterMesh.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterMesh.cpp
deleted file mode 100644
index cb4c59cfc37..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterMesh.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "platform/graphics/filters/custom/CustomFilterMesh.h"
-
-#include "platform/graphics/GraphicsContext3D.h"
-#include "platform/graphics/filters/custom/CustomFilterMeshGenerator.h"
-
-namespace WebCore {
-
-CustomFilterMesh::CustomFilterMesh(GraphicsContext3D* context, unsigned columns, unsigned rows,
- const FloatRect& meshBox, CustomFilterMeshType meshType)
- : m_context(context)
- , m_verticesBufferObject(0)
- , m_elementsBufferObject(0)
- , m_meshBox(meshBox)
- , m_meshType(meshType)
-{
- CustomFilterMeshGenerator generator(columns, rows, meshBox, meshType);
- m_indicesCount = generator.indicesCount();
- m_bytesPerVertex = generator.floatsPerVertex() * sizeof(float);
-
- m_context->makeContextCurrent();
-
- m_verticesBufferObject = m_context->createBuffer();
- m_context->bindBuffer(GL_ARRAY_BUFFER, m_verticesBufferObject);
- m_context->bufferData(GL_ARRAY_BUFFER, generator.vertices().size() * sizeof(float), generator.vertices().data(), GL_STATIC_DRAW);
-
- m_elementsBufferObject = m_context->createBuffer();
- m_context->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_elementsBufferObject);
- m_context->bufferData(GL_ELEMENT_ARRAY_BUFFER, generator.indices().size() * sizeof(uint16_t), generator.indices().data(), GL_STATIC_DRAW);
-}
-
-CustomFilterMesh::~CustomFilterMesh()
-{
- m_context->makeContextCurrent();
- m_context->deleteBuffer(m_verticesBufferObject);
- m_context->deleteBuffer(m_elementsBufferObject);
-}
-
-} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterMesh.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterMesh.h
deleted file mode 100644
index b9e8a1b5f11..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterMesh.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef CustomFilterMesh_h
-#define CustomFilterMesh_h
-
-#include "platform/geometry/FloatRect.h"
-#include "platform/graphics/GraphicsTypes3D.h"
-#include "platform/graphics/filters/custom/CustomFilterOperation.h"
-#include "wtf/RefCounted.h"
-
-namespace WebCore {
-
-class GraphicsContext3D;
-
-class PLATFORM_EXPORT CustomFilterMesh : public RefCounted<CustomFilterMesh> {
-public:
- static PassRefPtr<CustomFilterMesh> create(GraphicsContext3D* context, unsigned cols, unsigned rows, const FloatRect& meshBox, CustomFilterMeshType meshType)
- {
- return adoptRef(new CustomFilterMesh(context, cols, rows, meshBox, meshType));
- }
- ~CustomFilterMesh();
-
- Platform3DObject verticesBufferObject() const { return m_verticesBufferObject; }
- unsigned bytesPerVertex() const { return m_bytesPerVertex; }
-
- Platform3DObject elementsBufferObject() const { return m_elementsBufferObject; }
- unsigned indicesCount() const { return m_indicesCount; }
-
- const FloatRect& meshBox() const { return m_meshBox; }
- CustomFilterMeshType meshType() const { return m_meshType; }
-
-private:
- CustomFilterMesh(GraphicsContext3D*, unsigned cols, unsigned rows, const FloatRect& meshBox, CustomFilterMeshType);
-
- GraphicsContext3D* m_context;
-
- Platform3DObject m_verticesBufferObject;
- unsigned m_bytesPerVertex;
-
- Platform3DObject m_elementsBufferObject;
- unsigned m_indicesCount;
-
- FloatRect m_meshBox;
- CustomFilterMeshType m_meshType;
-};
-
-} // namespace WebCore
-
-#endif // CustomFilterMesh_h
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterMeshGenerator.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterMeshGenerator.cpp
deleted file mode 100644
index 3e373009979..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterMeshGenerator.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "platform/graphics/filters/custom/CustomFilterMeshGenerator.h"
-
-#ifndef NDEBUG
-#include <stdio.h> // Needed for printf used in dumpBuffers.
-#endif
-
-namespace WebCore {
-
-#ifndef NDEBUG
-// Use "call 'WebCore::s_dumpCustomFilterMeshBuffers' = 1" in GDB to activate printing of the mesh buffers.
-static bool s_dumpCustomFilterMeshBuffers = false;
-#endif
-
-CustomFilterMeshGenerator::CustomFilterMeshGenerator(unsigned columns, unsigned rows, const FloatRect& meshBox, CustomFilterMeshType meshType)
- : m_meshType(meshType)
- , m_points(columns + 1, rows + 1)
- , m_tiles(columns, rows)
- , m_tileSizeInPixels(meshBox.width() / m_tiles.width(), meshBox.height() / m_tiles.height())
- , m_tileSizeInDeviceSpace(1.0f / m_tiles.width(), 1.0f / m_tiles.height())
- , m_meshBox(meshBox)
-{
- // Build the two buffers needed to draw triangles:
- // * m_vertices has a number of float attributes that will be passed to the vertex shader
- // for each computed vertex. This number is calculated in floatsPerVertex() based on the meshType.
- // * m_indices is a buffer that will have 3 indices per triangle. Each index will point inside
- // the m_vertices buffer.
- m_vertices.reserveCapacity(verticesCount() * floatsPerVertex());
- m_indices.reserveCapacity(indicesCount());
-
- // Based on the meshType there can be two types of meshes.
- // * attached: each triangle uses vertices from the neighbor triangles. This is useful to save some GPU memory
- // when there's no need to explode the tiles.
- // * detached: each triangle has its own vertices. This means each triangle can be moved independently and a vec3
- // attribute is passed, so that each vertex can be uniquely identified.
- if (m_meshType == MeshTypeAttached)
- generateAttachedMesh();
- else
- generateDetachedMesh();
-
-#ifndef NDEBUG
- if (s_dumpCustomFilterMeshBuffers)
- dumpBuffers();
-#endif
-}
-
-void CustomFilterMeshGenerator::addAttachedMeshIndex(int quadX, int quadY, int triangleX, int triangleY, int)
-{
- m_indices.append((quadY + triangleY) * m_points.width() + (quadX + triangleX));
-}
-
-void CustomFilterMeshGenerator::generateAttachedMesh()
-{
- for (int j = 0; j < m_points.height(); ++j) {
- for (int i = 0; i < m_points.width(); ++i)
- addAttachedMeshVertexAttributes(i, j);
- }
-
- for (int j = 0; j < m_tiles.height(); ++j) {
- for (int i = 0; i < m_tiles.width(); ++i)
- addTile<&CustomFilterMeshGenerator::addAttachedMeshIndex>(i, j);
- }
-}
-
-void CustomFilterMeshGenerator::addDetachedMeshVertexAndIndex(int quadX, int quadY, int triangleX, int triangleY, int triangle)
-{
- addDetachedMeshVertexAttributes(quadX, quadY, triangleX, triangleY, triangle);
- m_indices.append(m_indices.size());
-}
-
-void CustomFilterMeshGenerator::generateDetachedMesh()
-{
- for (int j = 0; j < m_tiles.height(); ++j) {
- for (int i = 0; i < m_tiles.width(); ++i)
- addTile<&CustomFilterMeshGenerator::addDetachedMeshVertexAndIndex>(i, j);
- }
-}
-
-void CustomFilterMeshGenerator::addPositionAttribute(int quadX, int quadY)
-{
- // vec4 a_position
- m_vertices.append(m_tileSizeInPixels.width() * quadX - 0.5f + m_meshBox.x());
- m_vertices.append(m_tileSizeInPixels.height() * quadY - 0.5f + m_meshBox.y());
- m_vertices.append(0.0f); // z
- m_vertices.append(1.0f);
-}
-
-void CustomFilterMeshGenerator::addTexCoordAttribute(int quadX, int quadY)
-{
- // vec2 a_texCoord
- m_vertices.append(m_tileSizeInPixels.width() * quadX + m_meshBox.x());
- m_vertices.append(m_tileSizeInPixels.height() * quadY + m_meshBox.y());
-}
-
-void CustomFilterMeshGenerator::addMeshCoordAttribute(int quadX, int quadY)
-{
- // vec2 a_meshCoord
- m_vertices.append(m_tileSizeInDeviceSpace.width() * quadX);
- m_vertices.append(m_tileSizeInDeviceSpace.height() * quadY);
-}
-
-void CustomFilterMeshGenerator::addTriangleCoordAttribute(int quadX, int quadY, int triangle)
-{
- // vec3 a_triangleCoord
- m_vertices.append(quadX);
- m_vertices.append(quadY);
- m_vertices.append(triangle);
-}
-
-void CustomFilterMeshGenerator::addAttachedMeshVertexAttributes(int quadX, int quadY)
-{
- addPositionAttribute(quadX, quadY);
- addTexCoordAttribute(quadX, quadY);
- addMeshCoordAttribute(quadX, quadY);
-}
-
-void CustomFilterMeshGenerator::addDetachedMeshVertexAttributes(int quadX, int quadY, int triangleX, int triangleY, int triangle)
-{
- addAttachedMeshVertexAttributes(quadX + triangleX, quadY + triangleY);
- addTriangleCoordAttribute(quadX, quadY, triangle);
-}
-
-#ifndef NDEBUG
-void CustomFilterMeshGenerator::dumpBuffers() const
-{
- printf("Mesh buffers: Points.width(): %d, Points.height(): %d meshBox: %f, %f, %f, %f, type: %s\n",
- m_points.width(), m_points.height(), m_meshBox.x(), m_meshBox.y(), m_meshBox.width(), m_meshBox.height(),
- (m_meshType == MeshTypeAttached) ? "Attached" : "Detached");
- printf("---Vertex:\n\t");
- for (unsigned i = 0; i < m_vertices.size(); ++i) {
- printf("%f ", m_vertices.at(i));
- if (!((i + 1) % floatsPerVertex()))
- printf("\n\t");
- }
- printf("\n---Indices: ");
- for (unsigned i = 0; i < m_indices.size(); ++i)
- printf("%d ", m_indices.at(i));
- printf("\n");
-}
-#endif
-
-} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterMeshGenerator.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterMeshGenerator.h
deleted file mode 100644
index d4fc6441611..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterMeshGenerator.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef CustomFilterMeshGenerator_h
-#define CustomFilterMeshGenerator_h
-
-#include "platform/PlatformExport.h"
-#include "platform/geometry/FloatRect.h"
-#include "platform/graphics/filters/custom/CustomFilterConstants.h"
-
-namespace WebCore {
-
-class PLATFORM_EXPORT CustomFilterMeshGenerator {
-public:
- // Lines and columns are the values passed in CSS. The result is vertex mesh that has 'rows' numbers of rows
- // and 'columns' number of columns with a total of 'rows + 1' * 'columns + 1' vertices.
- // MeshBox is the filtered area calculated defined using the border-box, padding-box, content-box or filter-box
- // attributes. A value of (0, 0, 1, 1) will cover the entire output surface.
- CustomFilterMeshGenerator(unsigned columns, unsigned rows, const FloatRect& meshBox, CustomFilterMeshType);
-
- const Vector<float>& vertices() const { return m_vertices; }
- const Vector<uint16_t>& indices() const { return m_indices; }
-
- const IntSize& points() const { return m_points; }
- unsigned pointsCount() const { return m_points.width() * m_points.height(); }
-
- const IntSize& tiles() const { return m_tiles; }
- unsigned tilesCount() const { return m_tiles.width() * m_tiles.height(); }
-
- unsigned indicesCount() const
- {
- const unsigned trianglesPerTile = 2;
- const unsigned indicesPerTriangle = 3;
- return tilesCount() * trianglesPerTile * indicesPerTriangle;
- }
-
- unsigned floatsPerVertex() const
- {
- static const unsigned AttachedMeshVertexSize = PositionAttribSize + TexAttribSize + MeshAttribSize;
- static const unsigned DetachedMeshVertexSize = AttachedMeshVertexSize + TriangleAttribSize;
- return m_meshType == MeshTypeAttached ? AttachedMeshVertexSize : DetachedMeshVertexSize;
- }
-
- unsigned verticesCount() const
- {
- return m_meshType == MeshTypeAttached ? pointsCount() : indicesCount();
- }
-
-private:
- typedef void (CustomFilterMeshGenerator::*AddTriangleVertexFunction)(int quadX, int quadY, int triangleX, int triangleY, int triangle);
-
- template <AddTriangleVertexFunction addTriangleVertex>
- void addTile(int quadX, int quadY)
- {
- ((*this).*(addTriangleVertex))(quadX, quadY, 0, 0, 1);
- ((*this).*(addTriangleVertex))(quadX, quadY, 1, 0, 2);
- ((*this).*(addTriangleVertex))(quadX, quadY, 1, 1, 3);
- ((*this).*(addTriangleVertex))(quadX, quadY, 0, 0, 4);
- ((*this).*(addTriangleVertex))(quadX, quadY, 1, 1, 5);
- ((*this).*(addTriangleVertex))(quadX, quadY, 0, 1, 6);
- }
-
- void addAttachedMeshIndex(int quadX, int quadY, int triangleX, int triangleY, int triangle);
-
- void generateAttachedMesh();
-
- void addDetachedMeshVertexAndIndex(int quadX, int quadY, int triangleX, int triangleY, int triangle);
-
- void generateDetachedMesh();
- void addPositionAttribute(int quadX, int quadY);
- void addTexCoordAttribute(int quadX, int quadY);
- void addMeshCoordAttribute(int quadX, int quadY);
- void addTriangleCoordAttribute(int quadX, int quadY, int triangle);
- void addAttachedMeshVertexAttributes(int quadX, int quadY);
- void addDetachedMeshVertexAttributes(int quadX, int quadY, int triangleX, int triangleY, int triangle);
-
-#ifndef NDEBUG
- void dumpBuffers() const;
-#endif
-
-private:
- Vector<float> m_vertices;
- Vector<uint16_t> m_indices;
-
- CustomFilterMeshType m_meshType;
- IntSize m_points;
- IntSize m_tiles;
- FloatSize m_tileSizeInPixels;
- FloatSize m_tileSizeInDeviceSpace;
- FloatRect m_meshBox;
-};
-
-} // namespace WebCore
-
-#endif // CustomFilterMeshGenerator_h
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterNumberParameter.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterNumberParameter.cpp
deleted file mode 100644
index 1fbfa58f6a9..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterNumberParameter.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "platform/graphics/filters/custom/CustomFilterNumberParameter.h"
-
-#include "platform/animation/AnimationUtilities.h"
-
-namespace WebCore {
-
-PassRefPtr<CustomFilterParameter> CustomFilterNumberParameter::blend(const CustomFilterParameter* from, double progress)
-{
- if (!from || !isSameType(*from))
- return this;
- const CustomFilterNumberParameter* fromNumber = static_cast<const CustomFilterNumberParameter*>(from);
- if (size() != fromNumber->size())
- return this;
- RefPtr<CustomFilterNumberParameter> result = CustomFilterNumberParameter::create(name());
- for (size_t i = 0; i < size(); ++i)
- result->addValue(WebCore::blend(fromNumber->valueAt(i), valueAt(i), progress));
- return result.release();
-}
-
-} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterNumberParameter.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterNumberParameter.h
deleted file mode 100644
index ed2e838fcd9..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterNumberParameter.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef CustomFilterNumberParameter_h
-#define CustomFilterNumberParameter_h
-
-#include "platform/PlatformExport.h"
-#include "platform/graphics/filters/custom/CustomFilterParameter.h"
-#include "wtf/Vector.h"
-
-namespace WebCore {
-
-class PLATFORM_EXPORT CustomFilterNumberParameter : public CustomFilterParameter {
-public:
- static PassRefPtr<CustomFilterNumberParameter> create(const String& name)
- {
- return adoptRef(new CustomFilterNumberParameter(name));
- }
-
- unsigned size() const { return m_data.size(); }
- double valueAt(unsigned index) const { return m_data.at(index); }
-
- void addValue(double value) { m_data.append(value); }
-
- virtual PassRefPtr<CustomFilterParameter> blend(const CustomFilterParameter* from, double progress);
-
- virtual bool operator==(const CustomFilterParameter& o) const
- {
- if (!isSameType(o))
- return false;
- const CustomFilterNumberParameter* other = static_cast<const CustomFilterNumberParameter*>(&o);
- return m_data == other->m_data;
- }
-
-private:
- CustomFilterNumberParameter(const String& name)
- : CustomFilterParameter(Number, name)
- {
- }
-
- Vector<double, 4> m_data;
-};
-
-} // namespace WebCore
-
-
-#endif // CustomFilterNumberParameter_h
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterOperation.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterOperation.cpp
deleted file mode 100644
index cf13a4998a3..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterOperation.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "platform/graphics/filters/custom/CustomFilterOperation.h"
-
-#include "platform/graphics/filters/custom/CustomFilterParameter.h"
-
-namespace WebCore {
-
-CustomFilterOperation::CustomFilterOperation(PassRefPtr<CustomFilterProgram> program, const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType)
- : FilterOperation(CUSTOM)
- , m_program(program)
- , m_parameters(sortedParameters)
- , m_meshRows(meshRows)
- , m_meshColumns(meshColumns)
- , m_meshType(meshType)
-{
-}
-
-CustomFilterOperation::~CustomFilterOperation()
-{
-}
-
-PassRefPtr<FilterOperation> CustomFilterOperation::blend(const FilterOperation* from, double progress) const
-{
- if (!from) {
- // FIXME: There's no way to decide what is the "passthrough filter" for shaders using the current CSS Syntax.
- // https://bugs.webkit.org/show_bug.cgi?id=84903
- // https://www.w3.org/Bugs/Public/show_bug.cgi?id=16861
- return const_cast<CustomFilterOperation*>(this);
- }
-
- ASSERT_WITH_SECURITY_IMPLICATION(from->isSameType(*this));
- const CustomFilterOperation* fromOp = toCustomFilterOperation(from);
- if (m_program.get() != fromOp->m_program.get()
- || m_meshRows != fromOp->m_meshRows
- || m_meshColumns != fromOp->m_meshColumns
- || m_meshType != fromOp->m_meshType)
- return const_cast<CustomFilterOperation*>(this);
-
- CustomFilterParameterList animatedParameters;
- m_parameters.blend(fromOp->m_parameters, progress, animatedParameters);
- return CustomFilterOperation::create(m_program, animatedParameters, m_meshRows, m_meshColumns, m_meshType);
-}
-
-} // namespace WebCore
-
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterOperation.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterOperation.h
deleted file mode 100644
index 945a534b108..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterOperation.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef CustomFilterOperation_h
-#define CustomFilterOperation_h
-
-#include "platform/geometry/LayoutSize.h"
-#include "platform/graphics/filters/FilterOperation.h"
-#include "platform/graphics/filters/custom/CustomFilterConstants.h"
-#include "platform/graphics/filters/custom/CustomFilterParameterList.h"
-#include "platform/graphics/filters/custom/CustomFilterProgram.h"
-
-namespace WebCore {
-
-// CSS Shaders
-
-class PLATFORM_EXPORT CustomFilterOperation : public FilterOperation {
-public:
- static PassRefPtr<CustomFilterOperation> create(PassRefPtr<CustomFilterProgram> program, const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType)
- {
- return adoptRef(new CustomFilterOperation(program, sortedParameters, meshRows, meshColumns, meshType));
- }
-
- CustomFilterProgram* program() const { return m_program.get(); }
- void setProgram(PassRefPtr<CustomFilterProgram> program) { m_program = program; }
-
- const CustomFilterParameterList& parameters() const { return m_parameters; }
-
- unsigned meshRows() const { return m_meshRows; }
- unsigned meshColumns() const { return m_meshColumns; }
-
- CustomFilterMeshType meshType() const { return m_meshType; }
-
- virtual ~CustomFilterOperation();
-
- virtual bool affectsOpacity() const { return true; }
- virtual bool movesPixels() const { return true; }
-
-
-protected:
- CustomFilterOperation(PassRefPtr<CustomFilterProgram>, const CustomFilterParameterList&, unsigned meshRows, unsigned meshColumns, CustomFilterMeshType);
-
-private:
- virtual PassRefPtr<FilterOperation> blend(const FilterOperation* from, double progress) const OVERRIDE;
- virtual bool operator==(const FilterOperation& o) const
- {
- if (!isSameType(o))
- return false;
-
- const CustomFilterOperation* other = static_cast<const CustomFilterOperation*>(&o);
- return m_program.get() == other->m_program.get()
- && m_meshRows == other->m_meshRows
- && m_meshColumns == other->m_meshColumns
- && m_meshType == other->m_meshType
- && m_parameters == other->m_parameters;
- }
-
- RefPtr<CustomFilterProgram> m_program;
- CustomFilterParameterList m_parameters;
-
- unsigned m_meshRows;
- unsigned m_meshColumns;
- CustomFilterMeshType m_meshType;
-};
-
-DEFINE_FILTER_OPERATION_TYPE_CASTS(CustomFilterOperation, CUSTOM);
-
-} // namespace WebCore
-
-
-#endif // CustomFilterOperation_h
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterParameter.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterParameter.h
deleted file mode 100644
index 13e1277528a..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterParameter.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef CustomFilterParameter_h
-#define CustomFilterParameter_h
-
-#include "platform/PlatformExport.h"
-#include "wtf/PassRefPtr.h"
-#include "wtf/RefCounted.h"
-#include "wtf/text/WTFString.h"
-
-namespace WebCore {
-
-class PLATFORM_EXPORT CustomFilterParameter : public RefCounted<CustomFilterParameter> {
-public:
- // FIXME: Implement other parameters types:
- // booleans: https://bugs.webkit.org/show_bug.cgi?id=76438
- // textures: https://bugs.webkit.org/show_bug.cgi?id=71442
- // 3d-transforms: https://bugs.webkit.org/show_bug.cgi?id=71443
- // mat2, mat3, mat4: https://bugs.webkit.org/show_bug.cgi?id=71444
- enum ParameterType {
- Array,
- Number,
- Transform
- };
-
- virtual ~CustomFilterParameter() { }
-
- ParameterType parameterType() const { return m_type; }
- const String& name() const { return m_name; }
-
- bool isSameType(const CustomFilterParameter& other) const { return parameterType() == other.parameterType(); }
-
- virtual PassRefPtr<CustomFilterParameter> blend(const CustomFilterParameter*, double progress) = 0;
- virtual bool operator==(const CustomFilterParameter&) const = 0;
- bool operator!=(const CustomFilterParameter& o) const { return !(*this == o); }
-protected:
- CustomFilterParameter(ParameterType type, const String& name)
- : m_name(name)
- , m_type(type)
- {
- }
-
-private:
- String m_name;
- ParameterType m_type;
-};
-
-} // namespace WebCore
-
-
-#endif // CustomFilterParameter_h
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterParameterList.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterParameterList.cpp
deleted file mode 100644
index d10aae8498e..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterParameterList.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "platform/graphics/filters/custom/CustomFilterParameterList.h"
-
-#include "wtf/text/StringHash.h"
-
-namespace WebCore {
-
-CustomFilterParameterList::CustomFilterParameterList()
-{
-}
-
-CustomFilterParameterList::CustomFilterParameterList(size_t size)
- : m_parameters(size)
-{
-}
-
-bool CustomFilterParameterList::operator==(const CustomFilterParameterList& other) const
-{
- if (size() != other.size())
- return false;
- for (size_t i = 0; i < size(); ++i) {
- if (at(i).get() != other.at(i).get()
- && *at(i).get() != *other.at(i).get())
- return false;
- }
- return true;
-}
-
-#ifndef NDEBUG
-bool CustomFilterParameterList::checkAlphabeticalOrder() const
-{
- for (unsigned i = 1; i < size(); ++i) {
- // Break for equal or not-sorted parameters.
- if (!codePointCompareLessThan(at(i - 1)->name(), at(i)->name()))
- return false;
- }
- return true;
-}
-#endif
-
-void CustomFilterParameterList::blend(const CustomFilterParameterList& fromList,
- double progress, CustomFilterParameterList& resultList) const
-{
-#ifndef NDEBUG
- // This method expects both lists to be sorted by parameter name and the result list is also sorted.
- ASSERT(checkAlphabeticalOrder());
- ASSERT(fromList.checkAlphabeticalOrder());
-#endif
- size_t fromListIndex = 0, toListIndex = 0;
- while (fromListIndex < fromList.size() && toListIndex < size()) {
- CustomFilterParameter* paramFrom = fromList.at(fromListIndex).get();
- CustomFilterParameter* paramTo = at(toListIndex).get();
- if (paramFrom->name() == paramTo->name()) {
- resultList.append(paramTo->blend(paramFrom, progress));
- ++fromListIndex;
- ++toListIndex;
- continue;
- }
- if (codePointCompareLessThan(paramFrom->name(), paramTo->name())) {
- resultList.append(paramFrom);
- ++fromListIndex;
- continue;
- }
- resultList.append(paramTo);
- ++toListIndex;
- }
- for (; fromListIndex < fromList.size(); ++fromListIndex)
- resultList.append(fromList.at(fromListIndex));
- for (; toListIndex < size(); ++toListIndex)
- resultList.append(at(toListIndex));
-#ifndef NDEBUG
- ASSERT(resultList.checkAlphabeticalOrder());
-#endif
-}
-
-static bool sortParametersByNameComparator(const RefPtr<CustomFilterParameter>& a, const RefPtr<CustomFilterParameter>& b)
-{
- return codePointCompareLessThan(a->name(), b->name());
-}
-
-void CustomFilterParameterList::sortParametersByName()
-{
- std::sort(m_parameters.begin(), m_parameters.end(), sortParametersByNameComparator);
-}
-
-} // namespace WebCore
-
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterParameterList.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterParameterList.h
deleted file mode 100644
index 0dd3dcd9a0e..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterParameterList.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef CustomFilterParameterList_h
-#define CustomFilterParameterList_h
-
-#include "platform/PlatformExport.h"
-#include "platform/geometry/LayoutSize.h"
-#include "platform/graphics/filters/custom/CustomFilterParameter.h"
-#include "wtf/Vector.h"
-
-namespace WebCore {
-
-class PLATFORM_EXPORT CustomFilterParameterList {
-public:
- CustomFilterParameterList();
- explicit CustomFilterParameterList(size_t);
-
- void blend(const CustomFilterParameterList& from, double progress, CustomFilterParameterList& resultList) const;
- bool operator==(const CustomFilterParameterList&) const;
-
- PassRefPtr<CustomFilterParameter> at(size_t index) const { return m_parameters.at(index); }
- size_t size() const { return m_parameters.size(); }
- void append(const PassRefPtr<CustomFilterParameter>& parameter) { m_parameters.append(parameter); }
- void sortParametersByName();
-private:
-#ifndef NDEBUG
- bool checkAlphabeticalOrder() const;
-#endif
- typedef Vector<RefPtr<CustomFilterParameter> > CustomFilterParameterVector;
- CustomFilterParameterVector m_parameters;
-};
-
-} // namespace WebCore
-
-
-#endif // CustomFilterParameterList_h
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgram.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgram.cpp
deleted file mode 100644
index ebaff283493..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgram.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "platform/graphics/filters/custom/CustomFilterProgram.h"
-
-#include "platform/graphics/filters/custom/CustomFilterProgramClient.h"
-
-namespace WebCore {
-
-CustomFilterProgram::CustomFilterProgram(CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings, CustomFilterMeshType meshType)
- : m_programType(programType)
- , m_mixSettings(mixSettings)
- , m_meshType(meshType)
-{
- // Keep the constructor protected to prevent creating this object directly.
-}
-
-CustomFilterProgram::~CustomFilterProgram()
-{
- // All the clients should keep a reference to this object.
- ASSERT(m_clients.isEmpty());
-}
-
-void CustomFilterProgram::addClient(CustomFilterProgramClient* client)
-{
- if (m_clients.isEmpty()) {
- // Notify the StyleCustomFilterProgram that we now have at least a client
- // and the loading can begin.
- // Note: If the shader is already cached the first client will be notified,
- // even if the filter was already built. Add the client only after notifying
- // the cache about them, so that we avoid a useless recreation of the filters chain.
- willHaveClients();
- }
- m_clients.add(client);
-}
-
-void CustomFilterProgram::removeClient(CustomFilterProgramClient* client)
-{
- m_clients.remove(client);
- if (m_clients.isEmpty()) {
- // We have no clients anymore, the cached resources can be purged from memory.
- didRemoveLastClient();
- }
-}
-
-void CustomFilterProgram::notifyClients()
-{
- for (CustomFilterProgramClientList::iterator iter = m_clients.begin(), end = m_clients.end(); iter != end; ++iter)
- iter->key->notifyCustomFilterProgramLoaded(this);
-}
-
-CustomFilterProgramInfo CustomFilterProgram::programInfo() const
-{
- ASSERT(isLoaded());
- return CustomFilterProgramInfo(vertexShaderString(), fragmentShaderString(), m_programType, m_mixSettings, m_meshType);
-}
-
-} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgram.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgram.h
deleted file mode 100644
index 1b949786d8e..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgram.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef CustomFilterProgram_h
-#define CustomFilterProgram_h
-
-#include "platform/graphics/filters/custom/CustomFilterProgramInfo.h"
-
-#include "wtf/HashCountedSet.h"
-#include "wtf/RefCounted.h"
-#include "wtf/text/WTFString.h"
-
-namespace WebCore {
-
-class GraphicsContext3D;
-class CustomFilterCompiledProgram;
-class CustomFilterProgramClient;
-
-// This is the base class for the StyleCustomFilterProgram class which knows how to keep
-// references to the cached shaders.
-class PLATFORM_EXPORT CustomFilterProgram: public RefCounted<CustomFilterProgram> {
-public:
- virtual ~CustomFilterProgram();
-
- virtual bool isLoaded() const = 0;
-
- void addClient(CustomFilterProgramClient*);
- void removeClient(CustomFilterProgramClient*);
-
- CustomFilterProgramInfo programInfo() const;
-
- virtual String vertexShaderString() const = 0;
- virtual String fragmentShaderString() const = 0;
- CustomFilterProgramType programType() const { return m_programType; }
- CustomFilterProgramMixSettings mixSettings() const { return m_mixSettings; }
- CustomFilterMeshType meshType() const { return m_meshType; }
-
-protected:
- // StyleCustomFilterProgram can notify the clients that the cached resources are
- // loaded and it is ready to create CustomFilterCompiledProgram objects.
- void notifyClients();
-
- virtual void willHaveClients() = 0;
- virtual void didRemoveLastClient() = 0;
-
- // Keep the constructor protected to prevent creating this object directly.
- CustomFilterProgram(CustomFilterProgramType, const CustomFilterProgramMixSettings&, CustomFilterMeshType);
-
-private:
- // CustomFilterPrograms are unique combinations of shaders and can be
- // compared using just the pointer value instead.
- // These will catch anyone doing a value equal comparison.
- bool operator==(const CustomFilterProgram&) const;
- bool operator!=(const CustomFilterProgram&) const;
-
- typedef HashCountedSet<CustomFilterProgramClient*> CustomFilterProgramClientList;
- CustomFilterProgramClientList m_clients;
- CustomFilterProgramType m_programType;
- CustomFilterProgramMixSettings m_mixSettings;
- CustomFilterMeshType m_meshType;
-};
-
-}
-
-
-#endif
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgramClient.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgramClient.cpp
deleted file mode 100644
index 85a378f6bac..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgramClient.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "platform/graphics/filters/custom/CustomFilterProgramClient.h"
-
-namespace WebCore {
-
-CustomFilterProgramClient::~CustomFilterProgramClient()
-{
-}
-
-} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgramClient.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgramClient.h
deleted file mode 100644
index b13098b9ab8..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgramClient.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef CustomFilterProgramClient_h
-#define CustomFilterProgramClient_h
-
-#include "platform/PlatformExport.h"
-
-namespace WebCore {
-
-class CustomFilterProgram;
-
-class PLATFORM_EXPORT CustomFilterProgramClient {
-public:
- virtual ~CustomFilterProgramClient();
-
- virtual void notifyCustomFilterProgramLoaded(CustomFilterProgram*) = 0;
-};
-
-}
-
-
-#endif // CustomFilterProgramClient_h
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgramInfo.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgramInfo.cpp
deleted file mode 100644
index a767e6edb90..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgramInfo.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "platform/graphics/filters/custom/CustomFilterProgramInfo.h"
-
-#include "wtf/HashFunctions.h"
-#include "wtf/text/StringHash.h"
-
-namespace WebCore {
-
-static unsigned hashPossiblyNullString(const String& string)
-{
- return string.isNull() ? 0 : DefaultHash<String>::Hash::hash(string);
-}
-
-CustomFilterProgramInfo::CustomFilterProgramInfo()
-{
-}
-
-bool CustomFilterProgramInfo::isEmptyValue() const
-{
- return m_vertexShaderString.isNull()
- && m_fragmentShaderString.isNull();
-}
-
-CustomFilterProgramInfo::CustomFilterProgramInfo(WTF::HashTableDeletedValueType)
- : m_vertexShaderString(WTF::HashTableDeletedValue)
- , m_fragmentShaderString(WTF::HashTableDeletedValue)
-{
-}
-
-bool CustomFilterProgramInfo::isHashTableDeletedValue() const
-{
- return m_vertexShaderString.isHashTableDeletedValue()
- && m_fragmentShaderString.isHashTableDeletedValue();
-}
-
-CustomFilterProgramInfo::CustomFilterProgramInfo(const String& vertexShader, const String& fragmentShader, CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings, CustomFilterMeshType meshType)
- : m_vertexShaderString(vertexShader)
- , m_fragmentShaderString(fragmentShader)
- , m_programType(programType)
- , m_mixSettings(mixSettings)
- , m_meshType(meshType)
-{
- // At least one of the shaders needs to be non-null.
- ASSERT(!m_vertexShaderString.isNull() || !m_fragmentShaderString.isNull());
-}
-
-unsigned CustomFilterProgramInfo::hash() const
-{
- // At least one of the shaders needs to be non-null.
- ASSERT(!m_vertexShaderString.isNull() || !m_fragmentShaderString.isNull());
-
- bool blendsElementTexture = (m_programType == ProgramTypeBlendsElementTexture);
- uintptr_t hashCodes[6] = {
- hashPossiblyNullString(m_vertexShaderString),
- hashPossiblyNullString(m_fragmentShaderString),
- blendsElementTexture,
- static_cast<uintptr_t>(blendsElementTexture ? m_mixSettings.blendMode : 0),
- static_cast<uintptr_t>(blendsElementTexture ? m_mixSettings.compositeOperator : 0),
- m_meshType
- };
- return StringHasher::hashMemory<sizeof(hashCodes)>(&hashCodes);
-}
-
-bool CustomFilterProgramInfo::operator==(const CustomFilterProgramInfo& o) const
-{
- ASSERT(!isHashTableDeletedValue());
- ASSERT(!o.isHashTableDeletedValue());
-
- return m_programType == o.m_programType
- && (m_programType != ProgramTypeBlendsElementTexture || m_mixSettings == o.m_mixSettings)
- && m_meshType == o.m_meshType
- && m_vertexShaderString == o.m_vertexShaderString
- && m_fragmentShaderString == o.m_fragmentShaderString;
-}
-
-} // namespace WebCore
-
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgramInfo.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgramInfo.h
deleted file mode 100644
index 079cd402ede..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterProgramInfo.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef CustomFilterProgramInfo_h
-#define CustomFilterProgramInfo_h
-
-#include "platform/PlatformExport.h"
-#include "platform/graphics/GraphicsTypes.h"
-#include "platform/graphics/filters/custom/CustomFilterConstants.h"
-#include "wtf/HashTableDeletedValueType.h"
-#include "wtf/HashTraits.h"
-#include "wtf/text/WTFString.h"
-
-namespace WebCore {
-
-
-struct CustomFilterProgramMixSettings {
- CustomFilterProgramMixSettings()
- : blendMode(blink::WebBlendModeNormal)
- , compositeOperator(CompositeSourceAtop)
- {
- }
-
- bool operator==(const CustomFilterProgramMixSettings& o) const
- {
- return blendMode == o.blendMode && compositeOperator == o.compositeOperator;
- }
-
- blink::WebBlendMode blendMode;
- CompositeOperator compositeOperator;
-};
-
-// CustomFilterProgramInfo is the key used to link CustomFilterProgram with CustomFilterCompiledProgram.
-// It can be used as a key in a HashMap, with the note that at least one of Strings needs to be non-null.
-// Null strings are placeholders for the default shader.
-class PLATFORM_EXPORT CustomFilterProgramInfo {
-public:
- CustomFilterProgramInfo(const String&, const String&, CustomFilterProgramType, const CustomFilterProgramMixSettings&, CustomFilterMeshType);
-
- CustomFilterProgramInfo();
- bool isEmptyValue() const;
-
- CustomFilterProgramInfo(WTF::HashTableDeletedValueType);
- bool isHashTableDeletedValue() const;
-
- unsigned hash() const;
- bool operator==(const CustomFilterProgramInfo&) const;
-
- const String& vertexShaderString() const { return m_vertexShaderString; }
- const String& fragmentShaderString() const { return m_fragmentShaderString; }
- CustomFilterProgramType programType() const { return m_programType; }
- const CustomFilterProgramMixSettings& mixSettings() const { return m_mixSettings; }
- CustomFilterMeshType meshType() const { return m_meshType; }
-private:
- String m_vertexShaderString;
- String m_fragmentShaderString;
- CustomFilterProgramType m_programType;
- CustomFilterProgramMixSettings m_mixSettings;
- CustomFilterMeshType m_meshType;
-};
-
-struct CustomFilterProgramInfoHash {
- static unsigned hash(const CustomFilterProgramInfo& programInfo) { return programInfo.hash(); }
- static bool equal(const CustomFilterProgramInfo& a, const CustomFilterProgramInfo& b) { return a == b; }
- static const bool safeToCompareToEmptyOrDeleted = false;
-};
-
-struct CustomFilterProgramInfoHashTraits : WTF::SimpleClassHashTraits<CustomFilterProgramInfo> {
- static const bool hasIsEmptyValueFunction = true;
- static bool isEmptyValue(const CustomFilterProgramInfo& info) { return info.isEmptyValue(); }
-};
-
-} // namespace WebCore
-
-namespace WTF {
-
-template<> struct HashTraits<WebCore::CustomFilterProgramInfo> : WebCore::CustomFilterProgramInfoHashTraits { };
-template<> struct DefaultHash<WebCore::CustomFilterProgramInfo> {
- typedef WebCore::CustomFilterProgramInfoHash Hash;
-};
-
-}
-
-#endif // CustomFilterProgramInfo_h
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterRenderer.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterRenderer.cpp
deleted file mode 100644
index c8480321696..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterRenderer.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
- * Copyright (C) 2012 Company 100, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "platform/graphics/filters/custom/CustomFilterRenderer.h"
-
-#include "platform/graphics/GraphicsContext3D.h"
-#include "platform/graphics/filters/custom/CustomFilterArrayParameter.h"
-#include "platform/graphics/filters/custom/CustomFilterCompiledProgram.h"
-#include "platform/graphics/filters/custom/CustomFilterMesh.h"
-#include "platform/graphics/filters/custom/CustomFilterNumberParameter.h"
-#include "platform/graphics/filters/custom/CustomFilterParameter.h"
-#include "platform/graphics/filters/custom/CustomFilterTransformParameter.h"
-#include "platform/transforms/TransformationMatrix.h"
-
-namespace WebCore {
-
-static void orthogonalProjectionMatrix(TransformationMatrix& matrix, float left, float right, float bottom, float top)
-{
- ASSERT(matrix.isIdentity());
-
- float deltaX = right - left;
- float deltaY = top - bottom;
- if (!deltaX || !deltaY)
- return;
- matrix.setM11(2.0f / deltaX);
- matrix.setM41(-(right + left) / deltaX);
- matrix.setM22(2.0f / deltaY);
- matrix.setM42(-(top + bottom) / deltaY);
-
- // Use big enough near/far values, so that simple rotations of rather large objects will not
- // get clipped. 10000 should cover most of the screen resolutions.
- const float farValue = 10000;
- const float nearValue = -10000;
- matrix.setM33(-2.0f / (farValue - nearValue));
- matrix.setM43(- (farValue + nearValue) / (farValue - nearValue));
- matrix.setM44(1.0f);
-}
-
-PassRefPtr<CustomFilterRenderer> CustomFilterRenderer::create(PassRefPtr<GraphicsContext3D> context, CustomFilterProgramType programType, const CustomFilterParameterList& parameters,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType)
-{
- return adoptRef(new CustomFilterRenderer(context, programType, parameters, meshRows, meshColumns, meshType));
-}
-
-CustomFilterRenderer::CustomFilterRenderer(PassRefPtr<GraphicsContext3D> context, CustomFilterProgramType programType, const CustomFilterParameterList& parameters,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType)
- : m_context(context)
- , m_programType(programType)
- , m_parameters(parameters)
- , m_meshRows(meshRows)
- , m_meshColumns(meshColumns)
- , m_meshType(meshType)
-{
-}
-
-CustomFilterRenderer::~CustomFilterRenderer()
-{
-}
-
-bool CustomFilterRenderer::premultipliedAlpha() const
-{
- return m_programType == ProgramTypeBlendsElementTexture;
-}
-
-bool CustomFilterRenderer::programNeedsInputTexture() const
-{
- ASSERT(m_compiledProgram.get());
- return m_compiledProgram->samplerLocation() != -1;
-}
-
-void CustomFilterRenderer::draw(Platform3DObject inputTexture, const IntSize& size)
-{
- // FIXME: We would need something like CustomFilterRendererState that will contain the size and other parameters in the future. We should pass that to bindProgramBuffers instead of storing it.
- // https://bugs.webkit.org/show_bug.cgi?id=100107
- m_contextSize = size;
-
- bindProgramAndBuffers(inputTexture);
- m_context->drawElements(GL_TRIANGLES, m_mesh->indicesCount(), GL_UNSIGNED_SHORT, 0);
- unbindVertexAttributes();
-}
-
-void CustomFilterRenderer::setCompiledProgram(PassRefPtr<CustomFilterCompiledProgram> compiledProgram)
-{
- m_compiledProgram = compiledProgram;
-}
-
-bool CustomFilterRenderer::prepareForDrawing()
-{
- m_context->makeContextCurrent();
- if (!m_compiledProgram || !m_compiledProgram->isInitialized())
- return false;
- initializeMeshIfNeeded();
- return true;
-}
-
-void CustomFilterRenderer::initializeMeshIfNeeded()
-{
- if (m_mesh.get())
- return;
-
- // FIXME: Sharing the mesh would just save the time needed to upload it to the GPU, so I assume we could
- // benchmark that for performance.
- // https://bugs.webkit.org/show_bug.cgi?id=88429
- m_mesh = CustomFilterMesh::create(m_context.get(), m_meshColumns, m_meshRows, FloatRect(0, 0, 1, 1), m_meshType);
-}
-
-void CustomFilterRenderer::bindVertexAttribute(int attributeLocation, unsigned size, unsigned offset)
-{
- if (attributeLocation != -1) {
- m_context->vertexAttribPointer(attributeLocation, size, GL_FLOAT, false, m_mesh->bytesPerVertex(), offset);
- m_context->enableVertexAttribArray(attributeLocation);
- }
-}
-
-void CustomFilterRenderer::unbindVertexAttribute(int attributeLocation)
-{
- if (attributeLocation != -1)
- m_context->disableVertexAttribArray(attributeLocation);
-}
-
-void CustomFilterRenderer::bindProgramArrayParameters(int uniformLocation, CustomFilterArrayParameter* arrayParameter)
-{
- unsigned parameterSize = arrayParameter->size();
- Vector<GC3Dfloat> floatVector;
-
- for (unsigned i = 0; i < parameterSize; ++i)
- floatVector.append(arrayParameter->valueAt(i));
-
- m_context->uniform1fv(uniformLocation, parameterSize, floatVector.data());
-}
-
-void CustomFilterRenderer::bindProgramNumberParameters(int uniformLocation, CustomFilterNumberParameter* numberParameter)
-{
- switch (numberParameter->size()) {
- case 1:
- m_context->uniform1f(uniformLocation, numberParameter->valueAt(0));
- break;
- case 2:
- m_context->uniform2f(uniformLocation, numberParameter->valueAt(0), numberParameter->valueAt(1));
- break;
- case 3:
- m_context->uniform3f(uniformLocation, numberParameter->valueAt(0), numberParameter->valueAt(1), numberParameter->valueAt(2));
- break;
- case 4:
- m_context->uniform4f(uniformLocation, numberParameter->valueAt(0), numberParameter->valueAt(1), numberParameter->valueAt(2), numberParameter->valueAt(3));
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-}
-
-void CustomFilterRenderer::bindProgramTransformParameter(int uniformLocation, CustomFilterTransformParameter* transformParameter)
-{
- TransformationMatrix matrix;
- if (m_contextSize.width() && m_contextSize.height()) {
- // The viewport is a box with the size of 1 unit, so we are scaling up here to make sure that translations happen using real pixel
- // units. At the end we scale back down in order to map it back to the original box. Note that transforms come in reverse order, because it is
- // supposed to multiply to the left of the coordinates of the vertices.
- // Note that the origin (0, 0) of the viewport is in the middle of the context, so there's no need to change the origin of the transform
- // in order to rotate around the middle of mesh.
- matrix.scale3d(1.0 / m_contextSize.width(), 1.0 / m_contextSize.height(), 1);
- transformParameter->applyTransform(matrix, m_contextSize);
- matrix.scale3d(m_contextSize.width(), m_contextSize.height(), 1);
- }
- float glMatrix[16];
- matrix.toColumnMajorFloatArray(glMatrix);
- m_context->uniformMatrix4fv(uniformLocation, 1, false, &glMatrix[0]);
-}
-
-void CustomFilterRenderer::bindProgramParameters()
-{
- // FIXME: Find a way to reset uniforms that are not specified in CSS. This is needed to avoid using values
- // set by other previous rendered filters.
- // https://bugs.webkit.org/show_bug.cgi?id=76440
-
- size_t parametersSize = m_parameters.size();
- for (size_t i = 0; i < parametersSize; ++i) {
- CustomFilterParameter* parameter = m_parameters.at(i).get();
- int uniformLocation = m_compiledProgram->uniformLocationByName(parameter->name());
- if (uniformLocation == -1)
- continue;
- switch (parameter->parameterType()) {
- case CustomFilterParameter::Array:
- bindProgramArrayParameters(uniformLocation, static_cast<CustomFilterArrayParameter*>(parameter));
- break;
- case CustomFilterParameter::Number:
- bindProgramNumberParameters(uniformLocation, static_cast<CustomFilterNumberParameter*>(parameter));
- break;
- case CustomFilterParameter::Transform:
- bindProgramTransformParameter(uniformLocation, static_cast<CustomFilterTransformParameter*>(parameter));
- break;
- }
- }
-}
-
-void CustomFilterRenderer::bindProgramAndBuffers(Platform3DObject inputTexture)
-{
- ASSERT(m_compiledProgram->isInitialized());
-
- m_context->useProgram(m_compiledProgram->program());
-
- if (programNeedsInputTexture()) {
- // We should be binding the DOM element texture sampler only if the author is using the CSS mix function.
- ASSERT(m_programType == ProgramTypeBlendsElementTexture);
- ASSERT(m_compiledProgram->samplerLocation() != -1);
-
- m_context->activeTexture(GL_TEXTURE0);
- m_context->uniform1i(m_compiledProgram->samplerLocation(), 0);
- m_context->bindTexture(GL_TEXTURE_2D, inputTexture);
- m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- }
-
- if (m_compiledProgram->projectionMatrixLocation() != -1) {
- TransformationMatrix projectionMatrix;
- orthogonalProjectionMatrix(projectionMatrix, -0.5, 0.5, -0.5, 0.5);
- float glProjectionMatrix[16];
- projectionMatrix.toColumnMajorFloatArray(glProjectionMatrix);
- m_context->uniformMatrix4fv(m_compiledProgram->projectionMatrixLocation(), 1, false, &glProjectionMatrix[0]);
- }
-
- ASSERT(m_meshColumns);
- ASSERT(m_meshRows);
-
- if (m_compiledProgram->meshSizeLocation() != -1)
- m_context->uniform2f(m_compiledProgram->meshSizeLocation(), m_meshColumns, m_meshRows);
-
- if (m_compiledProgram->tileSizeLocation() != -1)
- m_context->uniform2f(m_compiledProgram->tileSizeLocation(), 1.0 / m_meshColumns, 1.0 / m_meshRows);
-
- if (m_compiledProgram->meshBoxLocation() != -1) {
- // FIXME: This will change when filter margins will be implemented,
- // see https://bugs.webkit.org/show_bug.cgi?id=71400
- m_context->uniform4f(m_compiledProgram->meshBoxLocation(), -0.5, -0.5, 1.0, 1.0);
- }
-
- if (m_compiledProgram->samplerSizeLocation() != -1)
- m_context->uniform2f(m_compiledProgram->samplerSizeLocation(), m_contextSize.width(), m_contextSize.height());
-
- m_context->bindBuffer(GL_ARRAY_BUFFER, m_mesh->verticesBufferObject());
- m_context->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_mesh->elementsBufferObject());
-
- bindVertexAttribute(m_compiledProgram->positionAttribLocation(), PositionAttribSize, PositionAttribOffset);
- bindVertexAttribute(m_compiledProgram->texAttribLocation(), TexAttribSize, TexAttribOffset);
- bindVertexAttribute(m_compiledProgram->meshAttribLocation(), MeshAttribSize, MeshAttribOffset);
- if (m_meshType == MeshTypeDetached)
- bindVertexAttribute(m_compiledProgram->triangleAttribLocation(), TriangleAttribSize, TriangleAttribOffset);
-
- bindProgramParameters();
-}
-
-void CustomFilterRenderer::unbindVertexAttributes()
-{
- unbindVertexAttribute(m_compiledProgram->positionAttribLocation());
- unbindVertexAttribute(m_compiledProgram->texAttribLocation());
- unbindVertexAttribute(m_compiledProgram->meshAttribLocation());
- if (m_meshType == MeshTypeDetached)
- unbindVertexAttribute(m_compiledProgram->triangleAttribLocation());
-}
-
-} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterRenderer.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterRenderer.h
deleted file mode 100644
index 059fc42a448..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterRenderer.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
- * Copyright (C) 2012 Company 100, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef CustomFilterRenderer_h
-#define CustomFilterRenderer_h
-
-#include "platform/geometry/IntSize.h"
-#include "platform/graphics/GraphicsTypes3D.h"
-#include "platform/graphics/filters/custom/CustomFilterConstants.h"
-#include "platform/graphics/filters/custom/CustomFilterParameterList.h"
-#include "wtf/RefCounted.h"
-#include "wtf/RefPtr.h"
-
-namespace WebCore {
-
-class CustomFilterArrayParameter;
-class CustomFilterCompiledProgram;
-class CustomFilterMesh;
-class CustomFilterNumberParameter;
-class CustomFilterTransformParameter;
-class GraphicsContext3D;
-
-class CustomFilterRenderer : public RefCounted<CustomFilterRenderer> {
-public:
- static PassRefPtr<CustomFilterRenderer> create(PassRefPtr<GraphicsContext3D>, CustomFilterProgramType, const CustomFilterParameterList&,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshType);
- ~CustomFilterRenderer();
-
- bool premultipliedAlpha() const;
- bool programNeedsInputTexture() const;
-
- bool prepareForDrawing();
-
- void draw(Platform3DObject, const IntSize&);
-
- CustomFilterCompiledProgram* compiledProgram() const { return m_compiledProgram.get(); }
- void setCompiledProgram(PassRefPtr<CustomFilterCompiledProgram>);
-
-private:
- CustomFilterRenderer(PassRefPtr<GraphicsContext3D>, CustomFilterProgramType, const CustomFilterParameterList&,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshType);
-
- void initializeCompiledProgramIfNeeded();
- void initializeMeshIfNeeded();
-
- void bindVertexAttribute(int attributeLocation, unsigned size, unsigned offset);
- void unbindVertexAttribute(int attributeLocation);
- void bindProgramArrayParameters(int uniformLocation, CustomFilterArrayParameter*);
- void bindProgramNumberParameters(int uniformLocation, CustomFilterNumberParameter*);
- void bindProgramTransformParameter(int uniformLocation, CustomFilterTransformParameter*);
- void bindProgramParameters();
- void bindProgramAndBuffers(Platform3DObject inputTexture);
- void unbindVertexAttributes();
-
- RefPtr<GraphicsContext3D> m_context;
- RefPtr<CustomFilterCompiledProgram> m_compiledProgram;
- CustomFilterProgramType m_programType;
- RefPtr<CustomFilterMesh> m_mesh;
- IntSize m_contextSize;
-
- CustomFilterParameterList m_parameters;
-
- unsigned m_meshRows;
- unsigned m_meshColumns;
- CustomFilterMeshType m_meshType;
-};
-
-} // namespace WebCore
-
-#endif // CustomFilterRenderer_h
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterTransformParameter.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterTransformParameter.cpp
deleted file mode 100644
index 317130288e1..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterTransformParameter.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "platform/graphics/filters/custom/CustomFilterTransformParameter.h"
-
-#include "platform/geometry/FloatSize.h"
-
-namespace WebCore {
-
-PassRefPtr<CustomFilterParameter> CustomFilterTransformParameter::blend(const CustomFilterParameter* fromParameter, double progress)
-{
- if (!fromParameter || !isSameType(*fromParameter))
- return this;
-
- const CustomFilterTransformParameter* fromTransformParameter = static_cast<const CustomFilterTransformParameter*>(fromParameter);
- const TransformOperations& from = fromTransformParameter->operations();
- const TransformOperations& to = operations();
- if (from == to)
- return this;
-
- RefPtr<CustomFilterTransformParameter> result = CustomFilterTransformParameter::create(name());
- if (from.size() && to.size())
- result->setOperations(to.blend(from, progress));
- else
- result->setOperations(progress > 0.5 ? to : from);
- return result;
-}
-
-bool CustomFilterTransformParameter::operator==(const CustomFilterParameter& o) const
-{
- if (!isSameType(o))
- return false;
- const CustomFilterTransformParameter* other = static_cast<const CustomFilterTransformParameter*>(&o);
- return m_operations == other->m_operations;
-}
-
-void CustomFilterTransformParameter::applyTransform(TransformationMatrix& transform, const FloatSize& boxSize) const
-{
- for (unsigned i = 0, size = m_operations.size(); i < size; ++i)
- m_operations.at(i)->apply(transform, boxSize);
-}
-
-} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterTransformParameter.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterTransformParameter.h
deleted file mode 100644
index 62dc58e05ea..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterTransformParameter.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef CustomFilterTransformParameter_h
-#define CustomFilterTransformParameter_h
-
-#include "platform/PlatformExport.h"
-#include "platform/graphics/filters/custom/CustomFilterParameter.h"
-#include "platform/transforms/TransformOperations.h"
-
-namespace WebCore {
-
-class FloatSize;
-class TransformationMatrix;
-
-class PLATFORM_EXPORT CustomFilterTransformParameter : public CustomFilterParameter {
-public:
- static PassRefPtr<CustomFilterTransformParameter> create(const String& name)
- {
- return adoptRef(new CustomFilterTransformParameter(name));
- }
-
- virtual PassRefPtr<CustomFilterParameter> blend(const CustomFilterParameter* fromParameter, double progress);
-
- virtual bool operator==(const CustomFilterParameter&) const;
-
- void applyTransform(TransformationMatrix&, const FloatSize& boxSize) const;
-
- const TransformOperations& operations() const { return m_operations; }
- void setOperations(const TransformOperations& value) { m_operations = value; }
-
-private:
- CustomFilterTransformParameter(const String& name)
- : CustomFilterParameter(Transform, name)
- {
- }
- virtual ~CustomFilterTransformParameter()
- {
- }
-
- TransformOperations m_operations;
-};
-
-} // namespace WebCore
-
-#endif // CustomFilterTransformParameter_h
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterValidatedProgram.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterValidatedProgram.cpp
deleted file mode 100644
index 63e384383be..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterValidatedProgram.cpp
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "platform/graphics/filters/custom/CustomFilterValidatedProgram.h"
-
-#include "platform/NotImplemented.h"
-#include "platform/graphics/angle/ANGLEPlatformBridge.h"
-#include "platform/graphics/filters/custom/CustomFilterConstants.h"
-#include "platform/graphics/filters/custom/CustomFilterGlobalContext.h"
-#include "wtf/HashMap.h"
-#include "wtf/Vector.h"
-#include "wtf/text/StringBuilder.h"
-#include "wtf/text/StringHash.h"
-
-namespace WebCore {
-
-#define SHADER(Src) (#Src)
-
-typedef HashMap<String, ShDataType> SymbolNameToTypeMap;
-
-static SymbolNameToTypeMap* builtInAttributeNameToTypeMap()
-{
- static SymbolNameToTypeMap* nameToTypeMap = 0;
- if (!nameToTypeMap) {
- nameToTypeMap = new SymbolNameToTypeMap;
- nameToTypeMap->set("a_meshCoord", SH_FLOAT_VEC2);
- nameToTypeMap->set("a_position", SH_FLOAT_VEC4);
- nameToTypeMap->set("a_texCoord", SH_FLOAT_VEC2);
- nameToTypeMap->set("a_triangleCoord", SH_FLOAT_VEC3);
- }
- return nameToTypeMap;
-}
-
-static SymbolNameToTypeMap* builtInUniformNameToTypeMap()
-{
- static SymbolNameToTypeMap* nameToTypeMap = 0;
- if (!nameToTypeMap) {
- nameToTypeMap = new SymbolNameToTypeMap;
- nameToTypeMap->set("u_meshBox", SH_FLOAT_VEC4);
- nameToTypeMap->set("u_meshSize", SH_FLOAT_VEC2);
- nameToTypeMap->set("u_projectionMatrix", SH_FLOAT_MAT4);
- nameToTypeMap->set("u_textureSize", SH_FLOAT_VEC2);
- nameToTypeMap->set("u_tileSize", SH_FLOAT_VEC2);
- }
- return nameToTypeMap;
-}
-
-static bool validateSymbols(const Vector<ANGLEShaderSymbol>& symbols, CustomFilterMeshType meshType)
-{
- for (size_t i = 0; i < symbols.size(); ++i) {
- const ANGLEShaderSymbol& symbol = symbols[i];
- switch (symbol.symbolType) {
- case SHADER_SYMBOL_TYPE_ATTRIBUTE: {
- SymbolNameToTypeMap* attributeNameToTypeMap = builtInAttributeNameToTypeMap();
- SymbolNameToTypeMap::iterator builtInAttribute = attributeNameToTypeMap->find(symbol.name);
- if (builtInAttribute == attributeNameToTypeMap->end()) {
- // The author defined a custom attribute.
- // FIXME: Report the validation error.
- // https://bugs.webkit.org/show_bug.cgi?id=74416
- return false;
- }
- if (meshType == MeshTypeAttached && symbol.name == "a_triangleCoord") {
- // a_triangleCoord is only available for detached meshes.
- // FIXME: Report the validation error.
- // https://bugs.webkit.org/show_bug.cgi?id=74416
- return false;
- }
- if (symbol.dataType != builtInAttribute->value) {
- // The author defined one of the built-in attributes with the wrong type.
- // FIXME: Report the validation error.
- // https://bugs.webkit.org/show_bug.cgi?id=74416
- return false;
- }
- break;
- }
- case SHADER_SYMBOL_TYPE_UNIFORM: {
- if (symbol.isSampler()) {
- // FIXME: For now, we restrict shaders with any sampler defined.
- // When we implement texture parameters, we will allow shaders whose samplers are bound to valid textures.
- // We must not allow OpenGL to give unbound samplers a default value of 0 because that references the element texture,
- // which should be inaccessible to the author's shader code.
- // https://bugs.webkit.org/show_bug.cgi?id=96230
- return false;
- }
-
- SymbolNameToTypeMap* uniformNameToTypeMap = builtInUniformNameToTypeMap();
- SymbolNameToTypeMap::iterator builtInUniform = uniformNameToTypeMap->find(symbol.name);
- if (builtInUniform != uniformNameToTypeMap->end() && (symbol.isArray || symbol.dataType != builtInUniform->value)) {
- // The author defined one of the built-in uniforms with the wrong type.
- // FIXME: Report the validation error.
- // https://bugs.webkit.org/show_bug.cgi?id=74416
- return false;
- }
- break;
- }
- default:
- ASSERT_NOT_REACHED();
- break;
- }
- }
-
- return true;
-}
-
-String CustomFilterValidatedProgram::defaultVertexShaderString()
-{
- DEFINE_STATIC_LOCAL(String, vertexShaderString, (SHADER(
- attribute mediump vec4 a_position;
- uniform mediump mat4 u_projectionMatrix;
-
- void main()
- {
- gl_Position = u_projectionMatrix * a_position;
- }
- )));
- return vertexShaderString;
-}
-
-String CustomFilterValidatedProgram::defaultFragmentShaderString()
-{
- DEFINE_STATIC_LOCAL(String, fragmentShaderString, (SHADER(
- void main()
- {
- }
- )));
- return fragmentShaderString;
-}
-
-CustomFilterValidatedProgram::CustomFilterValidatedProgram(CustomFilterGlobalContext* globalContext, const CustomFilterProgramInfo& programInfo)
- : m_globalContext(globalContext)
- , m_programInfo(programInfo)
- , m_isInitialized(false)
-{
- platformInit();
-
- String originalVertexShader = programInfo.vertexShaderString();
- if (originalVertexShader.isNull())
- originalVertexShader = defaultVertexShaderString();
-
- String originalFragmentShader = programInfo.fragmentShaderString();
- if (originalFragmentShader.isNull())
- originalFragmentShader = defaultFragmentShaderString();
-
- // Shaders referenced from the CSS mix function use a different validator than regular WebGL shaders. See core/platform/graphics/filters/custom/CustomFilterGlobalContext.h for more details.
- bool blendsElementTexture = (programInfo.programType() == ProgramTypeBlendsElementTexture);
- ANGLEPlatformBridge* validator = blendsElementTexture ? m_globalContext->mixShaderValidator() : m_globalContext->webglShaderValidator();
- String vertexShaderLog, fragmentShaderLog;
- Vector<ANGLEShaderSymbol> symbols;
- bool vertexShaderValid = validator->compileShaderSource(originalVertexShader.utf8().data(), SHADER_TYPE_VERTEX, m_validatedVertexShader, vertexShaderLog, symbols);
- bool fragmentShaderValid = validator->compileShaderSource(originalFragmentShader.utf8().data(), SHADER_TYPE_FRAGMENT, m_validatedFragmentShader, fragmentShaderLog, symbols);
- if (!vertexShaderValid || !fragmentShaderValid) {
- // FIXME: Report the validation errors.
- // https://bugs.webkit.org/show_bug.cgi?id=74416
- return;
- }
-
- if (!validateSymbols(symbols, m_programInfo.meshType())) {
- // FIXME: Report validation errors.
- // https://bugs.webkit.org/show_bug.cgi?id=74416
- return;
- }
-
- // We need to add texture access, blending, and compositing code to shaders that are referenced from the CSS mix function.
- if (blendsElementTexture) {
- rewriteMixVertexShader(symbols);
- rewriteMixFragmentShader();
- }
-
- m_isInitialized = true;
-}
-
-PassRefPtr<CustomFilterCompiledProgram> CustomFilterValidatedProgram::compiledProgram()
-{
- ASSERT(m_isInitialized && m_globalContext && !m_validatedVertexShader.isNull() && !m_validatedFragmentShader.isNull());
- if (!m_compiledProgram) {
- m_compiledProgram = CustomFilterCompiledProgram::create(m_globalContext->context(), m_validatedVertexShader, m_validatedFragmentShader, m_programInfo.programType());
- ASSERT(m_compiledProgram->isInitialized());
- ASSERT(m_compiledProgram->samplerLocation() != -1 || !needsInputTexture());
- }
- return m_compiledProgram;
-}
-
-bool CustomFilterValidatedProgram::needsInputTexture() const
-{
- return m_programInfo.programType() == ProgramTypeBlendsElementTexture
- && m_programInfo.mixSettings().compositeOperator != CompositeClear
- && m_programInfo.mixSettings().compositeOperator != CompositeCopy;
-}
-
-void CustomFilterValidatedProgram::rewriteMixVertexShader(const Vector<ANGLEShaderSymbol>& symbols)
-{
- ASSERT(m_programInfo.programType() == ProgramTypeBlendsElementTexture);
-
- // If the author defined a_texCoord, we can use it to shuttle the texture coordinate to the fragment shader.
- // Note that vertex attributes are read-only in GLSL, so the author could not have changed a_texCoord's value.
- // Also, note that we would have already rejected the shader if the author defined a_texCoord with the wrong type.
- bool texCoordAttributeDefined = false;
- for (size_t i = 0; i < symbols.size(); ++i) {
- if (symbols[i].name == "a_texCoord")
- texCoordAttributeDefined = true;
- }
-
- if (!texCoordAttributeDefined)
- m_validatedVertexShader.append("attribute mediump vec2 a_texCoord;");
-
- // During validation, ANGLE renamed the author's "main" function to "css_main".
- // We write our own "main" function and call "css_main" from it.
- // This makes rewriting easy and ensures that our code runs after all author code.
- m_validatedVertexShader.append(SHADER(
- varying mediump vec2 css_v_texCoord;
-
- void main()
- {
- css_main();
- css_v_texCoord = a_texCoord;
- }
- ));
-}
-
-void CustomFilterValidatedProgram::rewriteMixFragmentShader()
-{
- ASSERT(m_programInfo.programType() == ProgramTypeBlendsElementTexture);
-
- StringBuilder builder;
- // ANGLE considered these symbols as built-ins during validation under the SH_CSS_SHADERS_SPEC flag.
- // Now, we have to define these symbols in order to make this shader valid GLSL.
- // We define these symbols before the author's shader code, which makes them accessible to author code.
- builder.append(SHADER(
- mediump vec4 css_MixColor = vec4(0.0);
- mediump mat4 css_ColorMatrix = mat4(1.0);
- ));
- builder.append(m_validatedFragmentShader);
- builder.append(blendFunctionString(m_programInfo.mixSettings().blendMode));
- builder.append(compositeFunctionString(m_programInfo.mixSettings().compositeOperator));
- // We define symbols like "css_u_texture" after the author's shader code, which makes them inaccessible to author code.
- // In particular, "css_u_texture" represents the DOM element texture, so it's important to keep it inaccessible to
- // author code for security reasons.
- builder.append(SHADER(
- uniform sampler2D css_u_texture;
- varying mediump vec2 css_v_texCoord;
-
- void main()
- {
- css_main();
- mediump vec4 originalColor = texture2D(css_u_texture, css_v_texCoord);
- mediump vec4 multipliedColor = clamp(css_ColorMatrix * originalColor, 0.0, 1.0);
- mediump vec4 clampedMixColor = clamp(css_MixColor, 0.0, 1.0);
- mediump vec3 blendedColor = css_BlendColor(multipliedColor.rgb, clampedMixColor.rgb);
- mediump vec3 weightedColor = (1.0 - multipliedColor.a) * clampedMixColor.rgb + multipliedColor.a * blendedColor;
- gl_FragColor = css_Composite(multipliedColor.rgb, multipliedColor.a, weightedColor.rgb, clampedMixColor.a);
- }
- ));
- m_validatedFragmentShader = builder.toString();
-}
-
-String CustomFilterValidatedProgram::blendFunctionString(blink::WebBlendMode blendMode)
-{
- // Implemented using the same symbol names as the Compositing and Blending spec:
- // https://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html#blendingnormal
- // Cs: is the source color in css_BlendColor() and the source color component in css_BlendComponent()
- // Cb: is the backdrop color in css_BlendColor() and the backdrop color component in css_BlendComponent()
- const char* blendColorExpression = "vec3(css_BlendComponent(Cb.r, Cs.r), css_BlendComponent(Cb.g, Cs.g), css_BlendComponent(Cb.b, Cs.b))";
- const char* blendComponentExpression = "Co = 0.0;";
- bool needsLuminosityHelperFunctions = false;
- bool needsSaturationHelperFunctions = false;
- String blendFunctionString;
- switch (blendMode) {
- case blink::WebBlendModeNormal:
- blendColorExpression = "Cs";
- break;
- case blink::WebBlendModeMultiply:
- blendColorExpression = "Cs * Cb";
- break;
- case blink::WebBlendModeScreen:
- blendColorExpression = "Cb + Cs - (Cb * Cs)";
- break;
- case blink::WebBlendModeDarken:
- blendColorExpression = "min(Cb, Cs)";
- break;
- case blink::WebBlendModeLighten:
- blendColorExpression = "max(Cb, Cs)";
- break;
- case blink::WebBlendModeDifference:
- blendColorExpression = "abs(Cb - Cs)";
- break;
- case blink::WebBlendModeExclusion:
- blendColorExpression = "Cb + Cs - 2.0 * Cb * Cs";
- break;
- case blink::WebBlendModeOverlay:
- /*
- Co = HardLight(Cs, Cb)
- = if(Cb <= 0.5)
- Multiply(Cs, 2 x Cb)
- else
- Screen(Cs, 2 x Cb - 1)
- = if(Cb <= 0.5)
- Cs x (2 x Cb)
- else
- Cs + (2 x Cb - 1) - (Cs x (2 x Cb - 1))
- */
- blendComponentExpression = SHADER(
- if (Cb <= 0.5)
- Co = Cs * (2.0 * Cb);
- else
- Co = Cs + (2.0 * Cb - 1.0) - (Cs * (2.0 * Cb - 1.0));
- );
- break;
- case blink::WebBlendModeColorDodge:
- /*
- Co = if(Cs < 1)
- min(1, Cb / (1 - Cs))
- else
- 1
- */
- blendComponentExpression = SHADER(
- if (Cs < 1.0)
- Co = min(1.0, Cb / (1.0 - Cs));
- else
- Co = 1.0;
- );
- break;
- case blink::WebBlendModeColorBurn:
- /*
- Co = if(Cs > 0)
- 1 - min(1, (1 - Cb) / Cs)
- else
- 0
- */
- blendComponentExpression = SHADER(
- if (Cs > 0.0)
- Co = 1.0 - min(1.0, (1.0 - Cb) / Cs);
- else
- Co = 0.0;
- );
- break;
- case blink::WebBlendModeHardLight:
- /*
- Co = if(Cs <= 0.5)
- Multiply(Cb, 2 x Cs)
- else
- Screen(Cb, 2 x Cs -1)
- = if(Cs <= 0.5)
- Cb x (2 x Cs)
- else
- Cb + (2 x Cs - 1) - (Cb x (2 x Cs - 1))
- */
- blendComponentExpression = SHADER(
- if (Cs <= 0.5)
- Co = Cb * (2.0 * Cs);
- else
- Co = Cb + (2.0 * Cs - 1.0) - (Cb * (2.0 * Cs - 1.0));
- );
- break;
- case blink::WebBlendModeSoftLight:
- /*
- Co = if(Cs <= 0.5)
- Cb - (1 - 2 x Cs) x Cb x (1 - Cb)
- else
- Cb + (2 x Cs - 1) x (D(Cb) - Cb)
-
- with
-
- D(Cb) = if(Cb <= 0.25)
- (16 * Cb - 12) x Cb + 4) x Cb
- else
- sqrt(Cb)
- */
- blendComponentExpression = SHADER(
- mediump float D;
- if (Cb <= 0.25)
- D = ((16.0 * Cb - 12.0) * Cb + 4.0) * Cb;
- else
- D = sqrt(Cb);
-
- if (Cs <= 0.5)
- Co = Cb - (1.0 - 2.0 * Cs) * Cb * (1.0 - Cb);
- else
- Co = Cb + (2.0 * Cs - 1.0) * (D - Cb);
- );
- break;
- case blink::WebBlendModeColor:
- needsLuminosityHelperFunctions = true;
- blendColorExpression = "css_SetLum(Cs, css_Lum(Cb))";
- break;
- case blink::WebBlendModeLuminosity:
- needsLuminosityHelperFunctions = true;
- blendColorExpression = "css_SetLum(Cb, css_Lum(Cs))";
- break;
- case blink::WebBlendModeHue:
- needsLuminosityHelperFunctions = true;
- needsSaturationHelperFunctions = true;
- blendColorExpression = "css_SetLum(css_SetSat(Cs, css_Sat(Cb)), css_Lum(Cb))";
- break;
- case blink::WebBlendModeSaturation:
- needsLuminosityHelperFunctions = true;
- needsSaturationHelperFunctions = true;
- blendColorExpression = "css_SetLum(css_SetSat(Cb, css_Sat(Cs)), css_Lum(Cb))";
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-
- if (needsLuminosityHelperFunctions) {
- blendFunctionString.append(SHADER(
- mediump float css_Lum(mediump vec3 C)
- {
- return 0.3 * C.r + 0.59 * C.g + 0.11 * C.b;
- }
- mediump vec3 css_ClipColor(mediump vec3 C)
- {
- mediump float L = css_Lum(C);
- mediump float n = min(min(C.r, C.g), C.b);
- mediump float x = max(max(C.r, C.g), C.b);
- if (n < 0.0)
- C = L + (((C - L) * L) / (L - n));
- if (x > 1.0)
- C = L + (((C - L) * (1.0 - L) / (x - L)));
- return C;
- }
- mediump vec3 css_SetLum(mediump vec3 C, mediump float l)
- {
- C += l - css_Lum(C);
- return css_ClipColor(C);
- }
- ));
- }
-
- if (needsSaturationHelperFunctions) {
- blendFunctionString.append(SHADER(
- mediump float css_Sat(mediump vec3 C)
- {
- mediump float cMin = min(min(C.r, C.g), C.b);
- mediump float cMax = max(max(C.r, C.g), C.b);
- return cMax - cMin;
- }
- void css_SetSatHelper(inout mediump float cMin, inout mediump float cMid, inout mediump float cMax, mediump float s)
- {
- if (cMax > cMin) {
- cMid = (((cMid - cMin) * s) / (cMax - cMin));
- cMax = s;
- } else {
- cMid = cMax = 0.0;
- }
- cMin = 0.0;
- }
- mediump vec3 css_SetSat(mediump vec3 C, mediump float s)
- {
- if (C.r <= C.g) {
- if (C.g <= C.b) {
- css_SetSatHelper(C.r, C.g, C.b, s);
- } else {
- if (C.r <= C.b)
- css_SetSatHelper(C.r, C.b, C.g, s);
- else
- css_SetSatHelper(C.b, C.r, C.g, s);
- }
- } else {
- if (C.r <= C.b) {
- css_SetSatHelper(C.g, C.r, C.b, s);
- } else {
- if (C.g <= C.b)
- css_SetSatHelper(C.g, C.b, C.r, s);
- else
- css_SetSatHelper(C.b, C.g, C.r, s);
- }
- }
- return C;
- }
- ));
- }
-
- blendFunctionString.append(String::format(SHADER(
- mediump float css_BlendComponent(mediump float Cb, mediump float Cs)
- {
- mediump float Co;
- %s
- return Co;
- }
- mediump vec3 css_BlendColor(mediump vec3 Cb, mediump vec3 Cs)
- {
- return %s;
- }
- ), blendComponentExpression, blendColorExpression));
-
- return blendFunctionString;
-}
-
-String CustomFilterValidatedProgram::compositeFunctionString(CompositeOperator compositeOperator)
-{
- // Use the same symbol names as the Compositing and Blending spec:
- // https://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html#blendingnormal
- // Cs: is the source color
- // Cb: is the backdrop color
- // as: is the source alpha
- // ab: is the backdrop alpha
- // Fa: is defined by the Porter Duff operator in use
- // Fb: is defined by the Porter Duff operator in use
- const char* Fa = 0;
- const char* Fb = 0;
- switch (compositeOperator) {
- case CompositeSourceAtop:
- Fa = "ab";
- Fb = "1.0 - as";
- break;
- case CompositeClear:
- Fa = "0.0";
- Fb = "0.0";
- break;
- case CompositeCopy:
- Fa = "1.0";
- Fb = "0.0";
- break;
- case CompositeSourceOver:
- Fa = "1.0";
- Fb = "1.0 - as";
- break;
- case CompositeSourceIn:
- Fa = "ab";
- Fb = "0.0";
- break;
- case CompositeSourceOut:
- Fa = "1.0 - ab";
- Fb = "0.0";
- break;
- case CompositeDestinationOver:
- Fa = "1.0 - ab";
- Fb = "1.0";
- break;
- case CompositeDestinationIn:
- Fa = "0.0";
- Fb = "as";
- break;
- case CompositeDestinationOut:
- Fa = "0.0";
- Fb = "1.0 - as";
- break;
- case CompositeDestinationAtop:
- Fa = "1.0 - ab";
- Fb = "as";
- break;
- case CompositeXOR:
- Fa = "1.0 - ab";
- Fb = "1.0 - as";
- break;
- case CompositePlusLighter:
- notImplemented();
- return String();
- default:
- // The CSS parser should not have accepted any other composite operators.
- ASSERT_NOT_REACHED();
- return String();
- }
-
- ASSERT(Fa && Fb);
- // Use the general formula for compositing, lifted from the spec:
- // https://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html#generalformula
- return String::format(SHADER(
- mediump vec4 css_Composite(mediump vec3 Cb, mediump float ab, mediump vec3 Cs, mediump float as)
- {
- mediump float Fa = %s;
- mediump float Fb = %s;
- return vec4(as * Fa * Cs + ab * Fb * Cb, as * Fa + ab * Fb);
- }
- ), Fa, Fb);
-}
-
-CustomFilterValidatedProgram::~CustomFilterValidatedProgram()
-{
- platformDestroy();
-
- if (m_globalContext)
- m_globalContext->removeValidatedProgram(this);
-}
-
-CustomFilterProgramInfo CustomFilterValidatedProgram::validatedProgramInfo() const
-{
- ASSERT(m_isInitialized);
- return CustomFilterProgramInfo(m_validatedVertexShader, m_validatedFragmentShader, m_programInfo.programType(), m_programInfo.mixSettings(), m_programInfo.meshType());
-}
-
-void CustomFilterValidatedProgram::platformInit()
-{
-}
-
-void CustomFilterValidatedProgram::platformDestroy()
-{
-}
-
-} // namespace WebCore
-
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterValidatedProgram.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterValidatedProgram.h
deleted file mode 100644
index fed78481ae8..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/CustomFilterValidatedProgram.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef CustomFilterValidatedProgram_h
-#define CustomFilterValidatedProgram_h
-
-#include "platform/graphics/filters/custom/CustomFilterCompiledProgram.h"
-#include "platform/graphics/filters/custom/CustomFilterProgramInfo.h"
-#include "wtf/PassRefPtr.h"
-#include "wtf/RefCounted.h"
-#include "wtf/RefPtr.h"
-#include "wtf/text/WTFString.h"
-
-// PlatformCompiledProgram defines a type that is compatible with the framework used to implement accelerated compositing on a particular platform.
-namespace WebCore {
-
-struct ANGLEShaderSymbol;
-class CustomFilterCompiledProgram;
-class CustomFilterGlobalContext;
-
-//
-// A unique combination of vertex shader and fragment shader is only validated and compiled once.
-// All shaders are validated through ANGLE in CustomFilterValidatedProgram before being compiled by the GraphicsContext3D in CustomFilterCompiledProgram.
-// For shaders that use the CSS mix function, CustomFilterValidatedProgram adds shader code to perform DOM texture access, blending, and compositing.
-//
-// The CustomFilterGlobalContext caches the validated programs.
-// CustomFilterValidatedProgram owns a CustomFilterCompiledProgram if validation and compilation succeeds.
-// Thus, compiled programs are cached via their validated program owners.
-//
-// CustomFilterGlobalContext has a weak reference to the CustomFilterValidatedProgram.
-// Thus, the CustomFilterValidatedProgram destructor needs to notify the CustomFilterGlobalContext to remove the program from the cache.
-// FECustomFilter is the reference owner of the CustomFilterValidatedProgram.
-// Thus, a validated and compiled shader is only kept alive as long as there is at least one visible layer that applies the shader.
-//
-class PLATFORM_EXPORT CustomFilterValidatedProgram : public RefCounted<CustomFilterValidatedProgram> {
-public:
- static PassRefPtr<CustomFilterValidatedProgram> create(CustomFilterGlobalContext* globalContext, const CustomFilterProgramInfo& programInfo)
- {
- return adoptRef(new CustomFilterValidatedProgram(globalContext, programInfo));
- }
-
- ~CustomFilterValidatedProgram();
-
- const CustomFilterProgramInfo& programInfo() const { return m_programInfo; }
- CustomFilterProgramInfo validatedProgramInfo() const;
-
- PassRefPtr<CustomFilterCompiledProgram> compiledProgram();
-
- const String& validatedVertexShader() const
- {
- ASSERT(m_isInitialized);
- return m_validatedVertexShader;
- }
-
- const String& validatedFragmentShader() const
- {
- ASSERT(m_isInitialized);
- return m_validatedFragmentShader;
- }
-
- bool isInitialized() const { return m_isInitialized; }
-
- // 'detachFromGlobalContext' is called when the CustomFilterGlobalContext is deleted, and there's no need for the callback anymore.
- // Note that CustomFilterGlobalContext does not keep a strong reference to the CustomFilterValidatedProgram.
- void detachFromGlobalContext() { m_globalContext = 0; }
-private:
- CustomFilterValidatedProgram(CustomFilterGlobalContext*, const CustomFilterProgramInfo&);
-
- void platformInit();
- void platformDestroy();
-
- static String defaultVertexShaderString();
- static String defaultFragmentShaderString();
-
- static String blendFunctionString(blink::WebBlendMode);
- static String compositeFunctionString(CompositeOperator);
-
- void rewriteMixVertexShader(const Vector<ANGLEShaderSymbol>& symbols);
- void rewriteMixFragmentShader();
-
- bool needsInputTexture() const;
-
- CustomFilterGlobalContext* m_globalContext;
- CustomFilterProgramInfo m_programInfo;
-
- String m_validatedVertexShader;
- String m_validatedFragmentShader;
-
- RefPtr<CustomFilterCompiledProgram> m_compiledProgram;
-
- bool m_isInitialized;
-};
-
-}
-
-
-#endif
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/FECustomFilter.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/FECustomFilter.cpp
deleted file mode 100644
index bcce901401a..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/FECustomFilter.cpp
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
- * Copyright (C) 2013 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "platform/graphics/filters/custom/FECustomFilter.h"
-
-#include "platform/graphics/Extensions3D.h"
-#include "platform/graphics/GraphicsContext3D.h"
-#include "platform/graphics/filters/custom/CustomFilterRenderer.h"
-#include "platform/graphics/filters/custom/CustomFilterValidatedProgram.h"
-#include "platform/text/TextStream.h"
-#include "wtf/Uint8ClampedArray.h"
-
-namespace WebCore {
-
-FECustomFilter::FECustomFilter(Filter* filter, PassRefPtr<GraphicsContext3D> context, PassRefPtr<CustomFilterValidatedProgram> validatedProgram, const CustomFilterParameterList& parameters,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType)
- : FilterEffect(filter)
- , m_context(context)
- , m_validatedProgram(validatedProgram)
- , m_inputTexture(0)
- , m_frameBuffer(0)
- , m_depthBuffer(0)
- , m_destTexture(0)
- , m_triedMultisampleBuffer(false)
- , m_multisampleFrameBuffer(0)
- , m_multisampleRenderBuffer(0)
- , m_multisampleDepthBuffer(0)
-{
- // We will not pass a CustomFilterCompiledProgram here, as we only want to compile it when we actually need it in the first paint.
- m_customFilterRenderer = CustomFilterRenderer::create(m_context, m_validatedProgram->programInfo().programType(), parameters, meshRows, meshColumns, meshType);
-}
-
-PassRefPtr<FECustomFilter> FECustomFilter::create(Filter* filter, PassRefPtr<GraphicsContext3D> context, PassRefPtr<CustomFilterValidatedProgram> validatedProgram, const CustomFilterParameterList& parameters,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType)
-{
- return adoptRef(new FECustomFilter(filter, context, validatedProgram, parameters, meshRows, meshColumns, meshType));
-}
-
-FECustomFilter::~FECustomFilter()
-{
- deleteRenderBuffers();
-}
-
-void FECustomFilter::deleteRenderBuffers()
-{
- ASSERT(m_context);
- m_context->makeContextCurrent();
- if (m_inputTexture) {
- m_context->deleteTexture(m_inputTexture);
- m_inputTexture = 0;
- }
- if (m_frameBuffer) {
- // Make sure to unbind any framebuffer from the context first, otherwise
- // some platforms might refuse to bind the same buffer id again.
- m_context->bindFramebuffer(GL_FRAMEBUFFER, 0);
- m_context->deleteFramebuffer(m_frameBuffer);
- m_frameBuffer = 0;
- }
- if (m_depthBuffer) {
- m_context->deleteRenderbuffer(m_depthBuffer);
- m_depthBuffer = 0;
- }
- if (m_destTexture) {
- m_context->deleteTexture(m_destTexture);
- m_destTexture = 0;
- }
- deleteMultisampleRenderBuffers();
-}
-
-void FECustomFilter::deleteMultisampleRenderBuffers()
-{
- if (m_multisampleFrameBuffer) {
- // Make sure to unbind any framebuffer from the context first, otherwise
- // some platforms might refuse to bind the same buffer id again.
- m_context->bindFramebuffer(GL_FRAMEBUFFER, 0);
- m_context->deleteFramebuffer(m_multisampleFrameBuffer);
- m_multisampleFrameBuffer = 0;
- }
- if (m_multisampleRenderBuffer) {
- m_context->deleteRenderbuffer(m_multisampleRenderBuffer);
- m_multisampleRenderBuffer = 0;
- }
- if (m_multisampleDepthBuffer) {
- m_context->deleteRenderbuffer(m_multisampleDepthBuffer);
- m_multisampleDepthBuffer = 0;
- }
-}
-
-void FECustomFilter::applySoftware()
-{
- if (!applyShader())
- clearShaderResult();
-}
-
-void FECustomFilter::clearShaderResult()
-{
- clearResult();
- Uint8ClampedArray* dstPixelArray = createUnmultipliedImageResult();
- if (!dstPixelArray)
- return;
-
- FilterEffect* in = inputEffect(0);
- setIsAlphaImage(in->isAlphaImage());
- IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
- in->copyUnmultipliedImage(dstPixelArray, effectDrawingRect);
-}
-
-void FECustomFilter::drawFilterMesh(Platform3DObject inputTexture)
-{
- bool multisample = canUseMultisampleBuffers();
- m_context->bindFramebuffer(GL_FRAMEBUFFER, multisample ? m_multisampleFrameBuffer : m_frameBuffer);
- m_context->viewport(0, 0, m_contextSize.width(), m_contextSize.height());
-
- m_context->clearColor(0, 0, 0, 0);
- m_context->clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- m_customFilterRenderer->draw(inputTexture, m_contextSize);
-
- if (multisample)
- resolveMultisampleBuffer();
-}
-
-bool FECustomFilter::prepareForDrawing()
-{
- m_context->makeContextCurrent();
-
- // Lazily inject the compiled program into the CustomFilterRenderer.
- if (!m_customFilterRenderer->compiledProgram())
- m_customFilterRenderer->setCompiledProgram(m_validatedProgram->compiledProgram());
-
- if (!m_customFilterRenderer->prepareForDrawing())
- return false;
-
- // Only allocate a texture if the program needs one and the caller doesn't allocate one by itself.
- if ((m_customFilterRenderer->programNeedsInputTexture() && !ensureInputTexture()) || !ensureFrameBuffer())
- return false;
-
- return true;
-}
-
-bool FECustomFilter::applyShader()
-{
- Uint8ClampedArray* dstPixelArray = m_customFilterRenderer->premultipliedAlpha() ? createPremultipliedImageResult() : createUnmultipliedImageResult();
- if (!dstPixelArray)
- return false;
-
- if (!prepareForDrawing())
- return false;
-
- FilterEffect* in = inputEffect(0);
- IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
- IntSize newContextSize(effectDrawingRect.size());
- if (!resizeContextIfNeeded(newContextSize))
- return false;
-
- bool needsInputTexture = m_customFilterRenderer->programNeedsInputTexture();
- if (needsInputTexture) {
- RefPtr<Uint8ClampedArray> srcPixelArray = in->asUnmultipliedImage(effectDrawingRect);
- uploadInputTexture(srcPixelArray.get());
- }
- drawFilterMesh(needsInputTexture ? m_inputTexture : 0);
-
- ASSERT(static_cast<size_t>(newContextSize.width() * newContextSize.height() * 4) == dstPixelArray->length());
- m_context->readPixels(0, 0, newContextSize.width(), newContextSize.height(), GL_RGBA, GL_UNSIGNED_BYTE, dstPixelArray->data());
-
- return true;
-}
-
-bool FECustomFilter::ensureInputTexture()
-{
- if (!m_inputTexture)
- m_inputTexture = m_context->createTexture();
- return m_inputTexture;
-}
-
-void FECustomFilter::uploadInputTexture(Uint8ClampedArray* srcPixelArray)
-{
- m_context->bindTexture(GL_TEXTURE_2D, m_inputTexture);
- m_context->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_contextSize.width(), m_contextSize.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, srcPixelArray->data());
-}
-
-bool FECustomFilter::ensureFrameBuffer()
-{
- if (!m_frameBuffer)
- m_frameBuffer = m_context->createFramebuffer();
- if (!m_depthBuffer)
- m_depthBuffer = m_context->createRenderbuffer();
- if (!m_destTexture)
- m_destTexture = m_context->createTexture();
- return m_frameBuffer && m_depthBuffer && m_destTexture;
-}
-
-bool FECustomFilter::createMultisampleBuffer()
-{
- ASSERT(!m_triedMultisampleBuffer);
- m_triedMultisampleBuffer = true;
-
- Extensions3D* extensions = m_context->extensions();
- if (!extensions
- || !extensions->supports("GL_ANGLE_framebuffer_multisample")
- || !extensions->supports("GL_ANGLE_framebuffer_blit")
- || !extensions->supports("GL_OES_rgb8_rgba8"))
- return false;
-
- extensions->ensureEnabled("GL_ANGLE_framebuffer_blit");
- extensions->ensureEnabled("GL_ANGLE_framebuffer_multisample");
- extensions->ensureEnabled("GL_OES_rgb8_rgba8");
-
- if (!m_multisampleFrameBuffer)
- m_multisampleFrameBuffer = m_context->createFramebuffer();
- if (!m_multisampleRenderBuffer)
- m_multisampleRenderBuffer = m_context->createRenderbuffer();
- if (!m_multisampleDepthBuffer)
- m_multisampleDepthBuffer = m_context->createRenderbuffer();
-
- return true;
-}
-
-void FECustomFilter::resolveMultisampleBuffer()
-{
- ASSERT(m_triedMultisampleBuffer && m_multisampleFrameBuffer && m_multisampleRenderBuffer && m_multisampleDepthBuffer);
- m_context->bindFramebuffer(Extensions3D::READ_FRAMEBUFFER, m_multisampleFrameBuffer);
- m_context->bindFramebuffer(Extensions3D::DRAW_FRAMEBUFFER, m_frameBuffer);
-
- ASSERT(m_context->extensions());
- m_context->extensions()->blitFramebuffer(0, 0, m_contextSize.width(), m_contextSize.height(), 0, 0, m_contextSize.width(), m_contextSize.height(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
-
- m_context->bindFramebuffer(Extensions3D::READ_FRAMEBUFFER, 0);
- m_context->bindFramebuffer(Extensions3D::DRAW_FRAMEBUFFER, 0);
-
- m_context->bindFramebuffer(GL_FRAMEBUFFER, m_frameBuffer);
-}
-
-bool FECustomFilter::canUseMultisampleBuffers() const
-{
- return m_triedMultisampleBuffer && m_multisampleFrameBuffer && m_multisampleRenderBuffer && m_multisampleDepthBuffer;
-}
-
-bool FECustomFilter::resizeMultisampleBuffers(const IntSize& newContextSize)
-{
- if (!m_triedMultisampleBuffer && !createMultisampleBuffer())
- return false;
-
- if (!canUseMultisampleBuffers())
- return false;
-
- static const int kMaxSampleCount = 4;
- int maxSupportedSampleCount = 0;
- m_context->getIntegerv(Extensions3D::MAX_SAMPLES, &maxSupportedSampleCount);
- int sampleCount = std::min(kMaxSampleCount, maxSupportedSampleCount);
- if (!sampleCount) {
- deleteMultisampleRenderBuffers();
- return false;
- }
-
- Extensions3D* extensions = m_context->extensions();
- ASSERT(extensions);
-
- m_context->bindFramebuffer(GL_FRAMEBUFFER, m_multisampleFrameBuffer);
-
- m_context->bindRenderbuffer(GL_RENDERBUFFER, m_multisampleRenderBuffer);
- extensions->renderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, Extensions3D::RGBA8_OES, newContextSize.width(), newContextSize.height());
- m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_multisampleRenderBuffer);
-
- m_context->bindRenderbuffer(GL_RENDERBUFFER, m_multisampleDepthBuffer);
- extensions->renderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, GL_DEPTH_COMPONENT16, newContextSize.width(), newContextSize.height());
- m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_multisampleDepthBuffer);
-
- m_context->bindRenderbuffer(GL_RENDERBUFFER, 0);
-
- if (m_context->checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
- deleteMultisampleRenderBuffers();
- return false;
- }
-
- return true;
-}
-
-bool FECustomFilter::resizeContextIfNeeded(const IntSize& newContextSize)
-{
- if (newContextSize.isEmpty())
- return false;
- if (m_contextSize == newContextSize)
- return true;
-
- int maxTextureSize = 0;
- m_context->getIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
- if (newContextSize.height() > maxTextureSize || newContextSize.width() > maxTextureSize)
- return false;
-
- return resizeContext(newContextSize);
-}
-
-bool FECustomFilter::resizeContext(const IntSize& newContextSize)
-{
- bool multisample = resizeMultisampleBuffers(newContextSize);
-
- m_context->bindFramebuffer(GL_FRAMEBUFFER, m_frameBuffer);
- m_context->bindTexture(GL_TEXTURE_2D, m_destTexture);
- // We are going to clear the output buffer anyway, so we can safely initialize the destination texture with garbage data.
- // FIXME: GraphicsContext3D::texImage2DDirect is not implemented on Chromium.
- m_context->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, newContextSize.width(), newContextSize.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
- m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_destTexture, 0);
-
- // We don't need the depth buffer for the texture framebuffer, if we already
- // have a multisample buffer.
- if (!multisample) {
- m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer);
- m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, newContextSize.width(), newContextSize.height());
- m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthBuffer);
- }
-
- if (m_context->checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
- return false;
-
- if (multisample) {
- // Clear the framebuffer first, otherwise the first blit will fail.
- m_context->clearColor(0, 0, 0, 0);
- m_context->clear(GL_COLOR_BUFFER_BIT);
- }
-
- m_context->bindRenderbuffer(GL_RENDERBUFFER, 0);
-
- m_contextSize = newContextSize;
- return true;
-}
-
-TextStream& FECustomFilter::externalRepresentation(TextStream& ts, int indent) const
-{
- writeIndent(ts, indent);
- ts << "[feCustomFilter";
- FilterEffect::externalRepresentation(ts);
- ts << "]\n";
- inputEffect(0)->externalRepresentation(ts, indent + 1);
- return ts;
-}
-
-} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/FECustomFilter.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/FECustomFilter.h
deleted file mode 100644
index b2fb50b9d45..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/FECustomFilter.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
- * Copyright (C) 2013 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef FECustomFilter_h
-#define FECustomFilter_h
-
-#include "platform/graphics/GraphicsTypes3D.h"
-#include "platform/graphics/filters/Filter.h"
-#include "platform/graphics/filters/FilterEffect.h"
-#include "platform/graphics/filters/custom/CustomFilterConstants.h"
-#include "platform/graphics/filters/custom/CustomFilterOperation.h"
-#include "wtf/RefPtr.h"
-
-namespace WebCore {
-
-class CustomFilterRenderer;
-class CustomFilterValidatedProgram;
-class GraphicsContext3D;
-class IntSize;
-
-class PLATFORM_EXPORT FECustomFilter : public FilterEffect {
-public:
- static PassRefPtr<FECustomFilter> create(Filter*, PassRefPtr<GraphicsContext3D>, PassRefPtr<CustomFilterValidatedProgram>, const CustomFilterParameterList&,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshType);
-
- virtual TextStream& externalRepresentation(TextStream&, int indention) const;
-
-private:
- FECustomFilter(Filter*, PassRefPtr<GraphicsContext3D>, PassRefPtr<CustomFilterValidatedProgram>, const CustomFilterParameterList&,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshType);
- ~FECustomFilter();
-
- virtual void applySoftware() OVERRIDE;
-
- bool applyShader();
- void clearShaderResult();
- bool initializeContext();
-
- bool prepareForDrawing();
-
- void drawFilterMesh(Platform3DObject inputTexture);
- bool ensureInputTexture();
- void uploadInputTexture(Uint8ClampedArray* srcPixelArray);
- bool resizeContextIfNeeded(const IntSize&);
- bool resizeContext(const IntSize&);
-
- bool canUseMultisampleBuffers() const;
- bool createMultisampleBuffer();
- bool resizeMultisampleBuffers(const IntSize&);
- void resolveMultisampleBuffer();
- void deleteMultisampleRenderBuffers();
-
- bool ensureFrameBuffer();
- void deleteRenderBuffers();
-
- RefPtr<GraphicsContext3D> m_context;
- RefPtr<CustomFilterValidatedProgram> m_validatedProgram;
- RefPtr<CustomFilterRenderer> m_customFilterRenderer;
- IntSize m_contextSize;
-
- Platform3DObject m_inputTexture;
- Platform3DObject m_frameBuffer;
- Platform3DObject m_depthBuffer;
- Platform3DObject m_destTexture;
-
- bool m_triedMultisampleBuffer;
- Platform3DObject m_multisampleFrameBuffer;
- Platform3DObject m_multisampleRenderBuffer;
- Platform3DObject m_multisampleDepthBuffer;
-};
-
-} // namespace WebCore
-
-#endif // FECustomFilter_h
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/ValidatedCustomFilterOperation.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/ValidatedCustomFilterOperation.cpp
deleted file mode 100644
index c01b3af9e67..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/ValidatedCustomFilterOperation.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "platform/graphics/filters/custom/ValidatedCustomFilterOperation.h"
-
-#include "platform/graphics/filters/custom/CustomFilterParameter.h"
-#include "platform/graphics/filters/custom/CustomFilterValidatedProgram.h"
-
-namespace WebCore {
-
-ValidatedCustomFilterOperation::ValidatedCustomFilterOperation(PassRefPtr<CustomFilterValidatedProgram> validatedProgram,
- const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType)
- : FilterOperation(VALIDATED_CUSTOM)
- , m_validatedProgram(validatedProgram)
- , m_parameters(sortedParameters)
- , m_meshRows(meshRows)
- , m_meshColumns(meshColumns)
- , m_meshType(meshType)
-{
-}
-
-ValidatedCustomFilterOperation::~ValidatedCustomFilterOperation()
-{
-}
-
-PassRefPtr<FilterOperation> ValidatedCustomFilterOperation::blend(const FilterOperation*, double) const
-{
- ASSERT_NOT_REACHED();
- return const_cast<ValidatedCustomFilterOperation*>(this);
-}
-
-} // namespace WebCore
-
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/ValidatedCustomFilterOperation.h b/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/ValidatedCustomFilterOperation.h
deleted file mode 100644
index 9542914869d..00000000000
--- a/chromium/third_party/WebKit/Source/platform/graphics/filters/custom/ValidatedCustomFilterOperation.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef ValidatedCustomFilterOperation_h
-#define ValidatedCustomFilterOperation_h
-
-#include "platform/graphics/filters/FilterOperation.h"
-#include "platform/graphics/filters/custom/CustomFilterConstants.h"
-#include "platform/graphics/filters/custom/CustomFilterParameterList.h"
-
-namespace WebCore {
-
-class CustomFilterValidatedProgram;
-
-class PLATFORM_EXPORT ValidatedCustomFilterOperation : public FilterOperation {
-public:
- static PassRefPtr<ValidatedCustomFilterOperation> create(PassRefPtr<CustomFilterValidatedProgram> validatedProgram,
- const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType)
- {
- return adoptRef(new ValidatedCustomFilterOperation(validatedProgram, sortedParameters, meshRows, meshColumns, meshType));
- }
-
- virtual ~ValidatedCustomFilterOperation();
-
- virtual bool affectsOpacity() const { return true; }
- virtual bool movesPixels() const { return true; }
-
-
- CustomFilterValidatedProgram* validatedProgram() const { return m_validatedProgram.get(); }
- const CustomFilterParameterList& parameters() const { return m_parameters; }
-
- unsigned meshRows() const { return m_meshRows; }
- unsigned meshColumns() const { return m_meshColumns; }
-
- CustomFilterMeshType meshType() const { return m_meshType; }
-
-private:
- virtual PassRefPtr<FilterOperation> blend(const FilterOperation* from, double progress) const OVERRIDE;
- virtual bool operator==(const FilterOperation& o) const
- {
- if (!isSameType(o))
- return false;
-
- const ValidatedCustomFilterOperation* other = static_cast<const ValidatedCustomFilterOperation*>(&o);
- return m_validatedProgram.get() == other->m_validatedProgram.get()
- && m_meshRows == other->m_meshRows
- && m_meshColumns == other->m_meshColumns
- && m_meshType == other->m_meshType
- && m_parameters == other->m_parameters;
- }
-
- ValidatedCustomFilterOperation(PassRefPtr<CustomFilterValidatedProgram>, const CustomFilterParameterList&, unsigned meshRows, unsigned meshColumns, CustomFilterMeshType);
-
- RefPtr<CustomFilterValidatedProgram> m_validatedProgram;
-
- CustomFilterParameterList m_parameters;
- unsigned m_meshRows;
- unsigned m_meshColumns;
- CustomFilterMeshType m_meshType;
-};
-
-DEFINE_FILTER_OPERATION_TYPE_CASTS(ValidatedCustomFilterOperation, VALIDATED_CUSTOM);
-
-} // namespace WebCore
-
-
-#endif // ValidatedCustomFilterOperation_h