- a/Source/WebCore/ChangeLog +14 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2013-06-27  Commit Queue  <commit-queue@webkit.org>
2
3
        Unreviewed, rolling out r152074.
4
        http://trac.webkit.org/changeset/152074
5
        https://bugs.webkit.org/show_bug.cgi?id=118137
6
7
        It caused lots of layout and API test crash on Qt Wk2.
8
        (Requested by kadam on #webkit).
9
10
        * CMakeLists.txt:
11
        * Target.pri:
12
        * platform/graphics/texmap/coordinated/CompositingCoordinator.cpp: Removed.
13
        * platform/graphics/texmap/coordinated/CompositingCoordinator.h: Removed.
14
1
2013-06-27  Xabier Rodriguez Calvar  <calvaris@igalia.com>
15
2013-06-27  Xabier Rodriguez Calvar  <calvaris@igalia.com>
2
16
3
        Fixing some compiler warnings
17
        Fixing some compiler warnings
- a/Source/WebKit2/ChangeLog +60 lines
Lines 1-3 a/Source/WebKit2/ChangeLog_sec1
1
2013-06-27  Commit Queue  <commit-queue@webkit.org>
2
3
        Unreviewed, rolling out r152074.
4
        http://trac.webkit.org/changeset/152074
5
        https://bugs.webkit.org/show_bug.cgi?id=118137
6
7
        It caused lots of layout and API test crash on Qt Wk2.
8
        (Requested by kadam on #webkit).
9
10
        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
11
        (WebKit::CoordinatedLayerTreeHost::~CoordinatedLayerTreeHost):
12
        (WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
13
        (WebKit::CoordinatedLayerTreeHost::setRootCompositingLayer):
14
        (WebKit::CoordinatedLayerTreeHost::invalidate):
15
        (WebKit::CoordinatedLayerTreeHost::forceRepaint):
16
        (WebKit::CoordinatedLayerTreeHost::sizeDidChange):
17
        (WebKit::CoordinatedLayerTreeHost::flushPendingLayerChanges):
18
        (WebKit::CoordinatedLayerTreeHost::clearPendingStateChanges):
19
        (WebKit::CoordinatedLayerTreeHost::initializeRootCompositingLayerIfNeeded):
20
        (WebKit::CoordinatedLayerTreeHost::syncLayerState):
21
        (WebKit::CoordinatedLayerTreeHost::prepareCustomFilterProxiesIfNeeded):
22
        (WebKit::CoordinatedLayerTreeHost::checkCustomFilterProgramProxies):
23
        (WebKit::CoordinatedLayerTreeHost::removeCustomFilterProgramProxy):
24
        (WebKit::CoordinatedLayerTreeHost::detachLayer):
25
        (WebKit::CoordinatedLayerTreeHost::performScheduledLayerFlush):
26
        (WebKit::CoordinatedLayerTreeHost::syncDisplayState):
27
        (WebKit::CoordinatedLayerTreeHost::didPerformScheduledLayerFlush):
28
        (WebKit::CoordinatedLayerTreeHost::createPageOverlayLayer):
29
        (WebKit::CoordinatedLayerTreeHost::createImageBackingIfNeeded):
30
        (WebKit::CoordinatedLayerTreeHost::createImageBacking):
31
        (WebKit::CoordinatedLayerTreeHost::updateImageBacking):
32
        (WebKit::CoordinatedLayerTreeHost::clearImageBackingContents):
33
        (WebKit::CoordinatedLayerTreeHost::removeImageBacking):
34
        (WebKit::CoordinatedLayerTreeHost::flushPendingImageBackingChanges):
35
        (WebKit::CoordinatedLayerTreeHost::notifyAnimationStarted):
36
        (WebKit::CoordinatedLayerTreeHost::notifyFlushRequired):
37
        (WebKit::CoordinatedLayerTreeHost::paintContents):
38
        (WebKit::CoordinatedLayerTreeHost::createGraphicsLayer):
39
        (WebKit::CoordinatedLayerTreeHost::deviceScaleFactor):
40
        (WebKit::CoordinatedLayerTreeHost::pageScaleFactor):
41
        (WebKit::CoordinatedLayerTreeHost::createUpdateAtlas):
42
        (WebKit::CoordinatedLayerTreeHost::removeUpdateAtlas):
43
        (WebKit::CoordinatedLayerTreeHost::visibleContentsRect):
44
        (WebKit::CoordinatedLayerTreeHost::mainContentsLayer):
45
        (WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect):
46
        (WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
47
        (WebKit::CoordinatedLayerTreeHost::graphicsLayerFactory):
48
        (WebKit::CoordinatedLayerTreeHost::scheduleAnimation):
49
        (WebKit::CoordinatedLayerTreeHost::renderNextFrame):
50
        (WebKit::CoordinatedLayerTreeHost::purgeBackingStores):
51
        (WebKit::CoordinatedLayerTreeHost::paintToSurface):
52
        (WebKit::CoordinatedLayerTreeHost::scheduleReleaseInactiveAtlases):
53
        (WebKit::CoordinatedLayerTreeHost::releaseInactiveAtlasesTimerFired):
54
        (WebKit::CoordinatedLayerTreeHost::commitScrollOffset):
55
        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
56
        * WebProcess/WebPage/LayerTreeHost.h:
57
        (WebKit::LayerTreeHost::setVisibleContentsRect):
58
        (WebKit::LayerTreeHost::renderNextFrame):
59
        (WebKit::LayerTreeHost::purgeBackingStores):
60
1
2013-06-27  Xabier Rodriguez Calvar  <calvaris@igalia.com>
61
2013-06-27  Xabier Rodriguez Calvar  <calvaris@igalia.com>
2
62
3
        Fixing some compiler warnings
63
        Fixing some compiler warnings
- a/Source/WebCore/CMakeLists.txt -1 lines
Lines 1978-1984 set(WebCore_SOURCES a/Source/WebCore/CMakeLists.txt_sec1
1978
    platform/graphics/filters/SpotLightSource.cpp
1978
    platform/graphics/filters/SpotLightSource.cpp
1979
1979
1980
    platform/graphics/texmap/coordinated/AreaAllocator.cpp
1980
    platform/graphics/texmap/coordinated/AreaAllocator.cpp
1981
    platform/graphics/texmap/coordinated/CompositingCoordinator.cpp
1982
    platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp
1981
    platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp
1983
    platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
1982
    platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
1984
    platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp
1983
    platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp
- a/Source/WebCore/Target.pri -2 lines
Lines 4089-4095 use?(3D_GRAPHICS) { a/Source/WebCore/Target.pri_sec1
4089
        platform/graphics/texmap/TextureMapperGL.h \
4089
        platform/graphics/texmap/TextureMapperGL.h \
4090
        platform/graphics/texmap/TextureMapperShaderProgram.h \
4090
        platform/graphics/texmap/TextureMapperShaderProgram.h \
4091
        platform/graphics/texmap/coordinated/AreaAllocator.h \
4091
        platform/graphics/texmap/coordinated/AreaAllocator.h \
4092
        platform/graphics/texmap/coordinated/CompositingCoordinator.h \
4093
        platform/graphics/texmap/coordinated/CoordinatedBackingStore.h \
4092
        platform/graphics/texmap/coordinated/CoordinatedBackingStore.h \
4094
        platform/graphics/texmap/coordinated/CoordinatedCustomFilterOperation.h \
4093
        platform/graphics/texmap/coordinated/CoordinatedCustomFilterOperation.h \
4095
        platform/graphics/texmap/coordinated/CoordinatedCustomFilterProgram.h \
4094
        platform/graphics/texmap/coordinated/CoordinatedCustomFilterProgram.h \
Lines 4125-4131 use?(3D_GRAPHICS) { a/Source/WebCore/Target.pri_sec2
4125
        platform/graphics/texmap/TextureMapperGL.cpp \
4124
        platform/graphics/texmap/TextureMapperGL.cpp \
4126
        platform/graphics/texmap/TextureMapperShaderProgram.cpp \
4125
        platform/graphics/texmap/TextureMapperShaderProgram.cpp \
4127
        platform/graphics/texmap/coordinated/AreaAllocator.cpp \
4126
        platform/graphics/texmap/coordinated/AreaAllocator.cpp \
4128
        platform/graphics/texmap/coordinated/CompositingCoordinator.cpp \
4129
        platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp \
4127
        platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp \
4130
        platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp \
4128
        platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp \
4131
        platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp \
4129
        platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp \
- a/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp -434 lines
Lines 1-434 a/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp_sec1
1
/*
2
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
3
 * Copyright (C) 2013 Company 100, Inc. All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#include "config.h"
28
29
#if USE(COORDINATED_GRAPHICS)
30
#include "CompositingCoordinator.h"
31
32
#include "Frame.h"
33
#include "FrameView.h"
34
#include "GraphicsContext.h"
35
#include "InspectorController.h"
36
#include "Page.h"
37
#include "Settings.h"
38
#include <wtf/CurrentTime.h>
39
#include <wtf/TemporaryChange.h>
40
41
namespace WebCore {
42
43
PassOwnPtr<CompositingCoordinator> CompositingCoordinator::create(Page* page, CompositingCoordinator::Client* client)
44
{
45
    return adoptPtr(new CompositingCoordinator(page, client));
46
}
47
48
CompositingCoordinator::~CompositingCoordinator()
49
{
50
    purgeBackingStores();
51
52
    LayerMap::iterator end = m_registeredLayers.end();
53
    for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it)
54
        it->value->setCoordinator(0);
55
}
56
57
CompositingCoordinator::CompositingCoordinator(Page* page, CompositingCoordinator::Client* client)
58
    : m_page(page)
59
    , m_client(client)
60
    , m_rootCompositingLayer(0)
61
    , m_isPurging(false)
62
    , m_isFlushingLayerChanges(false)
63
    , m_shouldSyncFrame(false)
64
    , m_didInitializeRootCompositingLayer(false)
65
    , m_releaseInactiveAtlasesTimer(this, &CompositingCoordinator::releaseInactiveAtlasesTimerFired)
66
#if ENABLE(REQUEST_ANIMATION_FRAME)
67
    , m_lastAnimationServiceTime(0)
68
#endif
69
{
70
    m_page->settings()->setApplyDeviceScaleFactorInCompositor(true);
71
72
    // This is a temporary way to enable this only in the GL case, until TextureMapperImageBuffer is removed.
73
    // See https://bugs.webkit.org/show_bug.cgi?id=114869
74
    CoordinatedGraphicsLayer::setShouldSupportContentsTiling(true);
75
}
76
77
void CompositingCoordinator::setRootCompositingLayer(GraphicsLayer* layer)
78
{
79
    if (m_rootCompositingLayer)
80
        m_rootCompositingLayer->removeFromParent();
81
82
    m_rootCompositingLayer = layer;
83
    if (m_rootCompositingLayer)
84
        m_rootLayer->addChildAtIndex(m_rootCompositingLayer, 0);
85
}
86
87
void CompositingCoordinator::sizeDidChange(const IntSize& newSize)
88
{
89
    m_rootLayer->setSize(newSize);
90
    m_client->notifyFlushRequired();
91
}
92
93
bool CompositingCoordinator::flushPendingLayerChanges()
94
{
95
    TemporaryChange<bool> protector(m_isFlushingLayerChanges, true);
96
97
    initializeRootCompositingLayerIfNeeded();
98
99
    m_rootLayer->flushCompositingStateForThisLayerOnly();
100
    m_client->didFlushRootLayer();
101
102
    bool didSync = m_page->mainFrame()->view()->flushCompositingStateIncludingSubframes();
103
104
    toCoordinatedGraphicsLayer(m_rootLayer.get())->updateContentBuffersIncludingSubLayers();
105
    toCoordinatedGraphicsLayer(m_rootLayer.get())->syncPendingStateChangesIncludingSubLayers();
106
107
    flushPendingImageBackingChanges();
108
109
    if (m_shouldSyncFrame) {
110
        didSync = true;
111
112
        if (m_rootCompositingLayer) {
113
            m_state.contentsSize = roundedIntSize(m_rootCompositingLayer->size());
114
            if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
115
                m_state.coveredRect = contentsLayer->coverRect();
116
        }
117
        m_state.scrollPosition = m_visibleContentsRect.location();
118
119
        m_client->commitSceneState(m_state);
120
121
        clearPendingStateChanges();
122
        m_shouldSyncFrame = false;
123
    }
124
125
    return didSync;
126
}
127
128
void CompositingCoordinator::syncDisplayState()
129
{
130
#if ENABLE(INSPECTOR)
131
    m_page->inspectorController()->didBeginFrame();
132
#endif
133
134
#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER) && !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
135
    // Make sure that any previously registered animation callbacks are being executed before we flush the layers.
136
    m_lastAnimationServiceTime = WTF::monotonicallyIncreasingTime();
137
    m_page->mainFrame()->view()->serviceScriptedAnimations(m_lastAnimationServiceTime);
138
#endif
139
    m_page->mainFrame()->view()->updateLayoutAndStyleIfNeededRecursive();
140
}
141
142
#if ENABLE(REQUEST_ANIMATION_FRAME)
143
double CompositingCoordinator::nextAnimationServiceTime() const
144
{
145
    // According to the requestAnimationFrame spec, rAF callbacks should not be faster than 60FPS.
146
    static const double MinimalTimeoutForAnimations = 1. / 60.;
147
    return std::max<double>(0., MinimalTimeoutForAnimations - WTF::monotonicallyIncreasingTime() + m_lastAnimationServiceTime);
148
}
149
#endif
150
151
void CompositingCoordinator::clearPendingStateChanges()
152
{
153
    m_state.layersToCreate.clear();
154
    m_state.layersToUpdate.clear();
155
    m_state.layersToRemove.clear();
156
157
    m_state.imagesToCreate.clear();
158
    m_state.imagesToRemove.clear();
159
    m_state.imagesToUpdate.clear();
160
    m_state.imagesToClear.clear();
161
162
    m_state.updateAtlasesToCreate.clear();
163
    m_state.updateAtlasesToRemove.clear();
164
165
#if ENABLE(CSS_SHADERS)
166
    m_state.customFiltersToCreate.clear();
167
    m_state.customFiltersToRemove.clear();
168
#endif
169
}
170
171
void CompositingCoordinator::initializeRootCompositingLayerIfNeeded()
172
{
173
    if (m_didInitializeRootCompositingLayer)
174
        return;
175
176
    m_state.rootCompositingLayer = toCoordinatedGraphicsLayer(m_rootLayer.get())->id();
177
    m_didInitializeRootCompositingLayer = true;
178
    m_shouldSyncFrame = true;
179
}
180
181
void CompositingCoordinator::createRootLayer(const IntSize& size)
182
{
183
    ASSERT(!m_rootLayer);
184
    // Create a root layer.
185
    m_rootLayer = GraphicsLayer::create(this, this);
186
#ifndef NDEBUG
187
    m_rootLayer->setName("CompositingCoordinator root layer");
188
#endif
189
    m_rootLayer->setDrawsContent(false);
190
    m_rootLayer->setSize(size);
191
}
192
193
void CompositingCoordinator::syncLayerState(CoordinatedLayerID id, CoordinatedGraphicsLayerState& state)
194
{
195
    m_shouldSyncFrame = true;
196
    m_client->willSyncLayerState(state);
197
    m_state.layersToUpdate.append(std::make_pair(id, state));
198
}
199
200
PassRefPtr<CoordinatedImageBacking> CompositingCoordinator::createImageBackingIfNeeded(Image* image)
201
{
202
    CoordinatedImageBackingID imageID = CoordinatedImageBacking::getCoordinatedImageBackingID(image);
203
    ImageBackingMap::iterator it = m_imageBackings.find(imageID);
204
    RefPtr<CoordinatedImageBacking> imageBacking;
205
    if (it == m_imageBackings.end()) {
206
        imageBacking = CoordinatedImageBacking::create(this, image);
207
        m_imageBackings.add(imageID, imageBacking);
208
    } else
209
        imageBacking = it->value;
210
211
    return imageBacking;
212
}
213
214
void CompositingCoordinator::createImageBacking(CoordinatedImageBackingID imageID)
215
{
216
    m_state.imagesToCreate.append(imageID);
217
}
218
219
void CompositingCoordinator::updateImageBacking(CoordinatedImageBackingID imageID, PassRefPtr<CoordinatedSurface> coordinatedSurface)
220
{
221
    m_shouldSyncFrame = true;
222
    m_state.imagesToUpdate.append(std::make_pair(imageID, coordinatedSurface));
223
}
224
225
void CompositingCoordinator::clearImageBackingContents(CoordinatedImageBackingID imageID)
226
{
227
    m_shouldSyncFrame = true;
228
    m_state.imagesToClear.append(imageID);
229
}
230
231
void CompositingCoordinator::removeImageBacking(CoordinatedImageBackingID imageID)
232
{
233
    if (m_isPurging)
234
        return;
235
236
    ASSERT(m_imageBackings.contains(imageID));
237
    m_imageBackings.remove(imageID);
238
239
    m_state.imagesToRemove.append(imageID);
240
}
241
242
void CompositingCoordinator::flushPendingImageBackingChanges()
243
{
244
    ImageBackingMap::iterator end = m_imageBackings.end();
245
    for (ImageBackingMap::iterator iter = m_imageBackings.begin(); iter != end; ++iter)
246
        iter->value->update();
247
}
248
249
void CompositingCoordinator::notifyAnimationStarted(const GraphicsLayer*, double /* time */)
250
{
251
}
252
253
void CompositingCoordinator::notifyFlushRequired(const GraphicsLayer*)
254
{
255
    m_client->notifyFlushRequired();
256
}
257
258
259
void CompositingCoordinator::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase, const IntRect& clipRect)
260
{
261
    m_client->paintLayerContents(graphicsLayer, graphicsContext, clipRect);
262
}
263
264
PassOwnPtr<GraphicsLayer> CompositingCoordinator::createGraphicsLayer(GraphicsLayerClient* client)
265
{
266
    CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(client);
267
    layer->setCoordinator(this);
268
    m_registeredLayers.add(layer->id(), layer);
269
    m_state.layersToCreate.append(layer->id());
270
    layer->setNeedsVisibleRectAdjustment();
271
    m_client->notifyFlushRequired();
272
    return adoptPtr(layer);
273
}
274
275
float CompositingCoordinator::deviceScaleFactor() const
276
{
277
    return m_page->deviceScaleFactor();
278
}
279
280
float CompositingCoordinator::pageScaleFactor() const
281
{
282
    return m_page->pageScaleFactor();
283
}
284
285
void CompositingCoordinator::createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface> coordinatedSurface)
286
{
287
    m_state.updateAtlasesToCreate.append(std::make_pair(atlasID, coordinatedSurface));
288
}
289
290
void CompositingCoordinator::removeUpdateAtlas(uint32_t atlasID)
291
{
292
    if (m_isPurging)
293
        return;
294
    m_state.updateAtlasesToRemove.append(atlasID);
295
}
296
297
FloatRect CompositingCoordinator::visibleContentsRect() const
298
{
299
    return m_visibleContentsRect;
300
}
301
302
CoordinatedGraphicsLayer* CompositingCoordinator::mainContentsLayer()
303
{
304
    if (!m_rootCompositingLayer)
305
        return 0;
306
307
    return toCoordinatedGraphicsLayer(m_rootCompositingLayer)->findFirstDescendantWithContentsRecursively();
308
}
309
310
void CompositingCoordinator::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector)
311
{
312
    // A zero trajectoryVector indicates that tiles all around the viewport are requested.
313
    if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
314
        contentsLayer->setVisibleContentRectTrajectoryVector(trajectoryVector);
315
316
    bool contentsRectDidChange = rect != m_visibleContentsRect;
317
    if (contentsRectDidChange) {
318
        m_visibleContentsRect = rect;
319
320
        LayerMap::iterator end = m_registeredLayers.end();
321
        for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it)
322
            it->value->setNeedsVisibleRectAdjustment();
323
    }
324
325
    FrameView* view = m_page->mainFrame()->view();
326
    if (view->useFixedLayout()) {
327
        // Round the rect instead of enclosing it to make sure that its size stays
328
        // the same while panning. This can have nasty effects on layout.
329
        view->setFixedVisibleContentRect(roundedIntRect(rect));
330
    }
331
}
332
333
void CompositingCoordinator::deviceOrPageScaleFactorChanged()
334
{
335
    m_rootLayer->deviceOrPageScaleFactorChanged();
336
}
337
338
void CompositingCoordinator::detachLayer(CoordinatedGraphicsLayer* layer)
339
{
340
    if (m_isPurging)
341
        return;
342
343
    m_registeredLayers.remove(layer->id());
344
345
    size_t index = m_state.layersToCreate.find(layer->id());
346
    if (index != notFound) {
347
        m_state.layersToCreate.remove(index);
348
        return;
349
    }
350
351
    m_state.layersToRemove.append(layer->id());
352
    m_client->notifyFlushRequired();
353
}
354
355
void CompositingCoordinator::commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset)
356
{
357
    LayerMap::iterator i = m_registeredLayers.find(layerID);
358
    if (i == m_registeredLayers.end())
359
        return;
360
361
    i->value->commitScrollOffset(offset);
362
}
363
364
void CompositingCoordinator::renderNextFrame()
365
{
366
    for (unsigned i = 0; i < m_updateAtlases.size(); ++i)
367
        m_updateAtlases[i]->didSwapBuffers();
368
}
369
370
void CompositingCoordinator::purgeBackingStores()
371
{
372
    TemporaryChange<bool> purgingToggle(m_isPurging, true);
373
374
    LayerMap::iterator end = m_registeredLayers.end();
375
    for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it)
376
        it->value->purgeBackingStores();
377
378
    m_imageBackings.clear();
379
    m_updateAtlases.clear();
380
}
381
382
bool CompositingCoordinator::paintToSurface(const IntSize& size, CoordinatedSurface::Flags flags, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client* client)
383
{
384
    for (unsigned i = 0; i < m_updateAtlases.size(); ++i) {
385
        UpdateAtlas* atlas = m_updateAtlases[i].get();
386
        if (atlas->supportsAlpha() == (flags & CoordinatedSurface::SupportsAlpha)) {
387
            // This will be false if there is no available buffer space.
388
            if (atlas->paintOnAvailableBuffer(size, atlasID, offset, client))
389
                return true;
390
        }
391
    }
392
393
    static const int ScratchBufferDimension = 1024; // Should be a power of two.
394
    m_updateAtlases.append(adoptPtr(new UpdateAtlas(this, ScratchBufferDimension, flags)));
395
    scheduleReleaseInactiveAtlases();
396
    return m_updateAtlases.last()->paintOnAvailableBuffer(size, atlasID, offset, client);
397
}
398
399
const double ReleaseInactiveAtlasesTimerInterval = 0.5;
400
401
void CompositingCoordinator::scheduleReleaseInactiveAtlases()
402
{
403
    if (!m_releaseInactiveAtlasesTimer.isActive())
404
        m_releaseInactiveAtlasesTimer.startRepeating(ReleaseInactiveAtlasesTimerInterval);
405
}
406
407
void CompositingCoordinator::releaseInactiveAtlasesTimerFired(Timer<CompositingCoordinator>*)
408
{
409
    // We always want to keep one atlas for non-composited content.
410
    OwnPtr<UpdateAtlas> atlasToKeepAnyway;
411
    bool foundActiveAtlasForNonCompositedContent = false;
412
    for (int i = m_updateAtlases.size() - 1;  i >= 0; --i) {
413
        UpdateAtlas* atlas = m_updateAtlases[i].get();
414
        if (!atlas->isInUse())
415
            atlas->addTimeInactive(ReleaseInactiveAtlasesTimerInterval);
416
        bool usableForNonCompositedContent = !atlas->supportsAlpha();
417
        if (atlas->isInactive()) {
418
            if (!foundActiveAtlasForNonCompositedContent && !atlasToKeepAnyway && usableForNonCompositedContent)
419
                atlasToKeepAnyway = m_updateAtlases[i].release();
420
            m_updateAtlases.remove(i);
421
        } else if (usableForNonCompositedContent)
422
            foundActiveAtlasForNonCompositedContent = true;
423
    }
424
425
    if (!foundActiveAtlasForNonCompositedContent && atlasToKeepAnyway)
426
        m_updateAtlases.append(atlasToKeepAnyway.release());
427
428
    if (m_updateAtlases.size() <= 1)
429
        m_releaseInactiveAtlasesTimer.stop();
430
}
431
432
} // namespace WebCore
433
434
#endif // USE(COORDINATED_GRAPHICS)
- a/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.h -168 lines
Lines 1-168 a/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.h_sec1
1
/*
2
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
3
 * Copyright (C) 2013 Company 100, Inc. All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#ifndef CompositingCoordinator_h
28
#define CompositingCoordinator_h
29
30
#if USE(COORDINATED_GRAPHICS)
31
32
#include "CoordinatedGraphicsLayer.h"
33
#include "CoordinatedGraphicsState.h"
34
#include "CoordinatedImageBacking.h"
35
#include "FloatPoint.h"
36
#include "GraphicsLayerClient.h"
37
#include "GraphicsLayerFactory.h"
38
#include "IntRect.h"
39
#include "Timer.h"
40
#include "UpdateAtlas.h"
41
#include <wtf/OwnPtr.h>
42
43
#if ENABLE(CSS_SHADERS)
44
#include "FilterOperations.h"
45
#endif
46
47
namespace WebCore {
48
49
class Page;
50
class GraphicsContext;
51
class GraphicsLayer;
52
class CoordinatedSurface;
53
54
class CompositingCoordinator : public GraphicsLayerClient
55
    , public CoordinatedGraphicsLayerClient
56
    , public CoordinatedImageBacking::Client
57
    , public UpdateAtlas::Client
58
    , public GraphicsLayerFactory {
59
    WTF_MAKE_NONCOPYABLE(CompositingCoordinator); WTF_MAKE_FAST_ALLOCATED;
60
public:
61
    class Client {
62
    public:
63
        virtual void didFlushRootLayer() = 0;
64
        virtual void willSyncLayerState(CoordinatedGraphicsLayerState&) = 0;
65
        virtual void notifyFlushRequired() = 0;
66
        virtual void commitSceneState(CoordinatedGraphicsState&) = 0;
67
        virtual void paintLayerContents(const GraphicsLayer*, GraphicsContext&, const IntRect& clipRect) = 0;
68
    };
69
70
    static PassOwnPtr<CompositingCoordinator> create(Page*, CompositingCoordinator::Client*);
71
    virtual ~CompositingCoordinator();
72
73
    void setRootCompositingLayer(GraphicsLayer*);
74
    void sizeDidChange(const IntSize& newSize);
75
    void deviceOrPageScaleFactorChanged();
76
77
    void setVisibleContentsRect(const FloatRect&, const FloatPoint&);
78
    void renderNextFrame();
79
    void purgeBackingStores();
80
    void commitScrollOffset(uint32_t layerID, const IntSize& offset);
81
82
    void createRootLayer(const IntSize&);
83
    void clearRootLayer() { m_rootLayer = nullptr; }
84
    GraphicsLayer* rootLayer() const { return m_rootLayer.get(); }
85
    CoordinatedGraphicsLayer* mainContentsLayer();
86
87
    bool flushPendingLayerChanges();
88
    CoordinatedGraphicsState& state() { return m_state; }
89
90
    void syncDisplayState();
91
92
#if ENABLE(REQUEST_ANIMATION_FRAME)
93
    double nextAnimationServiceTime() const;
94
#endif
95
96
private:
97
    CompositingCoordinator(Page*, CompositingCoordinator::Client*);
98
99
    // GraphicsLayerClient
100
    virtual void notifyAnimationStarted(const GraphicsLayer*, double time) OVERRIDE;
101
    virtual void notifyFlushRequired(const GraphicsLayer*) OVERRIDE;
102
    virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& clipRect) OVERRIDE;
103
    virtual float deviceScaleFactor() const OVERRIDE;
104
    virtual float pageScaleFactor() const OVERRIDE;
105
106
    // CoordinatedImageBacking::Client
107
    virtual void createImageBacking(CoordinatedImageBackingID) OVERRIDE;
108
    virtual void updateImageBacking(CoordinatedImageBackingID, PassRefPtr<CoordinatedSurface>) OVERRIDE;
109
    virtual void clearImageBackingContents(CoordinatedImageBackingID) OVERRIDE;
110
    virtual void removeImageBacking(CoordinatedImageBackingID) OVERRIDE;
111
112
    // CoordinatedGraphicsLayerClient
113
    virtual bool isFlushingLayerChanges() const OVERRIDE { return m_isFlushingLayerChanges; }
114
    virtual FloatRect visibleContentsRect() const OVERRIDE;
115
    virtual PassRefPtr<CoordinatedImageBacking> createImageBackingIfNeeded(Image*) OVERRIDE;
116
    virtual void detachLayer(CoordinatedGraphicsLayer*) OVERRIDE;
117
    virtual bool paintToSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags, uint32_t& /* atlasID */, WebCore::IntPoint&, WebCore::CoordinatedSurface::Client*) OVERRIDE;
