summaryrefslogtreecommitdiff
path: root/Source/WebCore/platform/graphics/filters/FECustomFilter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform/graphics/filters/FECustomFilter.cpp')
-rw-r--r--Source/WebCore/platform/graphics/filters/FECustomFilter.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/Source/WebCore/platform/graphics/filters/FECustomFilter.cpp b/Source/WebCore/platform/graphics/filters/FECustomFilter.cpp
index 15c50a1e5..c22f50ef9 100644
--- a/Source/WebCore/platform/graphics/filters/FECustomFilter.cpp
+++ b/Source/WebCore/platform/graphics/filters/FECustomFilter.cpp
@@ -33,6 +33,7 @@
#if ENABLE(CSS_SHADERS) && USE(3D_GRAPHICS)
#include "FECustomFilter.h"
+#include "CustomFilterCompiledProgram.h"
#include "CustomFilterRenderer.h"
#include "CustomFilterValidatedProgram.h"
#include "Extensions3D.h"
@@ -45,7 +46,7 @@
namespace WebCore {
FECustomFilter::FECustomFilter(Filter* filter, PassRefPtr<GraphicsContext3D> context, PassRefPtr<CustomFilterValidatedProgram> validatedProgram, const CustomFilterParameterList& parameters,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType meshBoxType, CustomFilterMeshType meshType)
+ unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType)
: FilterEffect(filter)
, m_context(context)
, m_validatedProgram(validatedProgram)
@@ -59,13 +60,13 @@ FECustomFilter::FECustomFilter(Filter* filter, PassRefPtr<GraphicsContext3D> con
, 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, meshBoxType, meshType);
+ 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, CustomFilterMeshBoxType meshBoxType, CustomFilterMeshType meshType)
+ unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType)
{
- return adoptRef(new FECustomFilter(filter, context, validatedProgram, parameters, meshRows, meshColumns, meshBoxType, meshType));
+ return adoptRef(new FECustomFilter(filter, context, validatedProgram, parameters, meshRows, meshColumns, meshType));
}
FECustomFilter::~FECustomFilter()
@@ -156,9 +157,16 @@ 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->compiledProgram()) {
+ RefPtr<CustomFilterCompiledProgram> compiledProgram = m_validatedProgram->compiledProgram();
+ if (!compiledProgram) {
+ // Lazily create a compiled program and let CustomFilterValidatedProgram hold on to it.
+ compiledProgram = CustomFilterCompiledProgram::create(m_context, m_validatedProgram->validatedVertexShader(), m_validatedProgram->validatedFragmentShader(), m_validatedProgram->programInfo().programType());
+ m_validatedProgram->setCompiledProgram(compiledProgram);
+ }
+ // Lazily inject the compiled program into the CustomFilterRenderer.
+ m_customFilterRenderer->setCompiledProgram(compiledProgram.release());
+ }
if (!m_customFilterRenderer->prepareForDrawing())
return false;
@@ -331,12 +339,7 @@ bool FECustomFilter::resizeContext(const IntSize& newContextSize)
m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_frameBuffer);
m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_destTexture);
// We are going to clear the output buffer anyway, so we can safely initialize the destination texture with garbage data.
-#if PLATFORM(CHROMIUM)
- // FIXME: GraphicsContext3D::texImage2DDirect is not implemented on Chromium.
- m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, newContextSize.width(), newContextSize.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, 0);
-#else
m_context->texImage2DDirect(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, newContextSize.width(), newContextSize.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, 0);
-#endif
m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_destTexture, 0);
// We don't need the depth buffer for the texture framebuffer, if we already