| Differences between
and this patch
- a/Source/WebCore/ChangeLog +34 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2012-11-17  Alexandru Chiculita  <achicu@adobe.com>
2
3
        [Texmap][CSS Shaders] Reuse the precompiled shader for custom filters in TextureMapperGL
4
        https://bugs.webkit.org/show_bug.cgi?id=101801
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Added a HashMap in TextureMapperGL to store the precompiled versions of the shaders.
9
        Also added a new API on TextureMapper that receives a notification when the shader
10
        is no longer needed.
11
12
        No new tests, the code is tested by existing tests.
13
14
        * platform/graphics/filters/CustomFilterOperation.h:
15
        (WebCore::CustomFilterOperation::setProgram):
16
        (CustomFilterOperation): Made the constructor protected, so that we can overwrite the class
17
        in WK2.
18
        * platform/graphics/texmap/TextureMapper.h:
19
        (WebCore):
20
        (TextureMapper):
21
        (WebCore::TextureMapper::removeCachedCustomFilterProgram): 
22
        Function to be called by the platform code, when the shader is no longer
23
        needed. This implementation is empty and overridden in TextureMapperGL.
24
        * platform/graphics/texmap/TextureMapperGL.cpp:
25
        (WebCore::TextureMapperGL::removeCachedCustomFilterProgram):
26
        Removes the compiled shader from the cache. This is called from WK2 when the compiled shader
27
        is no longer needed.
28
        (WebCore):
29
        (WebCore::TextureMapperGL::drawUsingCustomFilter): The first time it uses a new
30
        shader it will cache the compiled version until removeCachedCustomFilterProgram is called.
31
        * platform/graphics/texmap/TextureMapperGL.h:
32
        (WebCore):
33
        (TextureMapperGL):
34
1
2012-11-16  Dimitri Glazkov  <dglazkov@chromium.org>
35
2012-11-16  Dimitri Glazkov  <dglazkov@chromium.org>
2
36
3
        [Chromium] Updated WebCore.gypi after r134939.
37
        [Chromium] Updated WebCore.gypi after r134939.
- a/Source/WebCore/platform/graphics/filters/CustomFilterOperation.h -2 / +5 lines
Lines 49-54 public: a/Source/WebCore/platform/graphics/filters/CustomFilterOperation.h_sec1
49
    }
49
    }
50
    
50
    
51
    CustomFilterProgram* program() const { return m_program.get(); }
51
    CustomFilterProgram* program() const { return m_program.get(); }
52
    void setProgram(PassRefPtr<CustomFilterProgram> program) { m_program = program; }
52
    
53
    
53
    const CustomFilterParameterList& parameters() const { return m_parameters; }
54
    const CustomFilterParameterList& parameters() const { return m_parameters; }
54
    
55
    
Lines 65-70 public: a/Source/WebCore/platform/graphics/filters/CustomFilterOperation.h_sec2
65
    virtual bool blendingNeedsRendererSize() const { return true; }
66
    virtual bool blendingNeedsRendererSize() const { return true; }
66
    
67
    
67
    virtual PassRefPtr<FilterOperation> blend(const FilterOperation* from, double progress, const LayoutSize&, bool blendToPassthrough = false);
68
    virtual PassRefPtr<FilterOperation> blend(const FilterOperation* from, double progress, const LayoutSize&, bool blendToPassthrough = false);
69
70
protected:
71
    CustomFilterOperation(PassRefPtr<CustomFilterProgram>, const CustomFilterParameterList&, unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType, CustomFilterMeshType);
72
    
68
private:
73
private:
69
    virtual bool operator==(const FilterOperation& o) const
74
    virtual bool operator==(const FilterOperation& o) const
70
    {
75
    {
Lines 79-86 private: a/Source/WebCore/platform/graphics/filters/CustomFilterOperation.h_sec3
79
            && m_meshType == other->m_meshType
84
            && m_meshType == other->m_meshType
80
            && m_parameters == other->m_parameters;
85
            && m_parameters == other->m_parameters;
81
    }
86
    }
82
    
83
    CustomFilterOperation(PassRefPtr<CustomFilterProgram>, const CustomFilterParameterList&, unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType, CustomFilterMeshType);
84
87
85
    RefPtr<CustomFilterProgram> m_program;
88
    RefPtr<CustomFilterProgram> m_program;
86
    CustomFilterParameterList m_parameters;