118
    virtual void syncLayerState(CoordinatedLayerID, CoordinatedGraphicsLayerState&) OVERRIDE;
119
120
    // UpdateAtlas::Client
121
    virtual void createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface>) OVERRIDE;
122
    virtual void removeUpdateAtlas(uint32_t atlasID) OVERRIDE;
123
124
    // GraphicsLayerFactory
125
    virtual PassOwnPtr<GraphicsLayer> createGraphicsLayer(GraphicsLayerClient*) OVERRIDE;
126
127
    void initializeRootCompositingLayerIfNeeded();
128
    void flushPendingImageBackingChanges();
129
    void clearPendingStateChanges();
130
131
    void scheduleReleaseInactiveAtlases();
132
133
    void releaseInactiveAtlasesTimerFired(Timer<CompositingCoordinator>*);
134
135
    Page* m_page;
136
    CompositingCoordinator::Client* m_client;
137
138
    OwnPtr<GraphicsLayer> m_rootLayer;
139
    GraphicsLayer* m_rootCompositingLayer;
140
141
    CoordinatedGraphicsState m_state;
142
143
    typedef HashMap<CoordinatedLayerID, CoordinatedGraphicsLayer*> LayerMap;
144
    LayerMap m_registeredLayers;
145
    typedef HashMap<CoordinatedImageBackingID, RefPtr<CoordinatedImageBacking> > ImageBackingMap;
