[Texmap][CSS Shaders] Reuse the precompiled shader for custom filters in TextureMapperGL
https://bugs.webkit.org/show_bug.cgi?id=101801

Reviewed by Noam Rosenthal.

Source/WebCore:

Added a HashMap in TextureMapperGL to store the precompiled versions of the shaders.
Also added a new API on TextureMapper that receives a notification when the shader
is no longer needed.

No new tests, the code is tested by existing tests.

* platform/graphics/filters/CustomFilterOperation.h:
(WebCore::CustomFilterOperation::setProgram):
(CustomFilterOperation): Made the constructor protected, so that we can overwrite the class in WK2.
* platform/graphics/filters/CustomFilterValidatedProgram.cpp:
(WebCore::CustomFilterValidatedProgram::validatedProgramInfo):
(WebCore):
* platform/graphics/filters/CustomFilterValidatedProgram.h:
(CustomFilterValidatedProgram):
* platform/graphics/texmap/TextureMapper.h:
(WebCore):
(TextureMapper):
(WebCore::TextureMapper::removeCachedCustomFilterProgram):
Function to be called by the platform code, when the shader is no longer
needed. This implementation is empty and overridden in TextureMapperGL.
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::removeCachedCustomFilterProgram):
Removes the compiled shader from the cache. This is called from WK2 when the compiled shader
is no longer needed.
(WebCore):
(WebCore::TextureMapperGL::drawUsingCustomFilter): The first time it uses a new
shader it will cache the compiled version until removeCachedCustomFilterProgram is called.
* platform/graphics/texmap/TextureMapperGL.h:
(WebCore):
(TextureMapperGL):

Source/WebKit2:

Changed the encoding code for ValidatedCustomFilterOperation to only encode the ID of the program.
LayerTreeCoordinator makes sure to send the programs in full before the encoder runs.
LayerTreeRenderer will maintain a HashMap from these IDs to the real CustomFilterProgram.
The UI process will also receive a message from the WebProcess when the shader is no longer in needed.
LayerTreeRenderer calls the TextureMapper's removeCachedCustomFilterProgram to notify
about the removed CustomFilterProgram.

* Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
(CoreIPC::::encode):
(CoreIPC::::decode):
(CoreIPC):
* Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.h:
(WebCore):
* Shared/CoordinatedGraphics/WebCustomFilterOperation.h: Added.
(WebCore):
(WebCustomFilterOperation):
(WebCore::WebCustomFilterOperation::create):
(WebCore::WebCustomFilterOperation::programID):
(WebCore::WebCustomFilterOperation::WebCustomFilterOperation):
* Shared/CoordinatedGraphics/WebCustomFilterProgramProxy.h:
(WebKit::WebCustomFilterProgramProxy::create):
(WebKit::WebCustomFilterProgramProxy::WebCustomFilterProgramProxy):
* UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp:
(WebKit):
(WebKit::LayerTreeCoordinatorProxy::removeCustomFilterProgram):
(WebKit::LayerTreeCoordinatorProxy::createCustomFilterProgram):
* UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h:
(LayerTreeCoordinatorProxy):
* UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in:
* UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp:
(WebKit::LayerTreeRenderer::setLayerFilters):
(WebKit):
(WebKit::LayerTreeRenderer::injectCachedCustomFilterPrograms):
(WebKit::LayerTreeRenderer::createCustomFilterProgram):
(WebKit::LayerTreeRenderer::removeCustomFilterProgram):
(WebKit::LayerTreeRenderer::setLayerAnimations):
* UIProcess/CoordinatedGraphics/LayerTreeRenderer.h:
(WebCore):
(LayerTreeRenderer):
* WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp:
(WebKit::LayerTreeCoordinator::checkCustomFilterProgramProxies):
(WebKit::LayerTreeCoordinator::removeCustomFilterProgramProxy):
(WebKit::LayerTreeCoordinator::setLayerAnimations):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@135056 268f45cc-cd09-0410-ab3c-d52691b4dbfc