89
    CustomFilterParameterList m_parameters;
- a/Source/WebCore/platform/graphics/texmap/TextureMapper.h +5 lines
Lines 48-53 a/Source/WebCore/platform/graphics/texmap/TextureMapper.h_sec1
48
namespace WebCore {
48
namespace WebCore {
49
49
50
class BitmapTexturePool;
50
class BitmapTexturePool;
51
class CustomFilterProgram;
51
class TextureMapper;
52
class TextureMapper;
52
53
53
// A 2D texture that can be the target of software or GL rendering.
54
// A 2D texture that can be the target of software or GL rendering.
Lines 154-159 public: a/Source/WebCore/platform/graphics/texmap/TextureMapper.h_sec2
154
155
155
    virtual PassRefPtr<BitmapTexture> acquireTextureFromPool(const IntSize&);
156
    virtual PassRefPtr<BitmapTexture> acquireTextureFromPool(const IntSize&);
156
157
158
#if ENABLE(CSS_SHADERS)
159
    virtual void removeCachedCustomFilterProgram(CustomFilterProgram*) { }
160
#endif
161
157
protected:
162
protected:
158
    explicit TextureMapper(AccelerationMode);
163
    explicit TextureMapper(AccelerationMode);
159
164
- a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp -3 / +16 lines
Lines 921-926 static void prepareFilterProgram(TextureMapperShaderProgram* program, const Filt a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp_sec1
921
}
921
}
922
922
923
#if ENABLE(CSS_SHADERS)
923
#if ENABLE(CSS_SHADERS)
924
void TextureMapperGL::removeCachedCustomFilterProgram(CustomFilterProgram* program)
925
{
926
    m_customFilterPrograms.remove(program);
927
}
928
924
bool TextureMapperGL::drawUsingCustomFilter(BitmapTexture& target, const BitmapTexture& source, const FilterOperation& filter)
929
bool TextureMapperGL::drawUsingCustomFilter(BitmapTexture& target, const BitmapTexture& source, const FilterOperation& filter)
925
{
930
{
926
    RefPtr<CustomFilterRenderer> renderer;
931
    RefPtr<CustomFilterRenderer> renderer;
Lines 930-940 bool TextureMapperGL::drawUsingCustomFilter(BitmapTexture& target, const BitmapT a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp_sec2
930
        // happens in CoordinatedGraphicsArgumentCoders.
935
        // happens in CoordinatedGraphicsArgumentCoders.
931
        const CustomFilterOperation* customFilter = static_cast<const CustomFilterOperation*>(&filter);
936
        const CustomFilterOperation* customFilter = static_cast<const CustomFilterOperation*>(&filter);
932
        RefPtr<CustomFilterProgram> program = customFilter->program();
937
        RefPtr<CustomFilterProgram> program = customFilter->program();
938
        // The program might be empty when WebKit::LayerTreeRenderer failed
939
        // to decode it. Don't try to render in that case.
940
        if (!program)
941
            return false;
933
        renderer = CustomFilterRenderer::create(m_context3D, program->programType(), customFilter->parameters(), 
942
        renderer = CustomFilterRenderer::create(m_context3D, program->programType(), customFilter->parameters(), 
934
            customFilter->meshRows(), customFilter->meshColumns(), customFilter->meshBoxType(), customFilter->meshType());
943
            customFilter->meshRows(), customFilter->meshColumns(), customFilter->meshBoxType(), customFilter->meshType());
935
        // FIXME: Optimize this by keeping a reference to the program across frames.
944
        RefPtr<CustomFilterCompiledProgram> compiledProgram;
936
        // https://bugs.webkit.org/show_bug.cgi?id=101801
945
        CustomFilterProgramMap::iterator iter = m_customFilterPrograms.find(program.get());
937
        RefPtr<CustomFilterCompiledProgram> compiledProgram = CustomFilterCompiledProgram::create(m_context3D, program->vertexShaderString(), program->fragmentShaderString(), program->programType());
946
        if (iter == m_customFilterPrograms.end()) {
947
            compiledProgram = CustomFilterCompiledProgram::create(m_context3D, program->vertexShaderString(), program->fragmentShaderString(), program->programType());
948
            m_customFilterPrograms.set(program.get(), compiledProgram);
949
        } else
950
            compiledProgram = iter->value;
938
        renderer->setCompiledProgram(compiledProgram.release());
951
        renderer->setCompiledProgram(compiledProgram.release());
939
        break;
952
        break;
940
    }
953
    }
- a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h +8 lines
Lines 30-35 a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h_sec1
30
30
31
namespace WebCore {
31
namespace WebCore {
32
32
33
class CustomFilterProgram;
34
class CustomFilterCompiledProgram;
33
class TextureMapperGLData;
35
class TextureMapperGLData;
34
class GraphicsContext;
36
class GraphicsContext;
35
class TextureMapperShaderProgram;
37
class TextureMapperShaderProgram;
Lines 74-79 public: a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h_sec2
74
#endif
76
#endif
75
#if ENABLE(CSS_SHADERS)
77
#if ENABLE(CSS_SHADERS)
76
    bool drawUsingCustomFilter(BitmapTexture& targetTexture, const BitmapTexture& sourceTexture, const FilterOperation&);
78
    bool drawUsingCustomFilter(BitmapTexture& targetTexture, const BitmapTexture& sourceTexture, const FilterOperation&);
79
    virtual void removeCachedCustomFilterProgram(CustomFilterProgram*);
77
#endif
80
#endif
78
81
79
    void setEnableEdgeDistanceAntialiasing(bool enabled) { m_enableEdgeDistanceAntialiasing = enabled; }
82
    void setEnableEdgeDistanceAntialiasing(bool enabled) { m_enableEdgeDistanceAntialiasing = enabled; }
Lines 128-133 private: a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h_sec3
128
    ClipStack m_clipStack;
131
    ClipStack m_clipStack;
129
    bool m_enableEdgeDistanceAntialiasing;
132
    bool m_enableEdgeDistanceAntialiasing;
130
133
134
#if ENABLE(CSS_SHADERS)
135
    typedef HashMap<CustomFilterProgram*, RefPtr<CustomFilterCompiledProgram> > CustomFilterProgramMap;
136
    CustomFilterProgramMap m_customFilterPrograms;
137
#endif
138
131
    friend class BitmapTextureGL;
139
    friend class BitmapTextureGL;
132
};
140
};
133
141
- a/Source/WebKit2/ChangeLog +45 lines
Lines 1-3 a/Source/WebKit2/ChangeLog_sec1
1
2012-11-17  Alexandru Chiculita  <achicu@adobe.com>
2
3
        [Texmap][CSS Shaders] Reuse the precompiled shader for custom filters in TextureMapperGL
4
        https://bugs.webkit.org/show_bug.cgi?id=101801
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Changed the encoding code for ValidatedCustomFilterOperation to only encode the shader
9
        when it was not serialized to the UI process before. Otherwise, it will just encode an ID.
10
        LayerTreeRenderer will now maintain a HashMap from these IDs to the real CustomFilterProgram.
11
        It will receive a message from the WebProcess when the shader is no longer in needed.
12
        LayerTreeRenderer also calls the TextureMapper's removeCachedCustomFilterProgram to notify
13
        about the removed CustomFilterProgram.
14
15
        * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
16
        (CoreIPC::::encode):
17
        (CoreIPC::::decode):
18
        * Shared/CoordinatedGraphics/WebCustomFilterOperation.h: Added.
19
        (WebCore):
20
        (WebCustomFilterOperation):
21
        (WebCore::WebCustomFilterOperation::create):
22
        (WebCore::WebCustomFilterOperation::programId):
23
        (WebCore::WebCustomFilterOperation::WebCustomFilterOperation):
24
        * Shared/CoordinatedGraphics/WebCustomFilterProgramProxy.h:
25
        (WebKit::WebCustomFilterProgramProxy::wasSentToUIProcess):
26
        (WebKit::WebCustomFilterProgramProxy::setWasSentToUIProcess):
27
        (WebCustomFilterProgramProxy):
28
        (WebKit::WebCustomFilterProgramProxy::WebCustomFilterProgramProxy):
29
        * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp:
30
        (WebKit):
31
        (WebKit::LayerTreeCoordinatorProxy::removeCustomFilterProgram):
32
        * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h:
33
        (LayerTreeCoordinatorProxy):
34
        * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in:
35
        * UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp:
36
        (WebKit::LayerTreeRenderer::setLayerFilters):
37
        (WebKit):
38
        (WebKit::LayerTreeRenderer::injectCachedCustomFilterPrograms):
39
        (WebKit::LayerTreeRenderer::removeCustomFilterProgram):
40
        * UIProcess/CoordinatedGraphics/LayerTreeRenderer.h:
41
        (WebCore):
42
        (LayerTreeRenderer):
43
        * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp:
44
        (WebKit::LayerTreeCoordinator::removeCustomFilterProgramProxy):
45
1
2012-11-16  Viatcheslav Ostapenko  <v.ostapenko@samsung.com>
46
2012-11-16  Viatcheslav Ostapenko  <v.ostapenko@samsung.com>
2
47
3
        [EFL][WK2] White flicker when scrolling big pages with dark background on slower hardware.
48
        [EFL][WK2] White flicker when scrolling big pages with dark background on slower hardware.
- a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp -27 / +44 lines
Lines 52-58 a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp_sec1
52
#endif
52
#endif
53
53
54
#if ENABLE(CSS_SHADERS)
54
#if ENABLE(CSS_SHADERS)
55
#include "WebCustomFilterOperation.h"
55
#include "WebCustomFilterProgram.h"
56
#include "WebCustomFilterProgram.h"
57
#include "WebCustomFilterProgramProxy.h"
56
#include <WebCore/CustomFilterArrayParameter.h>
58
#include <WebCore/CustomFilterArrayParameter.h>
57
#include <WebCore/CustomFilterConstants.h>
59
#include <WebCore/CustomFilterConstants.h>
58
#include <WebCore/CustomFilterNumberParameter.h>
60
#include <WebCore/CustomFilterNumberParameter.h>
Lines 142-164 void ArgumentCoder<WebCore::FilterOperations>::encode(ArgumentEncoder& encoder, a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp_sec2
142
            break;
144
            break;
143
        case FilterOperation::VALIDATED_CUSTOM: {
145
        case FilterOperation::VALIDATED_CUSTOM: {
144
            const ValidatedCustomFilterOperation* customOperation = static_cast<const ValidatedCustomFilterOperation*>(filter);
146
            const ValidatedCustomFilterOperation* customOperation = static_cast<const ValidatedCustomFilterOperation*>(filter);
145
146
            ASSERT(customOperation->validatedProgram());
147
            ASSERT(customOperation->validatedProgram());
147
            RefPtr<CustomFilterValidatedProgram> program = customOperation->validatedProgram();
148
            RefPtr<CustomFilterValidatedProgram> program = customOperation->validatedProgram();
148
            ASSERT(program->isInitialized());
149
            ASSERT(program->isInitialized());
149
            ASSERT(program->platformCompiledProgram());
150
            ASSERT(program->platformCompiledProgram());
150
            // FIXME: We should only serialize the object if it was not serialized before,
151
            ASSERT(program->platformCompiledProgram()->client());
151
            // otherwise only the ID of the program should be written to the stream.
152
            WebCustomFilterProgramProxy* customFilterProgramProxy = static_cast<WebCustomFilterProgramProxy*>(program->platformCompiledProgram()->client());
152
            // https://bugs.webkit.org/show_bug.cgi?id=101801
153
            encoder << program->validatedVertexShader();
154
            encoder << program->validatedFragmentShader();
155
            const CustomFilterProgramInfo& programInfo = program->programInfo();
153
            const CustomFilterProgramInfo& programInfo = program->programInfo();
156
            encoder.encodeEnum(programInfo.programType());
154
            // FIXME: CustomFilterOperation should not need the meshType, it should just be encoded in the program itself.
157
            const CustomFilterProgramMixSettings& mixSettings = programInfo.mixSettings();
155
            // https://bugs.webkit.org/show_bug.cgi?id=102529
158
            encoder.encodeEnum(mixSettings.blendMode);
159
            encoder.encodeEnum(mixSettings.compositeOperator);
160
            encoder.encodeEnum(programInfo.meshType());
156
            encoder.encodeEnum(programInfo.meshType());
161
157
            encoder << customFilterProgramProxy->wasSentToUIProcess();
158
            encoder << customFilterProgramProxy->id();
159
            if (!customFilterProgramProxy->wasSentToUIProcess()) {
160
                customFilterProgramProxy->setWasSentToUIProcess(true);
161
                encoder << program->validatedVertexShader();
162
                encoder << program->validatedFragmentShader();
163
                encoder.encodeEnum(programInfo.programType());
164
                const CustomFilterProgramMixSettings& mixSettings = programInfo.mixSettings();
165
                encoder.encodeEnum(mixSettings.blendMode);
166
                encoder.encodeEnum(mixSettings.compositeOperator);
167
            }
162
            CustomFilterParameterList parameters = customOperation->parameters();
168
            CustomFilterParameterList parameters = customOperation->parameters();
163
            encoder << static_cast<uint32_t>(parameters.size());
169
            encoder << static_cast<uint32_t>(parameters.size());
164
            for (size_t i = 0; i < parameters.size(); ++i) {
170
            for (size_t i = 0; i < parameters.size(); ++i) {
Lines 264-287 bool ArgumentCoder<WebCore::FilterOperations>::decode(ArgumentDecoder* decoder, a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp_sec3
264
            ASSERT_NOT_REACHED();
270
            ASSERT_NOT_REACHED();
265
            break;
271
            break;
266
        case FilterOperation::VALIDATED_CUSTOM: {
272
        case FilterOperation::VALIDATED_CUSTOM: {
267
            String vertexShaderString;
273
            // FIXME: CustomFilterOperation should not need the meshType.
268
            String fragmentShaderString;
274
            // https://bugs.webkit.org/show_bug.cgi?id=102529
269
            CustomFilterProgramType programType;
270
            CustomFilterProgramMixSettings mixSettings;
271
            CustomFilterMeshType meshType;
275
            CustomFilterMeshType meshType;
272
            if (!decoder->decode(vertexShaderString))
276
            if (!decoder->decodeEnum(meshType))
273
                return false;
274
            if (!decoder->decode(fragmentShaderString))
275
                return false;
276
            if (!decoder->decodeEnum(programType))
277
                return false;
278
            if (!decoder->decodeEnum(mixSettings.blendMode))
279
                return false;
277
                return false;
280
            if (!decoder->decodeEnum(mixSettings.compositeOperator))
278
            bool programWasSentToUIProcessBefore = false;
279
            int programId = 0;
280
            if (!decoder->decode(programWasSentToUIProcessBefore))
281
                return false;
281
                return false;
282
            if (!decoder->decodeEnum(meshType))
282
            if (!decoder->decode(programId))
283
                return false;
283
                return false;
284
            RefPtr<CustomFilterProgram> program = WebCustomFilterProgram::create(vertexShaderString, fragmentShaderString, programType, mixSettings, meshType);
284
            RefPtr<CustomFilterProgram> program;
285
            if (!programWasSentToUIProcessBefore) {
286
                String vertexShaderString;
287
                String fragmentShaderString;
288
                CustomFilterProgramType programType;
289
                CustomFilterProgramMixSettings mixSettings;
290
                if (!decoder->decode(vertexShaderString))
291
                    return false;
292
                if (!decoder->decode(fragmentShaderString))
293
                    return false;
294
                if (!decoder->decodeEnum(programType))
295
                    return false;
296
                if (!decoder->decodeEnum(mixSettings.blendMode))
297
                    return false;
298
                if (!decoder->decodeEnum(mixSettings.compositeOperator))
299
                    return false;
300
                program = WebCustomFilterProgram::create(vertexShaderString, fragmentShaderString, programType, mixSettings, meshType);
301
            }
285
302
286
            uint32_t parametersSize;
303
            uint32_t parametersSize;
287
            if (!decoder->decodeUInt32(parametersSize))
304
            if (!decoder->decodeUInt32(parametersSize))
Lines 347-354 bool ArgumentCoder<WebCore::FilterOperations>::decode(ArgumentDecoder* decoder, a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp_sec4
347
            if (!decoder->decodeEnum(meshBoxType))
364
            if (!decoder->decodeEnum(meshBoxType))
348
                return false;
365
                return false;
349
366
350
            // At this point the Shaders are already validated, so we just use CustomFilterOperation for transportation.
367
            // At this point the Shaders are already validated, so we just use WebCustomFilterOperation for transportation.
351
            filter = CustomFilterOperation::create(program.release(), parameters, meshRows, meshColumns, meshBoxType, meshType);
368
            filter = WebCustomFilterOperation::create(program.release(), programId, parameters, meshRows, meshColumns, meshBoxType, meshType);
352
            break;
369
            break;
353
        }
370
        }
354
#endif
371
#endif
- a/Source/WebKit2/Shared/CoordinatedGraphics/WebCustomFilterOperation.h +69 lines
Line 0 a/Source/WebKit2/Shared/CoordinatedGraphics/WebCustomFilterOperation.h_sec1
1
/*
2
 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 *
8
 * 1. Redistributions of source code must retain the above
9
 *    copyright notice, this list of conditions and the following
10
 *    disclaimer.
11
 * 2. Redistributions in binary form must reproduce the above
12
 *    copyright notice, this list of conditions and the following
13
 *    disclaimer in the documentation and/or other materials
14
 *    provided with the distribution.
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
17
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
20
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21
 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
25
 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
26
 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
 * SUCH DAMAGE.
28
 */
29
30
#ifndef WebCustomFilterOperation_h
31
#define WebCustomFilterOperation_h
32
33
#if ENABLE(CSS_SHADERS)
34
#include "CustomFilterOperation.h"
35
36
namespace WebCore {
37
38
// This class is only adding the programId on top of CustomFilterOperation. The argument decoder has no
39
// context, so we cannot search in our cached CustomFilterPrograms while decoding. In that case
40
// it will just store the programId and no CustomFilterProgram instance. The receiver is supposed to
41
// iterate on this structure and inject the right CustomFilterPrograms. There are two possibilities:
42
// a) Both program() and programId() are set, meaning that the program is new and needs to be cached
43
// b) Only programId() is set, meaning that the program was seen before and needs to be injected 
44
// by the LayerTreeCoordinatorProxy.
45
46
class WebCustomFilterOperation : public CustomFilterOperation {
47
public:
48
    static PassRefPtr<WebCustomFilterOperation> create(PassRefPtr<CustomFilterProgram> program, int programId, const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType meshBoxType, CustomFilterMeshType meshType)
49
    {
50
        return adoptRef(new WebCustomFilterOperation(program, programId, sortedParameters, meshRows, meshColumns, meshBoxType, meshType));
51
    }
52
53
    int programId() const { return m_programId; }
54
55
private:
56
    WebCustomFilterOperation(PassRefPtr<CustomFilterProgram> program, int programId, const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType meshBoxType, CustomFilterMeshType meshType)
57
        : CustomFilterOperation(program, sortedParameters, meshRows, meshColumns, meshBoxType, meshType)
58
        , m_programId(programId)
59
    {
60
    }
61
62
    int m_programId;
63
};
64
65
} // namespace WebCore
66
67
#endif // ENABLE(CSS_SHADERS)
68
69
#endif // CustomFilterOperation_h
- a/Source/WebKit2/Shared/CoordinatedGraphics/WebCustomFilterProgramProxy.h +5 lines
Lines 72-86 public: a/Source/WebKit2/Shared/CoordinatedGraphics/WebCustomFilterProgramProxy.h_sec1
72
    void setClient(WebCustomFilterProgramProxyClient* client) { m_client = client; }
72
    void setClient(WebCustomFilterProgramProxyClient* client) { m_client = client; }
73
    WebCustomFilterProgramProxyClient* client() const { return m_client; }
73
    WebCustomFilterProgramProxyClient* client() const { return m_client; }
74
74
75
    bool wasSentToUIProcess() const  { return m_wasSentToUIProcess; }
76
    void setWasSentToUIProcess(bool wasSentToUIProcess) { m_wasSentToUIProcess = wasSentToUIProcess; }
77
75
private:
78
private:
76
    WebCustomFilterProgramProxy(WebCustomFilterProgramProxyClient* client)
79
    WebCustomFilterProgramProxy(WebCustomFilterProgramProxyClient* client)
77
        : m_client(client)
80
        : m_client(client)
78
        , m_id(s_nextId++)
81
        , m_id(s_nextId++)
82
        , m_wasSentToUIProcess(false)
79
    {
83
    {
80
    }
84
    }
81
    
85
    
82
    WebCustomFilterProgramProxyClient* m_client;
86
    WebCustomFilterProgramProxyClient* m_client;
83
    int m_id;
87
    int m_id;
88
    bool m_wasSentToUIProcess;
84
    
89
    
85
    static int s_nextId;
90
    static int s_nextId;
86
};
91
};
- a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp +7 lines
Lines 115-120 void LayerTreeCoordinatorProxy::setCompositingLayerFilters(WebLayerID id, const a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp_sec1
115
}
115
}
116
#endif
116
#endif
117
117
118
#if ENABLE(CSS_SHADERS)
119
void LayerTreeCoordinatorProxy::removeCustomFilterProgram(int id)
120
{
121
    dispatchUpdate(bind(&LayerTreeRenderer::removeCustomFilterProgram, m_renderer.get(), id));
122
}
123
#endif
124
118
void LayerTreeCoordinatorProxy::didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect)
125
void LayerTreeCoordinatorProxy::didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect)
119
{
126
{
120
    dispatchUpdate(bind(&LayerTreeRenderer::flushLayerChanges, m_renderer.get()));
127
    dispatchUpdate(bind(&LayerTreeRenderer::flushLayerChanges, m_renderer.get()));
- a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h +3 lines
Lines 57-62 public: a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h_sec1
57
#if ENABLE(CSS_FILTERS)
57
#if ENABLE(CSS_FILTERS)
58
    void setCompositingLayerFilters(WebLayerID, const WebCore::FilterOperations&);
58
    void setCompositingLayerFilters(WebLayerID, const WebCore::FilterOperations&);
59
#endif
59
#endif
60
#if ENABLE(CSS_SHADERS)
61
    void removeCustomFilterProgram(int id);
62
#endif
60
    void deleteCompositingLayer(WebLayerID);
63
    void deleteCompositingLayer(WebLayerID);
61
    void setRootCompositingLayer(WebLayerID);
64
    void setRootCompositingLayer(WebLayerID);
62
    void setContentsSize(const WebCore::FloatSize&);
65
    void setContentsSize(const WebCore::FloatSize&);
- a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in +3 lines
Lines 24-29 messages -> LayerTreeCoordinatorProxy { a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in_sec1
24
#if ENABLE(CSS_FILTERS)
24
#if ENABLE(CSS_FILTERS)
25
    SetCompositingLayerFilters(uint32_t id, WebCore::FilterOperations filters)
25
    SetCompositingLayerFilters(uint32_t id, WebCore::FilterOperations filters)
26
#endif
26
#endif
27
#if ENABLE(CSS_SHADERS)
28
    RemoveCustomFilterProgram(int id)
29
#endif
27
    SetRootCompositingLayer(uint32_t id)
30
    SetRootCompositingLayer(uint32_t id)
28
    DeleteCompositingLayer(uint32_t id)
31
    DeleteCompositingLayer(uint32_t id)
29
    CreateTileForLayer(uint32_t layerID, int tileID, WebCore::IntRect tileRect, WebKit::SurfaceUpdateInfo updateInfo)
32
    CreateTileForLayer(uint32_t layerID, int tileID, WebCore::IntRect tileRect, WebKit::SurfaceUpdateInfo updateInfo)
- a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp +44 lines
Lines 37-42 a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp_sec1
37
#include <wtf/Atomics.h>
37
#include <wtf/Atomics.h>
38
#include <wtf/MainThread.h>
38
#include <wtf/MainThread.h>
39
39
40
#if ENABLE(CSS_SHADERS)
41
#include "CustomFilterProgram.h"
42
#include "WebCustomFilterOperation.h"
43
#endif
44
40
namespace WebKit {
45
namespace WebKit {
41
46
42
using namespace WebCore;
47
using namespace WebCore;
Lines 283-292 void LayerTreeRenderer::setLayerFilters(WebLayerID id, const FilterOperations& f a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp_sec2
283
    ASSERT(it != m_layers.end());
288
    ASSERT(it != m_layers.end());
284
289
285
    GraphicsLayer* layer = it->value;
290
    GraphicsLayer* layer = it->value;
291
#if ENABLE(CSS_SHADERS)
292
    injectCachedCustomFilterPrograms(const_cast<FilterOperations&>(filters));
293
#endif
286
    layer->setFilters(filters);
294
    layer->setFilters(filters);
287
}
295
}
288
#endif
296
#endif
289
297
298
#if ENABLE(CSS_SHADERS)
299
void LayerTreeRenderer::injectCachedCustomFilterPrograms(FilterOperations& filters)
300
{
301
    for (size_t i = 0; i < filters.size(); ++i) {
302
        FilterOperation* operation = filters.operations().at(i).get();
303
        if (operation->getOperationType() != FilterOperation::CUSTOM)
304
            continue;
305
        WebCustomFilterOperation* customOperation = static_cast<WebCustomFilterOperation*>(operation);
306
        if (!customOperation->program()) {
307
            CustomFilterProgramMap::iterator iter = m_customFilterPrograms.find(customOperation->programId());
308
            if (iter == m_customFilterPrograms.end()) {
309
                ASSERT_NOT_REACHED();
310
                continue;
311
            }
312
            customOperation->setProgram(iter->value.get());
313
        } else {
314
            // This is the first time we receive this program.
315
            ASSERT(!m_customFilterPrograms.contains(customOperation->programId()));
316
            m_customFilterPrograms.set(customOperation->programId(), customOperation->program());
317
        }
318
    }
319
}
320
321
void LayerTreeRenderer::removeCustomFilterProgram(int id)
322
{
323
    CustomFilterProgramMap::iterator iter = m_customFilterPrograms.find(id);
324
    if (iter == m_customFilterPrograms.end()) {
325
        ASSERT_NOT_REACHED();
326
        return;
327
    }
328
    if (m_textureMapper)
329
        m_textureMapper->removeCachedCustomFilterProgram(iter->value.get());
330
    m_customFilterPrograms.remove(iter);
331
}
332
#endif // ENABLE(CSS_SHADERS)
333
290
void LayerTreeRenderer::setLayerState(WebLayerID id, const WebLayerInfo& layerInfo)
334
void LayerTreeRenderer::setLayerState(WebLayerID id, const WebLayerInfo& layerInfo)
291
{
335
{
292
    ensureLayer(id);
336
    ensureLayer(id);
- a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h +13 lines
Lines 38-43 a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h_sec1
38
#include <wtf/HashSet.h>
38
#include <wtf/HashSet.h>
39
#include <wtf/ThreadingPrimitives.h>
39
#include <wtf/ThreadingPrimitives.h>
40
40
41
namespace WebCore {
42
class CustomFilterProgram;
43
}
44
41
namespace WebKit {
45
namespace WebKit {
42
46
43
class CoordinatedBackingStore;
47
class CoordinatedBackingStore;
Lines 84-89 public: a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h_sec2
84
#if ENABLE(CSS_FILTERS)
88
#if ENABLE(CSS_FILTERS)
85
    void setLayerFilters(WebLayerID, const WebCore::FilterOperations&);
89
    void setLayerFilters(WebLayerID, const WebCore::FilterOperations&);
86
#endif
90
#endif
91
#if ENABLE(CSS_SHADERS)
92
    void injectCachedCustomFilterPrograms(WebCore::FilterOperations& filters);
93
    void removeCustomFilterProgram(int id);
94
#endif
87
95
88
    void createTile(WebLayerID, int, float scale);
96
    void createTile(WebLayerID, int, float scale);
89
    void removeTile(WebLayerID, int);
97
    void removeTile(WebLayerID, int);
Lines 171-176 private: a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h_sec3
171
    WebCore::TextureMapper::AccelerationMode m_accelerationMode;
179
    WebCore::TextureMapper::AccelerationMode m_accelerationMode;
172
    WebCore::Color m_backgroundColor;
180
    WebCore::Color m_backgroundColor;
173
    bool m_setDrawsBackground;
181
    bool m_setDrawsBackground;
182
183
#if ENABLE(CSS_SHADERS)
184
    typedef HashMap<int, RefPtr<WebCore::CustomFilterProgram> > CustomFilterProgramMap;
185
    CustomFilterProgramMap m_customFilterPrograms;
186
#endif
174
};
187
};
175
188
176
};
189
};
- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp -2 / +1 lines
Lines 375-382 void LayerTreeCoordinator::removeCustomFilterProgramProxy(WebCustomFilterProgram a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp_sec1
375
    // At this time the shader is not needed anymore, so we remove it from our set and 
375
    // At this time the shader is not needed anymore, so we remove it from our set and 
376
    // send a message to the other process to delete it.
376
    // send a message to the other process to delete it.
377
    m_customFilterPrograms.remove(customFilterProgramProxy);
377
    m_customFilterPrograms.remove(customFilterProgramProxy);
378
    // FIXME: Send a message to delete the object on the UI process.
378
    m_webPage->send(Messages::LayerTreeCoordinatorProxy::RemoveCustomFilterProgram(customFilterProgramProxy->id()));
379
    // https://bugs.webkit.org/show_bug.cgi?id=101801
380
}
379
}
381
380
382
void LayerTreeCoordinator::disconnectCustomFilterPrograms()
381
void LayerTreeCoordinator::disconnectCustomFilterPrograms()

Return to Bug 101801