146
    ImageBackingMap m_imageBackings;
147
    Vector<OwnPtr<UpdateAtlas> > m_updateAtlases;
148
149
    // We don't send the messages related to releasing resources to renderer during purging, because renderer already had removed all resources.
150
    bool m_isPurging;
151
    bool m_isFlushingLayerChanges;
152
153
    FloatRect m_visibleContentsRect;
154
155
    bool m_shouldSyncFrame;
156
    bool m_didInitializeRootCompositingLayer;
157
    Timer<CompositingCoordinator> m_releaseInactiveAtlasesTimer;
158
159
#if ENABLE(REQUEST_ANIMATION_FRAME)
160
    double m_lastAnimationServiceTime;
161
#endif
162
};
163
164
}
165
166
#endif
167
168
#endif // CompositingCoordinator_h
- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp -62 / +384 lines
Lines 40-47 a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec1
40
#include "WebPageProxyMessages.h"
40
#include "WebPageProxyMessages.h"
41
#include <WebCore/Frame.h>
41
#include <WebCore/Frame.h>
42
#include <WebCore/FrameView.h>
42
#include <WebCore/FrameView.h>
43
#include <WebCore/GraphicsSurface.h>
44
#include <WebCore/InspectorController.h>
45
#include <WebCore/Page.h>
46
#include <WebCore/RenderLayer.h>
47
#include <WebCore/RenderLayerBacking.h>
48
#include <WebCore/RenderLayerCompositor.h>
49
#include <WebCore/RenderView.h>
43
#include <WebCore/Settings.h>
50
#include <WebCore/Settings.h>
51
#include <WebCore/SurfaceUpdateInfo.h>
52
#include <WebCore/TextureMapperPlatformLayer.h>
44
#include <wtf/CurrentTime.h>
53
#include <wtf/CurrentTime.h>
54
#include <wtf/TemporaryChange.h>
45
55
46
#if ENABLE(CSS_SHADERS)
56
#if ENABLE(CSS_SHADERS)
47
#include "CustomFilterValidatedProgram.h"
57
#include "CustomFilterValidatedProgram.h"
Lines 62-87 CoordinatedLayerTreeHost::~CoordinatedLayerTreeHost() a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec2
62
#if ENABLE(CSS_SHADERS)
72
#if ENABLE(CSS_SHADERS)
63
    disconnectCustomFilterPrograms();
