| Differences between
and this patch
- a/Source/WebCore/ChangeLog +31 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2012-04-06  James Robinson  <jamesr@chromium.org>
2
3
        [chromium] Texture copies should happen after incremental updates to preserve commit atomicity
4
        https://bugs.webkit.org/show_bug.cgi?id=83392
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        This enqueues texture copy operations in the CCTextureUpdater's list instead of evaluating them immediately so
9
        if the update is spread over multiple frames we can properly defer the texture copy until the end. Otherwise,
10
        the texture copy for WebGL / Canvas 2D content happens before the commit completes and the compositor might pick
11
        up a frame for the canvas that's "ahead" of the content around it.
12
13
        * platform/graphics/chromium/Canvas2DLayerChromium.cpp:
14
        (WebCore::Canvas2DLayerChromium::updateCompositorResources):
15
        * platform/graphics/chromium/TiledLayerChromium.cpp:
16
        (WebCore::TiledLayerChromium::updateCompositorResources):
17
        * platform/graphics/chromium/WebGLLayerChromium.cpp:
18
        (WebCore::WebGLLayerChromium::updateCompositorResources):
19
        * platform/graphics/chromium/cc/CCTextureUpdater.cpp:
20
        (WebCore::CCTextureUpdater::appendUpdate):
21
        (WebCore::CCTextureUpdater::appendPartialUpdate):
22
        (WebCore):
23
        (WebCore::CCTextureUpdater::appendCopy):
24
        (WebCore::CCTextureUpdater::hasMoreUpdates):
25
        (WebCore::CCTextureUpdater::update):
26
        (WebCore::CCTextureUpdater::clear):
27
        * platform/graphics/chromium/cc/CCTextureUpdater.h:
28
        (CCTextureUpdater):
29
        (UpdateEntry):
30
        (CopyEntry):
31
1
2012-04-06  Andrey Kosyakov  <caseq@chromium.org>
32
2012-04-06  Andrey Kosyakov  <caseq@chromium.org>
2
33
3
        Web Inspector: zoom on vertical mousewheel in Timeline overview
34
        Web Inspector: zoom on vertical mousewheel in Timeline overview
- a/Source/WebKit/chromium/ChangeLog +9 lines
Lines 1-3 a/Source/WebKit/chromium/ChangeLog_sec1
1
2012-04-06  James Robinson  <jamesr@chromium.org>
2
3
        [chromium] Texture copies should happen after incremental updates to preserve commit atomicity
4
        https://bugs.webkit.org/show_bug.cgi?id=83392
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * tests/Canvas2DLayerChromiumTest.cpp:
9
1
2012-04-09  Dana Jansens  <danakj@chromium.org>
10
2012-04-09  Dana Jansens  <danakj@chromium.org>
2
11
3
        [chromium] Make culling work with clipped rects
12
        [chromium] Make culling work with clipped rects
- a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp -2 / +1 lines
Lines 135-142 void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D* context a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp_sec1
135
        return;
135
        return;
136
136
137
    m_frontTexture->allocate(updater.allocator());
137
    m_frontTexture->allocate(updater.allocator());
138
    updater.copier()->copyTexture(context, m_backTextureId, m_frontTexture->textureId(), m_size);
138
    updater.appendCopy(m_backTextureId, m_frontTexture->textureId(), m_size);
139
    GLC(context, context->flush());
140
}
139
}
141
140
142
void Canvas2DLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
141
void Canvas2DLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp -2 / +2 lines
Lines 232-240 void TiledLayerChromium::updateCompositorResources(GraphicsContext3D*, CCTexture a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp_sec1
232
                CRASH();
232
                CRASH();
233
233
234
            if (tile->m_partialUpdate)
234
            if (tile->m_partialUpdate)
235
                updater.appendPartial(tile->texture(), sourceRect, destRect);
235
                updater.appendPartialUpdate(tile->texture(), sourceRect, destRect);
236
            else
236
            else
237
                updater.append(tile->texture(), sourceRect, destRect);
237
                updater.appendUpdate(tile->texture(), sourceRect, destRect);
238
        }
238
        }
239
    }
239
    }