73
    disconnectCustomFilterPrograms();
64
#endif
74
#endif
75
    purgeBackingStores();
76
77
    LayerMap::iterator end = m_registeredLayers.end();
78
    for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it)
79
        it->value->setCoordinator(0);
65
}
80
}
66
81
67
CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage)
82
CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage)
68
    : LayerTreeHost(webPage)
83
    : LayerTreeHost(webPage)
84
    , m_rootCompositingLayer(0)
69
    , m_notifyAfterScheduledLayerFlush(false)
85
    , m_notifyAfterScheduledLayerFlush(false)
70
    , m_isValid(true)
86
    , m_isValid(true)
87
    , m_isPurging(false)
88
    , m_isFlushingLayerChanges(false)
89
    , m_waitingForUIProcess(true)
71
    , m_isSuspended(false)
90
    , m_isSuspended(false)
72
    , m_isWaitingForRenderer(true)
91
    , m_shouldSyncFrame(false)
92
    , m_didInitializeRootCompositingLayer(false)
73
    , m_layerFlushTimer(this, &CoordinatedLayerTreeHost::layerFlushTimerFired)
93
    , m_layerFlushTimer(this, &CoordinatedLayerTreeHost::layerFlushTimerFired)
94
    , m_releaseInactiveAtlasesTimer(this, &CoordinatedLayerTreeHost::releaseInactiveAtlasesTimerFired)
74
    , m_layerFlushSchedulingEnabled(true)
95
    , m_layerFlushSchedulingEnabled(true)
75
    , m_forceRepaintAsyncCallbackID(0)
96
    , m_forceRepaintAsyncCallbackID(0)
97
    , m_animationsLocked(false)
98
#if ENABLE(REQUEST_ANIMATION_FRAME)
99
    , m_lastAnimationServiceTime(0)
100
#endif
76
{
101
{
77
    m_coordinator = CompositingCoordinator::create(webPage->corePage(), this);
102
    m_webPage->corePage()->settings()->setApplyDeviceScaleFactorInCompositor(true);
78
103
79
    m_coordinator->createRootLayer(webPage->size());
104
    // Create a root layer.
80
    m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(m_coordinator->rootLayer())->id();
105
    m_rootLayer = GraphicsLayer::create(this, this);
106
#ifndef NDEBUG
107
    m_rootLayer->setName("CoordinatedLayerTreeHost root layer");
108
#endif
109
    m_rootLayer->setDrawsContent(false);
110
    m_rootLayer->setSize(m_webPage->size());
111
    m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(m_rootLayer.get())->id();
81
112
82
    CoordinatedSurface::setFactory(createCoordinatedSurface);
113
    CoordinatedSurface::setFactory(createCoordinatedSurface);
83
114
84
    if (webPage->hasPageOverlay())
115
    // This is a temporary way to enable this only in the GL case, until TextureMapperImageBuffer is removed.
116
    // See https://bugs.webkit.org/show_bug.cgi?id=114869
117
    CoordinatedGraphicsLayer::setShouldSupportContentsTiling(true);
118
119
    if (m_webPage->hasPageOverlay())
85
        createPageOverlayLayer();
120
        createPageOverlayLayer();
86
121
87
    scheduleLayerFlush();
122
    scheduleLayerFlush();
Lines 123-129 void CoordinatedLayerTreeHost::setShouldNotifyAfterNextScheduledLayerFlush(bool a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec3
123
158
124
void CoordinatedLayerTreeHost::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer)
159
void CoordinatedLayerTreeHost::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer)
125
{
160
{
126
    m_coordinator->setRootCompositingLayer(graphicsLayer);
161
    if (m_rootCompositingLayer)
162
        m_rootCompositingLayer->removeFromParent();
163
164
    m_rootCompositingLayer = graphicsLayer;
165
    if (m_rootCompositingLayer)
166
        m_rootLayer->addChildAtIndex(m_rootCompositingLayer, 0);
127
}
167
}
128
168
129
void CoordinatedLayerTreeHost::invalidate()
169
void CoordinatedLayerTreeHost::invalidate()
Lines 131-137 void CoordinatedLayerTreeHost::invalidate() a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec4
131
    cancelPendingLayerFlush();
171
    cancelPendingLayerFlush();
132
172
133
    ASSERT(m_isValid);
173
    ASSERT(m_isValid);
134
    m_coordinator->clearRootLayer();
174
    m_rootLayer = nullptr;
135
    m_isValid = false;
175
    m_isValid = false;
136
}
176
}
137
177
Lines 139-150 void CoordinatedLayerTreeHost::forceRepaint() a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec5
139
{
179
{
140
    // This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely.
180
    // This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely.
141
    // Instead we are just triggering forceRepaint. But we still want to have the scripted animation callbacks being executed.
181
    // Instead we are just triggering forceRepaint. But we still want to have the scripted animation callbacks being executed.
142
    m_coordinator->syncDisplayState();
182
    syncDisplayState();
143
183
144
    // We need to schedule another flush, otherwise the forced paint might cancel a later expected flush.
184
    // We need to schedule another flush, otherwise the forced paint might cancel a later expected flush.
145
    // This is aligned with LayerTreeHostCA.
185
    // This is aligned with LayerTreeHostCA.
146
    scheduleLayerFlush();
186
    scheduleLayerFlush();
147
    m_coordinator->flushPendingLayerChanges();
187
    flushPendingLayerChanges();
148
}
188
}
149
189
150
bool CoordinatedLayerTreeHost::forceRepaintAsync(uint64_t callbackID)
190
bool CoordinatedLayerTreeHost::forceRepaintAsync(uint64_t callbackID)
Lines 158-164 bool CoordinatedLayerTreeHost::forceRepaintAsync(uint64_t callbackID) a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec6
158
198
159
void CoordinatedLayerTreeHost::sizeDidChange(const WebCore::IntSize& newSize)
199
void CoordinatedLayerTreeHost::sizeDidChange(const WebCore::IntSize& newSize)
160
{
200
{
161
    m_coordinator->sizeDidChange(newSize);
201
    m_rootLayer->setSize(newSize);
162
    scheduleLayerFlush();
202
    scheduleLayerFlush();
163
}
203
}
164
204
Lines 193-241 void CoordinatedLayerTreeHost::setPageOverlayOpacity(PageOverlay*, float value) a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec7
193
    scheduleLayerFlush();
233
    scheduleLayerFlush();
194
}
234
}
195
235
196
void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector)
236
bool CoordinatedLayerTreeHost::flushPendingLayerChanges()
197
{
237
{
198
    m_coordinator->setVisibleContentsRect(rect, trajectoryVector);
238
    if (m_waitingForUIProcess)
199
    scheduleLayerFlush();
239
        return false;
240
241
    TemporaryChange<bool> protector(m_isFlushingLayerChanges, true);
242
243
    initializeRootCompositingLayerIfNeeded();
244
245
    m_rootLayer->flushCompositingStateForThisLayerOnly();
246
    if (m_pageOverlayLayer)
247
        m_pageOverlayLayer->flushCompositingStateForThisLayerOnly();
248
249
    bool didSync = m_webPage->corePage()->mainFrame()->view()->flushCompositingStateIncludingSubframes();
250
251
    toCoordinatedGraphicsLayer(m_rootLayer.get())->updateContentBuffersIncludingSubLayers();
252
    toCoordinatedGraphicsLayer(m_rootLayer.get())->syncPendingStateChangesIncludingSubLayers();
253
254
    flushPendingImageBackingChanges();
255
256
    if (m_shouldSyncFrame) {
257
        didSync = true;
258
259
        if (m_rootCompositingLayer) {
260
            m_state.contentsSize = roundedIntSize(m_rootCompositingLayer->size());
261
            if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
262
                m_state.coveredRect = contentsLayer->coverRect();
263
        }
264
265
        m_state.scrollPosition = m_visibleContentsRect.location();
266
267
        m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CommitCoordinatedGraphicsState(m_state));
268
269
        clearPendingStateChanges();
270
        m_waitingForUIProcess = true;
271
        m_shouldSyncFrame = false;
272
    }
273
274
    if (m_forceRepaintAsyncCallbackID) {
275
        m_webPage->send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsyncCallbackID));
276
        m_forceRepaintAsyncCallbackID = 0;
277
    }
278
279
    return didSync;
200
}
280
}
201
281
202
void CoordinatedLayerTreeHost::renderNextFrame()
282
void CoordinatedLayerTreeHost::clearPendingStateChanges()
203
{
283
{
204
    m_coordinator->renderNextFrame();
284
    m_state.layersToCreate.clear();
205
    m_isWaitingForRenderer = false;
285
    m_state.layersToUpdate.clear();
206
    scheduleLayerFlush();
286
    m_state.layersToRemove.clear();
287
288
    m_state.imagesToCreate.clear();
289
    m_state.imagesToRemove.clear();
290
    m_state.imagesToUpdate.clear();
291
    m_state.imagesToClear.clear();
292
293
    m_state.updateAtlasesToCreate.clear();
294
    m_state.updateAtlasesToRemove.clear();
295
296
#if ENABLE(CSS_SHADERS)
297
    m_state.customFiltersToCreate.clear();
298
    m_state.customFiltersToRemove.clear();
299
#endif
207
}
300
}
208
301
209
void CoordinatedLayerTreeHost::purgeBackingStores()
302
void CoordinatedLayerTreeHost::initializeRootCompositingLayerIfNeeded()
210
{
303
{
211
    m_coordinator->purgeBackingStores();
304
    if (m_didInitializeRootCompositingLayer)
305
        return;
306
307
    m_state.rootCompositingLayer = toCoordinatedGraphicsLayer(m_rootLayer.get())->id();
308
    m_didInitializeRootCompositingLayer = true;
309
    m_shouldSyncFrame = true;
212
}
310
}
213
311
214
void CoordinatedLayerTreeHost::willSyncLayerState(CoordinatedGraphicsLayerState& state)
312
void CoordinatedLayerTreeHost::syncLayerState(CoordinatedLayerID id, CoordinatedGraphicsLayerState& state)
215
{
313
{
216
#if ENABLE(CSS_SHADERS)
314
    m_shouldSyncFrame = true;
217
    if (state.animationsChanged)
218
        prepareCustomFilterProxiesForAnimations(state.animations);
219
315
220
    if (state.filtersChanged)
316
#if ENABLE(CSS_SHADERS)
221
        checkCustomFilterProgramProxies(state.filters);
317
    prepareCustomFilterProxiesIfNeeded(state);
222
#else
223
    UNUSED_PARAM(state);
224
#endif
318
#endif
319
320
    m_state.layersToUpdate.append(std::make_pair(id, state));
225
}
321
}
226
322
227
#if ENABLE(CSS_SHADERS)
323
#if ENABLE(CSS_SHADERS)
228
void CoordinatedLayerTreeHost::prepareCustomFilterProxiesForAnimations(GraphicsLayerAnimations& activeAnimations)
324
void CoordinatedLayerTreeHost::prepareCustomFilterProxiesIfNeeded(CoordinatedGraphicsLayerState& state)
229
{
325
{
230
    for (size_t i = 0; i < activeAnimations.animations().size(); ++i) {
326
    if (state.animationsChanged) {
231
        const KeyframeValueList& keyframes = activeAnimations.animations().at(i).keyframes();
327
        GraphicsLayerAnimations& activeAnimations = state.animations;
232
        if (keyframes.property() != AnimatedPropertyWebkitFilter)
328
        for (size_t i = 0; i < activeAnimations.animations().size(); ++i) {
233
            continue;
329
            const KeyframeValueList& keyframes = activeAnimations.animations().at(i).keyframes();
234
        for (size_t j = 0; j < keyframes.size(); ++j) {
330
            if (keyframes.property() != AnimatedPropertyWebkitFilter)
235
            const FilterAnimationValue& filterValue = static_cast<const FilterAnimationValue&>(keyframes.at(j));
331
                continue;
236
            checkCustomFilterProgramProxies(filterValue.value());
332
            for (size_t j = 0; j < keyframes.size(); ++j) {
333
                const FilterAnimationValue& filterValue = static_cast<const FilterAnimationValue&>(keyframes.at(j));
334
                checkCustomFilterProgramProxies(filterValue.value());
335
            }
237
        }
336
        }
238
    }
337
    }
338
339
    if (state.filtersChanged)
340
        checkCustomFilterProgramProxies(state.filters);
239
}
341
}
240
342
241
void CoordinatedLayerTreeHost::checkCustomFilterProgramProxies(const FilterOperations& filters)
343
void CoordinatedLayerTreeHost::checkCustomFilterProgramProxies(const FilterOperations& filters)
Lines 265-271 void CoordinatedLayerTreeHost::checkCustomFilterProgramProxies(const FilterOpera a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec8
265
        if (!customFilterProgramProxy->client()) {
367
        if (!customFilterProgramProxy->client()) {
266
            customFilterProgramProxy->setClient(this);
368
            customFilterProgramProxy->setClient(this);
267
            m_customFilterPrograms.add(customFilterProgramProxy.get());
369
            m_customFilterPrograms.add(customFilterProgramProxy.get());
268
            m_coordinator->state().customFiltersToCreate.append(std::make_pair(customFilterProgramProxy->id(), customOperation->validatedProgram()->validatedProgramInfo()));
370
            m_state.customFiltersToCreate.append(std::make_pair(customFilterProgramProxy->id(), customOperation->validatedProgram()->validatedProgramInfo()));
269
        } else {
371
        } else {
270
            // If the client was not disconnected then this coordinator must be the client for it.
372
            // If the client was not disconnected then this coordinator must be the client for it.
271
            ASSERT(customFilterProgramProxy->client() == this);
373
            ASSERT(customFilterProgramProxy->client() == this);
Lines 278-284 void CoordinatedLayerTreeHost::removeCustomFilterProgramProxy(WebCustomFilterPro a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec9
278
    // At this time the shader is not needed anymore, so we remove it from our set and
380
    // At this time the shader is not needed anymore, so we remove it from our set and
279
    // send a message to the other process to delete it.
381
    // send a message to the other process to delete it.
280
    m_customFilterPrograms.remove(customFilterProgramProxy);
382
    m_customFilterPrograms.remove(customFilterProgramProxy);
281
    m_coordinator->state().customFiltersToRemove.append(customFilterProgramProxy->id());
383
    m_state.customFiltersToRemove.append(customFilterProgramProxy->id());
282
}
384
}
283
385
284
void CoordinatedLayerTreeHost::disconnectCustomFilterPrograms()
386
void CoordinatedLayerTreeHost::disconnectCustomFilterPrograms()
Lines 290-319 void CoordinatedLayerTreeHost::disconnectCustomFilterPrograms() a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec10
290
}
392
}
291
#endif // ENABLE(CSS_SHADERS)
393
#endif // ENABLE(CSS_SHADERS)
292
394
293
void CoordinatedLayerTreeHost::didFlushRootLayer()
395
void CoordinatedLayerTreeHost::detachLayer(CoordinatedGraphicsLayer* layer)
294
{
396
{
295
    if (m_pageOverlayLayer)
397
    m_registeredLayers.remove(layer->id());
296
        m_pageOverlayLayer->flushCompositingStateForThisLayerOnly();
398
399
    size_t index = m_state.layersToCreate.find(layer->id());
400
    if (index != notFound) {
401
        m_state.layersToCreate.remove(index);
402
        return;
403
    }
404
405
    m_state.layersToRemove.append(layer->id());
406
    scheduleLayerFlush();
297
}
407
}
298
408
299
void CoordinatedLayerTreeHost::performScheduledLayerFlush()
409
void CoordinatedLayerTreeHost::performScheduledLayerFlush()
300
{
410
{
301
    if (m_isSuspended || m_isWaitingForRenderer)
411
    if (m_isSuspended || m_waitingForUIProcess)
302
        return;
412
        return;
303
413
304
    m_coordinator->syncDisplayState();
414
    syncDisplayState();
305
415
306
    if (!m_isValid)
416
    if (!m_isValid)
307
        return;
417
        return;
308
418
309
    bool didSync = m_coordinator->flushPendingLayerChanges();
419
    if (flushPendingLayerChanges())
420
        didPerformScheduledLayerFlush();
421
}
310
422
311
    if (m_forceRepaintAsyncCallbackID) {
423
void CoordinatedLayerTreeHost::syncDisplayState()
312
        m_webPage->send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsyncCallbackID));