240
240
- a/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp -2 / +2 lines
Lines 84-97 void WebGLLayerChromium::paintContentsIfDirty(const CCOcclusionTracker* /* occlu a/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp_sec1
84
    m_contextLost = context()->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR;
84
    m_contextLost = context()->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR;
85
}
85
}
86
86
87
void WebGLLayerChromium::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater)
87
void WebGLLayerChromium::updateCompositorResources(GraphicsContext3D*, CCTextureUpdater& updater)
88
{
88
{
89
    if (!m_drawingBuffer)
89
    if (!m_drawingBuffer)
90
        return;
90
        return;
91
91
92
    m_textureId = m_drawingBuffer->frontColorBuffer();
92
    m_textureId = m_drawingBuffer->frontColorBuffer();
93
    if (m_drawingBuffer->requiresCopyFromBackToFrontBuffer())
93
    if (m_drawingBuffer->requiresCopyFromBackToFrontBuffer())
94
        updater.copier()->copyTexture(context, m_drawingBuffer->colorBuffer(), m_textureId, bounds());
94
        updater.appendCopy(m_drawingBuffer->colorBuffer(), m_textureId, bounds());
95
}
95
}
96
96
97
void WebGLLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
97
void WebGLLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
- a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp -11 / +32 lines
Lines 32-37 a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp_sec1
32
#include "GraphicsContext3D.h"
32
#include "GraphicsContext3D.h"
33
#include "LayerTextureUpdater.h"
33
#include "LayerTextureUpdater.h"
34
#include "ManagedTexture.h"
34
#include "ManagedTexture.h"
35
#include "TextureCopier.h"
35
36
36
using namespace std;
37
using namespace std;
37
38
Lines 49-78 CCTextureUpdater::~CCTextureUpdater() a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp_sec2
49
{
50
{
50
}
51
}
51
52
52
void CCTextureUpdater::append(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect, Vector<UpdateEntry>& entries)
53
void CCTextureUpdater::appendUpdate(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect, Vector<UpdateEntry>& entries)
53
{
54
{
54
    ASSERT(texture);
55
    ASSERT(texture);
55
56
56
    UpdateEntry entry;
57
    UpdateEntry entry;
57
    entry.m_texture = texture;
58
    entry.texture = texture;
58
    entry.m_sourceRect = sourceRect;
59
    entry.sourceRect = sourceRect;
59
    entry.m_destRect = destRect;
60
    entry.destRect = destRect;
60
    entries.append(entry);
61
    entries.append(entry);
61
}
62
}
62
63
63
void CCTextureUpdater::append(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect)
64
void CCTextureUpdater::appendUpdate(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect)
64
{
65
{
65
    append(texture, sourceRect, destRect, m_entries);
66
    appendUpdate(texture, sourceRect, destRect, m_entries);
66
}
67
}
67
68
68
void CCTextureUpdater::appendPartial(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect)
69
void CCTextureUpdater::appendPartialUpdate(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect)
69
{
70
{
70
    append(texture, sourceRect, destRect, m_partialEntries);
71
    appendUpdate(texture, sourceRect, destRect, m_partialEntries);
72
}
73
74
void CCTextureUpdater::appendCopy(unsigned sourceTexture, unsigned destTexture, const IntSize& size)
75
{
76
    CopyEntry copy;
77
    copy.sourceTexture = sourceTexture;
78
    copy.destTexture = destTexture;
79
    copy.size = size;
80
    m_copyEntries.append(copy);
71
}
81
}
72
82
73
bool CCTextureUpdater::hasMoreUpdates() const
83
bool CCTextureUpdater::hasMoreUpdates() const
74
{
84
{
75
    return m_entries.size() || m_partialEntries.size();
85
    return m_entries.size() || m_partialEntries.size() || m_copyEntries.size();
76
}
86
}
77
87
78
bool CCTextureUpdater::update(GraphicsContext3D* context, size_t count)
88
bool CCTextureUpdater::update(GraphicsContext3D* context, size_t count)
Lines 81-87 bool CCTextureUpdater::update(GraphicsContext3D* context, size_t count) a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp_sec3
81
    size_t maxIndex = min(m_entryIndex + count, m_entries.size());
91
    size_t maxIndex = min(m_entryIndex + count, m_entries.size());
82
    for (index = m_entryIndex; index < maxIndex; ++index) {
92
    for (index = m_entryIndex; index < maxIndex; ++index) {
83
        UpdateEntry& entry = m_entries[index];
93
        UpdateEntry& entry = m_entries[index];
84
        entry.m_texture->updateRect(context, m_allocator, entry.m_sourceRect, entry.m_destRect);
94
        entry.texture->updateRect(context, m_allocator, entry.sourceRect, entry.destRect);
85
    }
95
    }
86
96
87
    bool moreUpdates = maxIndex < m_entries.size();
97
    bool moreUpdates = maxIndex < m_entries.size();
Lines 99-106 bool CCTextureUpdater::update(GraphicsContext3D* context, size_t count) a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp_sec4
99
109
100
    for (index = 0; index < m_partialEntries.size(); ++index) {
110
    for (index = 0; index < m_partialEntries.size(); ++index) {
101
        UpdateEntry& entry = m_partialEntries[index];
111
        UpdateEntry& entry = m_partialEntries[index];
102
        entry.m_texture->updateRect(context, m_allocator, entry.m_sourceRect, entry.m_destRect);
112
        entry.texture->updateRect(context, m_allocator, entry.sourceRect, entry.destRect);
113
    }
114
115
    for (index = 0; index < m_copyEntries.size(); ++index) {
116
        CopyEntry& copyEntry = m_copyEntries[index];
117
        m_copier->copyTexture(context, copyEntry.sourceTexture, copyEntry.destTexture, copyEntry.size);
103
    }
118
    }
119
    // If we've performed any texture copies, we need to insert a flush here into the compositor context
120
    // before letting the main thread proceed as it may make draw calls to the source texture of one of
121
    // our copy operations.
122
    if (m_copyEntries.size())
123
        context->flush();
104
124
105
    // If no entries left to process, auto-clear.
125
    // If no entries left to process, auto-clear.
106
    clear();
126
    clear();
Lines 112-117 void CCTextureUpdater::clear() a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp_sec5
112
    m_entryIndex = 0;
132
    m_entryIndex = 0;
113
    m_entries.clear();
133
    m_entries.clear();
114
    m_partialEntries.clear();
134
    m_partialEntries.clear();
135
    m_copyEntries.clear();
115
}
136
}
116
137
117
}
138
}
- a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h -7 / +14 lines
Lines 41-48 public: a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h_sec1
41
    CCTextureUpdater(TextureAllocator*, TextureCopier*);
41
    CCTextureUpdater(TextureAllocator*, TextureCopier*);
42
    ~CCTextureUpdater();
42
    ~CCTextureUpdater();
43
43
44
    void append(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect);
44
    void appendUpdate(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect);
45
    void appendPartial(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect);
45
    void appendPartialUpdate(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect);
46
    void appendCopy(unsigned sourceTexture, unsigned destTexture, const IntSize&);
46
47
47
    bool hasMoreUpdates() const;
48
    bool hasMoreUpdates() const;
48
49
Lines 52-73 public: a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h_sec2
52
    void clear();
53
    void clear();
53
54
54
    TextureAllocator* allocator() { return m_allocator; }
55
    TextureAllocator* allocator() { return m_allocator; }
55
    TextureCopier* copier() { return m_copier; }
56
56
57
private:
57
private:
58
    struct UpdateEntry {
58
    struct UpdateEntry {
59
        LayerTextureUpdater::Texture* m_texture;
59
        LayerTextureUpdater::Texture* texture;
60
        IntRect m_sourceRect;
60
        IntRect sourceRect;
61
        IntRect m_destRect;
61
        IntRect destRect;
62
    };
62
    };
63
63
64
    static void append(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect, Vector<UpdateEntry>&);
64
    struct CopyEntry {
65
        IntSize size;
66
        unsigned sourceTexture;
67
        unsigned destTexture;
68
    };
69
70
    static void appendUpdate(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect, Vector<UpdateEntry>&);
65
71
66
    TextureAllocator* m_allocator;
72
    TextureAllocator* m_allocator;
67
    TextureCopier* m_copier;
73
    TextureCopier* m_copier;
68
    size_t m_entryIndex;
74
    size_t m_entryIndex;
69
    Vector<UpdateEntry> m_entries;
75
    Vector<UpdateEntry> m_entries;
70
    Vector<UpdateEntry> m_partialEntries;
76
    Vector<UpdateEntry> m_partialEntries;
77
    Vector<CopyEntry> m_copyEntries;
71
};
78
};
72
79
73
}
80
}
- a/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp -1 / +3 lines
Lines 97-104 protected: a/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp_sec1
97
        RefPtr<GraphicsContext3D> mainContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext()), GraphicsContext3D::RenderDirectlyToHostWindow);
97
        RefPtr<GraphicsContext3D> mainContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext()), GraphicsContext3D::RenderDirectlyToHostWindow);
98
        RefPtr<GraphicsContext3D> implContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext()), GraphicsContext3D::RenderDirectlyToHostWindow);
98
        RefPtr<GraphicsContext3D> implContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext()), GraphicsContext3D::RenderDirectlyToHostWindow);
99
99
100
        MockCanvasContext& implMock = *static_cast<MockCanvasContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(implContext.get()));
101
        MockCanvasContext& mainMock = *static_cast<MockCanvasContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(mainContext.get()));
100
        MockCanvasContext& mainMock = *static_cast<MockCanvasContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(mainContext.get()));
101
        MockCanvasContext& implMock = *static_cast<MockCanvasContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(implContext.get()));
102
102
103
        MockTextureAllocator allocatorMock;
103
        MockTextureAllocator allocatorMock;
104
        MockTextureCopier copierMock;
104
        MockTextureCopier copierMock;
Lines 156-161 protected: a/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp_sec2
156
            canvas->updateCompositorResources(implContext.get(), updater);
156
            canvas->updateCompositorResources(implContext.get(), updater);
157
            canvas->pushPropertiesTo(layerImpl.get());
157
            canvas->pushPropertiesTo(layerImpl.get());
158
158
159
            updater.update(implContext.get(), 1);
160
159
            if (threaded)
161
            if (threaded)
160
                EXPECT_EQ(frontTextureId, static_cast<CCTextureLayerImpl*>(layerImpl.get())->textureId());
162
                EXPECT_EQ(frontTextureId, static_cast<CCTextureLayerImpl*>(layerImpl.get())->textureId());
161
            else
163
            else

Return to Bug 83392