424
{
313
        m_forceRepaintAsyncCallbackID = 0;
425
#if ENABLE(INSPECTOR)
314
    }
426
    m_webPage->corePage()->inspectorController()->didBeginFrame();
427
#endif
428
429
#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER) && !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
430
    // Make sure that any previously registered animation callbacks are being executed before we flush the layers.
431
    m_lastAnimationServiceTime = WTF::monotonicallyIncreasingTime();
432
    m_webPage->corePage()->mainFrame()->view()->serviceScriptedAnimations(m_lastAnimationServiceTime);
433
#endif
434
435
    m_webPage->layoutIfNeeded();
436
}
315
437
316
    if (m_notifyAfterScheduledLayerFlush && didSync) {
438
void CoordinatedLayerTreeHost::didPerformScheduledLayerFlush()
439
{
440
    if (m_notifyAfterScheduledLayerFlush) {
317
        static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers();
441
        static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers();
318
        m_notifyAfterScheduledLayerFlush = false;
442
        m_notifyAfterScheduledLayerFlush = false;
319
    }
443
    }
Lines 328-342 void CoordinatedLayerTreeHost::createPageOverlayLayer() a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec11
328
{
452
{
329
    ASSERT(!m_pageOverlayLayer);
453
    ASSERT(!m_pageOverlayLayer);
330
454
331
    m_pageOverlayLayer = GraphicsLayer::create(graphicsLayerFactory(), m_coordinator.get());
455
    m_pageOverlayLayer = GraphicsLayer::create(this, this);
332
#ifndef NDEBUG
456
#ifndef NDEBUG
333
    m_pageOverlayLayer->setName("CompositingCoordinator page overlay content");
457
    m_pageOverlayLayer->setName("CoordinatedLayerTreeHost page overlay content");
334
#endif
458
#endif
335
459
336
    m_pageOverlayLayer->setDrawsContent(true);
460
    m_pageOverlayLayer->setDrawsContent(true);
337
    m_pageOverlayLayer->setSize(m_coordinator->rootLayer()->size());
461
    m_pageOverlayLayer->setSize(m_webPage->size());
338
462
339
    m_coordinator->rootLayer()->addChild(m_pageOverlayLayer.get());
463
    m_rootLayer->addChild(m_pageOverlayLayer.get());
340
}
464
}
341
465
342
void CoordinatedLayerTreeHost::destroyPageOverlayLayer()
466
void CoordinatedLayerTreeHost::destroyPageOverlayLayer()
Lines 346-352 void CoordinatedLayerTreeHost::destroyPageOverlayLayer() a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec12
346
    m_pageOverlayLayer = nullptr;
470
    m_pageOverlayLayer = nullptr;
347
}
471
}
348
472
349
void CoordinatedLayerTreeHost::paintLayerContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, const IntRect& clipRect)
473
PassRefPtr<CoordinatedImageBacking> CoordinatedLayerTreeHost::createImageBackingIfNeeded(Image* image)
474
{
475
    CoordinatedImageBackingID imageID = CoordinatedImageBacking::getCoordinatedImageBackingID(image);
476
    ImageBackingMap::iterator it = m_imageBackings.find(imageID);
477
    RefPtr<CoordinatedImageBacking> imageBacking;
478
    if (it == m_imageBackings.end()) {
479
        imageBacking = CoordinatedImageBacking::create(this, image);
480
        m_imageBackings.add(imageID, imageBacking);
481
    } else
482
        imageBacking = it->value;
483
484
    return imageBacking;
485
}
486
487
void CoordinatedLayerTreeHost::createImageBacking(CoordinatedImageBackingID imageID)
488
{
489
    m_state.imagesToCreate.append(imageID);
490
}
491
492
void CoordinatedLayerTreeHost::updateImageBacking(CoordinatedImageBackingID imageID, PassRefPtr<CoordinatedSurface> coordinatedSurface)
493
{
494
    m_shouldSyncFrame = true;
495
    m_state.imagesToUpdate.append(std::make_pair(imageID, coordinatedSurface));
496
}
497
498
void CoordinatedLayerTreeHost::clearImageBackingContents(CoordinatedImageBackingID imageID)
499
{
500
    m_shouldSyncFrame = true;
501
    m_state.imagesToClear.append(imageID);
502
}
503
504
void CoordinatedLayerTreeHost::removeImageBacking(CoordinatedImageBackingID imageID)
505
{
506
    if (m_isPurging)
507
        return;
508
509
    ASSERT(m_imageBackings.contains(imageID));
510
    m_imageBackings.remove(imageID);
511
512
    m_state.imagesToRemove.append(imageID);
513
}
514
515
void CoordinatedLayerTreeHost::flushPendingImageBackingChanges()
516
{
517
    ImageBackingMap::iterator end = m_imageBackings.end();
518
    for (ImageBackingMap::iterator iter = m_imageBackings.begin(); iter != end; ++iter)
519
        iter->value->update();
520
}
521
522
void CoordinatedLayerTreeHost::notifyAnimationStarted(const WebCore::GraphicsLayer*, double /* time */)
523
{
524
}
525
526
void CoordinatedLayerTreeHost::notifyFlushRequired(const WebCore::GraphicsLayer*)
527
{
528
    scheduleLayerFlush();
529
}
530
531
void CoordinatedLayerTreeHost::paintContents(const WebCore::GraphicsLayer* graphicsLayer, WebCore::GraphicsContext& graphicsContext, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect)
350
{
532
{
351
    if (graphicsLayer == m_pageOverlayLayer) {
533
    if (graphicsLayer == m_pageOverlayLayer) {
352
        // Overlays contain transparent contents and won't clear the context as part of their rendering, so we do it here.
534
        // Overlays contain transparent contents and won't clear the context as part of their rendering, so we do it here.
Lines 356-365 void CoordinatedLayerTreeHost::paintLayerContents(const GraphicsLayer* graphicsL a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec13
356
    }
538
    }
357
}
539
}
358
540
359
void CoordinatedLayerTreeHost::commitSceneState(WebCore::CoordinatedGraphicsState& state)
541
PassOwnPtr<GraphicsLayer> CoordinatedLayerTreeHost::createGraphicsLayer(GraphicsLayerClient* client)
360
{
542
{
361
    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CommitCoordinatedGraphicsState(state));
543
    CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(client);
362
    m_isWaitingForRenderer = true;
544
    layer->setCoordinator(this);
545
    m_registeredLayers.add(layer->id(), layer);
546
    m_state.layersToCreate.append(layer->id());
547
    layer->setNeedsVisibleRectAdjustment();
548
    scheduleLayerFlush();
549
    return adoptPtr(layer);
363
}
550
}
364
551
365
PassRefPtr<CoordinatedSurface> CoordinatedLayerTreeHost::createCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags)
552
PassRefPtr<CoordinatedSurface> CoordinatedLayerTreeHost::createCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags)
Lines 367-380 PassRefPtr<CoordinatedSurface> CoordinatedLayerTreeHost::createCoordinatedSurfac a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec14
367
    return WebCoordinatedSurface::create(size, flags);
554
    return WebCoordinatedSurface::create(size, flags);
368
}
555
}
369
556
557
float CoordinatedLayerTreeHost::deviceScaleFactor() const
558
{
559
    return m_webPage->deviceScaleFactor();
560
}
561
562
float CoordinatedLayerTreeHost::pageScaleFactor() const
563
{
564
    return m_webPage->pageScaleFactor();
565
}
566
370
bool LayerTreeHost::supportsAcceleratedCompositing()
567
bool LayerTreeHost::supportsAcceleratedCompositing()
371
{
568
{
372
    return true;
569
    return true;
373
}
570
}
374
571
572
void CoordinatedLayerTreeHost::createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface> coordinatedSurface)
573
{
574
    m_state.updateAtlasesToCreate.append(std::make_pair(atlasID, coordinatedSurface));
575
}
576
577
void CoordinatedLayerTreeHost::removeUpdateAtlas(uint32_t atlasID)
578
{
579
    if (m_isPurging)
580
        return;
581
    m_state.updateAtlasesToRemove.append(atlasID);
582
}
583
584
WebCore::FloatRect CoordinatedLayerTreeHost::visibleContentsRect() const
585
{
586
    return m_visibleContentsRect;
587
}
588
589
CoordinatedGraphicsLayer* CoordinatedLayerTreeHost::mainContentsLayer()
590
{
591
    if (!m_rootCompositingLayer)
592
        return 0;
593
594
    return toCoordinatedGraphicsLayer(m_rootCompositingLayer)->findFirstDescendantWithContentsRecursively();
595
}
596
597
void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector)
598
{
599
    // A zero trajectoryVector indicates that tiles all around the viewport are requested.
600
    if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
601
        contentsLayer->setVisibleContentRectTrajectoryVector(trajectoryVector);
602
603
    bool contentsRectDidChange = rect != m_visibleContentsRect;
604
    if (contentsRectDidChange) {
605
        m_visibleContentsRect = rect;
606
607
        LayerMap::iterator end = m_registeredLayers.end();
608
        for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it) {
609
            it->value->setNeedsVisibleRectAdjustment();
610
        }
611
    }
612
613
    scheduleLayerFlush();
614
    if (m_webPage->useFixedLayout()) {
615
        // Round the rect instead of enclosing it to make sure that its size stays
616
        // the same while panning. This can have nasty effects on layout.
617
        m_webPage->setFixedVisibleContentRect(roundedIntRect(rect));
618
    }
619
}
620
375
void CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
621
void CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
376
{
622
{
377
    m_coordinator->deviceOrPageScaleFactorChanged();
623
    m_rootLayer->deviceOrPageScaleFactorChanged();
378
    if (m_pageOverlayLayer)
624
    if (m_pageOverlayLayer)
379
        m_pageOverlayLayer->deviceOrPageScaleFactorChanged();
625
        m_pageOverlayLayer->deviceOrPageScaleFactorChanged();
380
}
626
}
Lines 385-407 void CoordinatedLayerTreeHost::pageBackgroundTransparencyChanged() a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec15
385
631
386
GraphicsLayerFactory* CoordinatedLayerTreeHost::graphicsLayerFactory()
632
GraphicsLayerFactory* CoordinatedLayerTreeHost::graphicsLayerFactory()
387
{
633
{
388
    return m_coordinator.get();
634
    return this;
389
}
635
}
390
636
391
#if ENABLE(REQUEST_ANIMATION_FRAME)
637
#if ENABLE(REQUEST_ANIMATION_FRAME)
392
void CoordinatedLayerTreeHost::scheduleAnimation()
638
void CoordinatedLayerTreeHost::scheduleAnimation()
393
{
639
{
394
    if (m_isWaitingForRenderer)
640
    if (m_waitingForUIProcess)
395
        return;
641
        return;
396
642
397
    if (m_layerFlushTimer.isActive())
643
    if (m_layerFlushTimer.isActive())
398
        return;
644
        return;
399
645
400
    m_layerFlushTimer.startOneShot(m_coordinator->nextAnimationServiceTime());
646
    // According to the requestAnimationFrame spec, rAF callbacks should not be faster than 60FPS.
647
    static const double MinimalTimeoutForAnimations = 1. / 60.;
648
    m_layerFlushTimer.startOneShot(std::max<double>(0., MinimalTimeoutForAnimations - WTF::monotonicallyIncreasingTime() + m_lastAnimationServiceTime));
401
    scheduleLayerFlush();
649
    scheduleLayerFlush();
402
}
650
}
403
#endif
651
#endif
404
652
653
void CoordinatedLayerTreeHost::renderNextFrame()
654
{
655
    m_waitingForUIProcess = false;
656
    scheduleLayerFlush();
657
    for (unsigned i = 0; i < m_updateAtlases.size(); ++i)
658
        m_updateAtlases[i]->didSwapBuffers();
659
}
660
661
void CoordinatedLayerTreeHost::purgeBackingStores()
662
{
663
    TemporaryChange<bool> purgingToggle(m_isPurging, true);
664
665
    LayerMap::iterator end = m_registeredLayers.end();
666
    for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it)
667
        it->value->purgeBackingStores();
668
669
    m_imageBackings.clear();
670
    m_updateAtlases.clear();
671
}
672
673
bool CoordinatedLayerTreeHost::paintToSurface(const IntSize& size, CoordinatedSurface::Flags flags, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client* client)
674
{
675
    for (unsigned i = 0; i < m_updateAtlases.size(); ++i) {
676
        UpdateAtlas* atlas = m_updateAtlases[i].get();
677
        if (atlas->supportsAlpha() == (flags & CoordinatedSurface::SupportsAlpha)) {
678
            // This will false if there is no available buffer space.
679
            if (atlas->paintOnAvailableBuffer(size, atlasID, offset, client))
680
                return true;
681
        }
682
    }
683
684
    static const int ScratchBufferDimension = 1024; // Should be a power of two.
685
    m_updateAtlases.append(adoptPtr(new UpdateAtlas(this, ScratchBufferDimension, flags)));
686
    scheduleReleaseInactiveAtlases();
687
    return m_updateAtlases.last()->paintOnAvailableBuffer(size, atlasID, offset, client);
688
}
689
690
const double ReleaseInactiveAtlasesTimerInterval = 0.5;
691
692
void CoordinatedLayerTreeHost::scheduleReleaseInactiveAtlases()
693
{
694
    if (!m_releaseInactiveAtlasesTimer.isActive())
695
        m_releaseInactiveAtlasesTimer.startRepeating(ReleaseInactiveAtlasesTimerInterval);
696
}
697
698
void CoordinatedLayerTreeHost::releaseInactiveAtlasesTimerFired(Timer<CoordinatedLayerTreeHost>*)
699
{
700
    // We always want to keep one atlas for non-composited content.
701
    OwnPtr<UpdateAtlas> atlasToKeepAnyway;
702
    bool foundActiveAtlasForNonCompositedContent = false;
703
    for (int i = m_updateAtlases.size() - 1;  i >= 0; --i) {
704
        UpdateAtlas* atlas = m_updateAtlases[i].get();
705
        if (!atlas->isInUse())
706
            atlas->addTimeInactive(ReleaseInactiveAtlasesTimerInterval);
707
        bool usableForNonCompositedContent = !atlas->supportsAlpha();
708
        if (atlas->isInactive()) {
709
            if (!foundActiveAtlasForNonCompositedContent && !atlasToKeepAnyway && usableForNonCompositedContent)
710
                atlasToKeepAnyway = m_updateAtlases[i].release();
711
            m_updateAtlases.remove(i);
712
        } else if (usableForNonCompositedContent)
713
            foundActiveAtlasForNonCompositedContent = true;
714
    }
715
716
    if (!foundActiveAtlasForNonCompositedContent && atlasToKeepAnyway)
717
        m_updateAtlases.append(atlasToKeepAnyway.release());
718
719
    if (m_updateAtlases.size() <= 1)
720
        m_releaseInactiveAtlasesTimer.stop();
721
}
722
405
void CoordinatedLayerTreeHost::setBackgroundColor(const WebCore::Color& color)
723
void CoordinatedLayerTreeHost::setBackgroundColor(const WebCore::Color& color)
406
{
724
{
407
    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::SetBackgroundColor(color));
725
    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::SetBackgroundColor(color));
Lines 409-415 void CoordinatedLayerTreeHost::setBackgroundColor(const WebCore::Color& color) a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec16
409
727
410
void CoordinatedLayerTreeHost::commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset)
728
void CoordinatedLayerTreeHost::commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset)
411
{
729
{
412
    m_coordinator->commitScrollOffset(layerID, offset);
730
    LayerMap::iterator i = m_registeredLayers.find(layerID);
731
    if (i == m_registeredLayers.end())
732
        return;
733
734
    i->value->commitScrollOffset(offset);
413
}
735
}
414
736
415
} // namespace WebKit
737
} // namespace WebKit
- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h -17 / +79 lines
Lines 25-32 a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h_sec1
25
25
26
#include "LayerTreeContext.h"
26
#include "LayerTreeContext.h"
27
#include "LayerTreeHost.h"
27
#include "LayerTreeHost.h"
28
#include <WebCore/CompositingCoordinator.h>
28
#include "Timer.h"
29
#include <WebCore/CoordinatedGraphicsLayer.h>
30
#include <WebCore/CoordinatedGraphicsState.h>
31
#include <WebCore/CoordinatedImageBacking.h>
32
#include <WebCore/GraphicsLayerClient.h>
29
#include <WebCore/GraphicsLayerFactory.h>
33
#include <WebCore/GraphicsLayerFactory.h>
34
#include <WebCore/UpdateAtlas.h>
30
#include <wtf/OwnPtr.h>
35
#include <wtf/OwnPtr.h>
31
36
32
#if ENABLE(CSS_SHADERS)
37
#if ENABLE(CSS_SHADERS)
Lines 41-47 namespace WebKit { a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h_sec2
41
46
42
class WebPage;
47
class WebPage;
43
48
44
class CoordinatedLayerTreeHost : public LayerTreeHost, public WebCore::CompositingCoordinator::Client
49
class CoordinatedLayerTreeHost : public LayerTreeHost, WebCore::GraphicsLayerClient
50
    , public WebCore::CoordinatedGraphicsLayerClient
51
    , public WebCore::CoordinatedImageBacking::Client
52
    , public WebCore::UpdateAtlas::Client
53
    , public WebCore::GraphicsLayerFactory
45
#if ENABLE(CSS_SHADERS)
54
#if ENABLE(CSS_SHADERS)
46
    , WebCustomFilterProgramProxyClient
55
    , WebCustomFilterProgramProxyClient
47
#endif
56
#endif
Lines 75-80 public: a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h_sec3
75
    virtual void deviceOrPageScaleFactorChanged() OVERRIDE;
84
    virtual void deviceOrPageScaleFactorChanged() OVERRIDE;
76
    virtual void pageBackgroundTransparencyChanged() OVERRIDE;
85
    virtual void pageBackgroundTransparencyChanged() OVERRIDE;
77
86
87
    virtual void renderNextFrame();
88
    virtual void purgeBackingStores();
89
    virtual void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&);
78
    virtual void didReceiveCoordinatedLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
90
    virtual void didReceiveCoordinatedLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
79
    virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() OVERRIDE;
91
    virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() OVERRIDE;
80
    WebCore::CoordinatedGraphicsLayer* mainContentsLayer();
92
    WebCore::CoordinatedGraphicsLayer* mainContentsLayer();
Lines 86-116 public: a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h_sec4
86
98
87
    static PassRefPtr<WebCore::CoordinatedSurface> createCoordinatedSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags);
99
    static PassRefPtr<WebCore::CoordinatedSurface> createCoordinatedSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags);
88
100
101
    void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset);
102
89
protected:
103
protected:
90
    explicit CoordinatedLayerTreeHost(WebPage*);
104
    explicit CoordinatedLayerTreeHost(WebPage*);
91
105
92
private:
106
private:
107
    // GraphicsLayerClient
108
    virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time);
109
    virtual void notifyFlushRequired(const WebCore::GraphicsLayer*);
110
    virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect);
111
    virtual float deviceScaleFactor() const OVERRIDE;
112
    virtual float pageScaleFactor() const OVERRIDE;
113
114
    // CoordinatedImageBacking::Client
115
    virtual void createImageBacking(WebCore::CoordinatedImageBackingID) OVERRIDE;
116
    virtual void updateImageBacking(WebCore::CoordinatedImageBackingID, PassRefPtr<WebCore::CoordinatedSurface>) OVERRIDE;
117
    virtual void clearImageBackingContents(WebCore::CoordinatedImageBackingID) OVERRIDE;
118
    virtual void removeImageBacking(WebCore::CoordinatedImageBackingID) OVERRIDE;
119
120
    void flushPendingImageBackingChanges();
121
122
    // CoordinatedGraphicsLayerClient
123
    virtual bool isFlushingLayerChanges() const OVERRIDE { return m_isFlushingLayerChanges; }
124
    virtual WebCore::FloatRect visibleContentsRect() const;
125
    virtual PassRefPtr<WebCore::CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) OVERRIDE;
126
    virtual void detachLayer(WebCore::CoordinatedGraphicsLayer*);
127
    virtual bool paintToSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags, uint32_t& /* atlasID */, WebCore::IntPoint&, WebCore::CoordinatedSurface::Client*) OVERRIDE;
128
    virtual void syncLayerState(WebCore::CoordinatedLayerID, WebCore::CoordinatedGraphicsLayerState&);
129
130
    // UpdateAtlas::Client
131
    virtual void createUpdateAtlas(uint32_t atlasID, PassRefPtr<WebCore::CoordinatedSurface>) OVERRIDE;
132
    virtual void removeUpdateAtlas(uint32_t atlasID) OVERRIDE;
133
134
    // GraphicsLayerFactory
135
    virtual PassOwnPtr<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayerClient*) OVERRIDE;
136
93
    // CoordinatedLayerTreeHost
137
    // CoordinatedLayerTreeHost
138
    void initializeRootCompositingLayerIfNeeded();
94
    void createPageOverlayLayer();
139
    void createPageOverlayLayer();
95
    void destroyPageOverlayLayer();
140
    void destroyPageOverlayLayer();
141
    bool flushPendingLayerChanges();
142
    void clearPendingStateChanges();
96
    void cancelPendingLayerFlush();
143
    void cancelPendingLayerFlush();
97
    void performScheduledLayerFlush();
144
    void performScheduledLayerFlush();
98
    void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&);
145
    void didPerformScheduledLayerFlush();
99
    void renderNextFrame();
146
    void syncDisplayState();
100
    void purgeBackingStores();
101
    void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset);
102
103
    void layerFlushTimerFired(WebCore::Timer<CoordinatedLayerTreeHost>*);
147
    void layerFlushTimerFired(WebCore::Timer<CoordinatedLayerTreeHost>*);
104
148
105
    // CompositingCoordinator::Client
149
    void scheduleReleaseInactiveAtlases();
106
    virtual void didFlushRootLayer() OVERRIDE;
150
107
    virtual void willSyncLayerState(WebCore::CoordinatedGraphicsLayerState&) OVERRIDE;
151
    void releaseInactiveAtlasesTimerFired(WebCore::Timer<CoordinatedLayerTreeHost>*);
108
    virtual void notifyFlushRequired() OVERRIDE { scheduleLayerFlush(); };
109
    virtual void commitSceneState(WebCore::CoordinatedGraphicsState&) OVERRIDE;
110
    virtual void paintLayerContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, const WebCore::IntRect& clipRect) OVERRIDE;
111
152
112
#if ENABLE(CSS_SHADERS)
153
#if ENABLE(CSS_SHADERS)
113
    void prepareCustomFilterProxiesForAnimations(WebCore::GraphicsLayerAnimations&);
154
    void prepareCustomFilterProxiesIfNeeded(WebCore::CoordinatedGraphicsLayerState&);
114
155
115
    // WebCustomFilterProgramProxyClient
156
    // WebCustomFilterProgramProxyClient
116
    void removeCustomFilterProgramProxy(WebCustomFilterProgramProxy*);
157
    void removeCustomFilterProgramProxy(WebCustomFilterProgramProxy*);
Lines 119-144 private: a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h_sec5
119
    void disconnectCustomFilterPrograms();
160
    void disconnectCustomFilterPrograms();
120
#endif
161
#endif
121
162
122
    OwnPtr<WebCore::CompositingCoordinator> m_coordinator;
163
    OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
164
    WebCore::GraphicsLayer* m_rootCompositingLayer;
123
165
124
    // The page overlay layer. Will be null if there's no page overlay.
166
    // The page overlay layer. Will be null if there's no page overlay.
125
    OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer;
167
    OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer;
126
    RefPtr<PageOverlay> m_pageOverlay;
168
    RefPtr<PageOverlay> m_pageOverlay;
127
169
170
    WebCore::CoordinatedGraphicsState m_state;
171
172
    typedef HashMap<WebCore::CoordinatedLayerID, WebCore::CoordinatedGraphicsLayer*> LayerMap;
173
    LayerMap m_registeredLayers;
174
    typedef HashMap<WebCore::CoordinatedImageBackingID, RefPtr<WebCore::CoordinatedImageBacking> > ImageBackingMap;
175
    ImageBackingMap m_imageBackings;
176
    Vector<OwnPtr<WebCore::UpdateAtlas> > m_updateAtlases;
177
128
#if ENABLE(CSS_SHADERS)
178
#if ENABLE(CSS_SHADERS)
129
    HashSet<WebCustomFilterProgramProxy*> m_customFilterPrograms;
179
    HashSet<WebCustomFilterProgramProxy*> m_customFilterPrograms;
130
#endif
180
#endif
131
181
132
    bool m_notifyAfterScheduledLayerFlush;
182
    bool m_notifyAfterScheduledLayerFlush;
133
    bool m_isValid;
183
    bool m_isValid;
184
    // We don't send the messages related to releasing resources to UI Process during purging, because UI Process already had removed all resources.
185
    bool m_isPurging;
186
    bool m_isFlushingLayerChanges;
187
188
    bool m_waitingForUIProcess;
134
    bool m_isSuspended;
189
    bool m_isSuspended;
135
    bool m_isWaitingForRenderer;
190
    WebCore::FloatRect m_visibleContentsRect;
136
191
137
    LayerTreeContext m_layerTreeContext;
192
    LayerTreeContext m_layerTreeContext;
138
193
    bool m_shouldSyncFrame;
194
    bool m_didInitializeRootCompositingLayer;
139
    WebCore::Timer<CoordinatedLayerTreeHost> m_layerFlushTimer;
195
    WebCore::Timer<CoordinatedLayerTreeHost> m_layerFlushTimer;
196
    WebCore::Timer<CoordinatedLayerTreeHost> m_releaseInactiveAtlasesTimer;
140
    bool m_layerFlushSchedulingEnabled;
197
    bool m_layerFlushSchedulingEnabled;
141
    uint64_t m_forceRepaintAsyncCallbackID;
198
    uint64_t m_forceRepaintAsyncCallbackID;
199
    bool m_animationsLocked;
200
201
#if ENABLE(REQUEST_ANIMATION_FRAME)
202
    double m_lastAnimationServiceTime;
203
#endif
142
};
204
};
143
205
144
} // namespace WebKit
206
} // namespace WebKit
- a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h +3 lines
Lines 87-92 public: a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h_sec1
87
    virtual void setBackgroundColor(const WebCore::Color&) { }
87
    virtual void setBackgroundColor(const WebCore::Color&) { }
88
88
89
#if USE(COORDINATED_GRAPHICS)
89
#if USE(COORDINATED_GRAPHICS)
90
    virtual void setVisibleContentsRect(const WebCore::FloatRect&, float /* scale */, const WebCore::FloatPoint&) { }
91
    virtual void renderNextFrame() { }
92
    virtual void purgeBackingStores() { }
90
    virtual void didReceiveCoordinatedLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) = 0;
93
    virtual void didReceiveCoordinatedLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) = 0;
91
#endif
94
#endif
92
95

Return to Bug 118137