Skip to content

Commit d2f7297

Browse files
committed
2011-02-24 James Robinson <[email protected]>
Reviewed by Kenneth Russell. [chromium] Move draw time properties out of *LayerChromium to CCLayerImpl https://bugs.webkit.org/show_bug.cgi?id=55013 This adds a new type (tentatively named CCLayerImpl) responsible for drawing/compositing layers. Currently LayerChromiums know about their CCLayerImpls and CCLayerImpls rely on the LayerChromium tree for structure. In theory updates are a LayerChromium-only concept and draw is a CCLayerImpl-only concept, but this patch doesn't go all there yet in the interest of keeping the patch small-ish. RenderSurfaces are a CCLayerImpl-only concepts and no longer have any direct LayerChromium dependencies. Note: I've put CCLayerImpl into a new 'cc' directory under platform/graphics/chromium/ and intentionally not added it to the include path. We plan to add more compositor implementation details to this directory and we want to keep accidental dependencies on these files to a minimum. See https://bugs.webkit.org/show_bug.cgi?id=54047 for the big picture. Refactor only, compositing/ tests cover these codepaths. * WebCore.gypi: * platform/graphics/chromium/CanvasLayerChromium.cpp: (WebCore::CanvasLayerChromium::draw): * platform/graphics/chromium/ContentLayerChromium.cpp: (WebCore::ContentLayerChromium::requiresClippedUpdateRect): (WebCore::ContentLayerChromium::updateContentsIfDirty): (WebCore::ContentLayerChromium::draw): * platform/graphics/chromium/LayerChromium.cpp: (WebCore::LayerChromium::LayerChromium): (WebCore::LayerChromium::cleanupResources): (WebCore::LayerChromium::setLayerRenderer): (WebCore::LayerChromium::setBounds): (WebCore::LayerChromium::setFrame): (WebCore::LayerChromium::setNeedsDisplay): (WebCore::LayerChromium::setBorderColor): (WebCore::LayerChromium::borderColor): (WebCore::LayerChromium::setBorderWidth): (WebCore::LayerChromium::borderWidth): (WebCore::LayerChromium::layerRenderer): (WebCore::LayerChromium::setDoubleSided): (WebCore::LayerChromium::bounds): * platform/graphics/chromium/LayerChromium.h: (WebCore::LayerChromium::maskDrawLayer): (WebCore::LayerChromium::ccLayerImpl): * platform/graphics/chromium/LayerRendererChromium.cpp: (WebCore::LayerRendererChromium::compareLayerZ): (WebCore::LayerRendererChromium::drawLayers): (WebCore::LayerRendererChromium::updateLayersRecursive): (WebCore::LayerRendererChromium::setCompositeOffscreen): (WebCore::LayerRendererChromium::getOffscreenLayerTexture): (WebCore::LayerRendererChromium::drawLayer): * platform/graphics/chromium/LayerRendererChromium.h: * platform/graphics/chromium/PluginLayerChromium.cpp: (WebCore::PluginLayerChromium::draw): * platform/graphics/chromium/RenderSurfaceChromium.cpp: (WebCore::RenderSurfaceChromium::RenderSurfaceChromium): (WebCore::RenderSurfaceChromium::drawSurface): (WebCore::RenderSurfaceChromium::draw): * platform/graphics/chromium/RenderSurfaceChromium.h: * platform/graphics/chromium/VideoLayerChromium.cpp: (WebCore::VideoLayerChromium::drawYUV): (WebCore::VideoLayerChromium::drawRGBA): * platform/graphics/chromium/cc/CCLayerImpl.cpp: Added. (WebCore::CCLayerImpl::CCLayerImpl): (WebCore::CCLayerImpl::~CCLayerImpl): (WebCore::CCLayerImpl::superlayer): (WebCore::CCLayerImpl::maskLayer): (WebCore::CCLayerImpl::replicaLayer): (WebCore::CCLayerImpl::setLayerRenderer): (WebCore::CCLayerImpl::createRenderSurface): (WebCore::CCLayerImpl::updateContentsIfDirty): (WebCore::CCLayerImpl::drawsContent): (WebCore::CCLayerImpl::draw): (WebCore::CCLayerImpl::unreserveContentsTexture): (WebCore::CCLayerImpl::bindContentsTexture): (WebCore::CCLayerImpl::cleanupResources): (WebCore::CCLayerImpl::getDrawRect): (WebCore::CCLayerImpl::drawDebugBorder): * platform/graphics/chromium/cc/CCLayerImpl.h: Added. (WebCore::CCLayerImpl::create): (WebCore::CCLayerImpl::setDebugBorderColor): (WebCore::CCLayerImpl::debugBorderColor): (WebCore::CCLayerImpl::setDebugBorderWidth): (WebCore::CCLayerImpl::debugBorderWidth): (WebCore::CCLayerImpl::layerRenderer): (WebCore::CCLayerImpl::renderSurface): (WebCore::CCLayerImpl::clearRenderSurface): (WebCore::CCLayerImpl::drawDepth): (WebCore::CCLayerImpl::setDrawDepth): (WebCore::CCLayerImpl::drawOpacity): (WebCore::CCLayerImpl::setDrawOpacity): (WebCore::CCLayerImpl::scissorRect): (WebCore::CCLayerImpl::setScissorRect): (WebCore::CCLayerImpl::targetRenderSurface): (WebCore::CCLayerImpl::setTargetRenderSurface): (WebCore::CCLayerImpl::doubleSided): (WebCore::CCLayerImpl::setDoubleSided): (WebCore::CCLayerImpl::bounds): (WebCore::CCLayerImpl::setBounds): (WebCore::CCLayerImpl::drawTransform): (WebCore::CCLayerImpl::setDrawTransform): (WebCore::CCLayerImpl::drawableContentRect): (WebCore::CCLayerImpl::setDrawableContentRect): Canonical link: https://commits.webkit.org/69578@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@79659 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 9407ff5 commit d2f7297

14 files changed

+655
-226
lines changed

Source/WebCore/ChangeLog

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,109 @@
1+
2011-02-24 James Robinson <[email protected]>
2+
3+
Reviewed by Kenneth Russell.
4+
5+
[chromium] Move draw time properties out of *LayerChromium to CCLayerImpl
6+
https://bugs.webkit.org/show_bug.cgi?id=55013
7+
8+
This adds a new type (tentatively named CCLayerImpl) responsible for drawing/compositing layers.
9+
Currently LayerChromiums know about their CCLayerImpls and CCLayerImpls rely on the LayerChromium
10+
tree for structure. In theory updates are a LayerChromium-only concept and draw is a CCLayerImpl-only
11+
concept, but this patch doesn't go all there yet in the interest of keeping the patch small-ish.
12+
13+
RenderSurfaces are a CCLayerImpl-only concepts and no longer have any direct LayerChromium dependencies.
14+
15+
Note: I've put CCLayerImpl into a new 'cc' directory under platform/graphics/chromium/ and intentionally
16+
not added it to the include path. We plan to add more compositor implementation details to this directory
17+
and we want to keep accidental dependencies on these files to a minimum.
18+
19+
See https://bugs.webkit.org/show_bug.cgi?id=54047 for the big picture.
20+
21+
Refactor only, compositing/ tests cover these codepaths.
22+
23+
* WebCore.gypi:
24+
* platform/graphics/chromium/CanvasLayerChromium.cpp:
25+
(WebCore::CanvasLayerChromium::draw):
26+
* platform/graphics/chromium/ContentLayerChromium.cpp:
27+
(WebCore::ContentLayerChromium::requiresClippedUpdateRect):
28+
(WebCore::ContentLayerChromium::updateContentsIfDirty):
29+
(WebCore::ContentLayerChromium::draw):
30+
* platform/graphics/chromium/LayerChromium.cpp:
31+
(WebCore::LayerChromium::LayerChromium):
32+
(WebCore::LayerChromium::cleanupResources):
33+
(WebCore::LayerChromium::setLayerRenderer):
34+
(WebCore::LayerChromium::setBounds):
35+
(WebCore::LayerChromium::setFrame):
36+
(WebCore::LayerChromium::setNeedsDisplay):
37+
(WebCore::LayerChromium::setBorderColor):
38+
(WebCore::LayerChromium::borderColor):
39+
(WebCore::LayerChromium::setBorderWidth):
40+
(WebCore::LayerChromium::borderWidth):
41+
(WebCore::LayerChromium::layerRenderer):
42+
(WebCore::LayerChromium::setDoubleSided):
43+
(WebCore::LayerChromium::bounds):
44+
* platform/graphics/chromium/LayerChromium.h:
45+
(WebCore::LayerChromium::maskDrawLayer):
46+
(WebCore::LayerChromium::ccLayerImpl):
47+
* platform/graphics/chromium/LayerRendererChromium.cpp:
48+
(WebCore::LayerRendererChromium::compareLayerZ):
49+
(WebCore::LayerRendererChromium::drawLayers):
50+
(WebCore::LayerRendererChromium::updateLayersRecursive):
51+
(WebCore::LayerRendererChromium::setCompositeOffscreen):
52+
(WebCore::LayerRendererChromium::getOffscreenLayerTexture):
53+
(WebCore::LayerRendererChromium::drawLayer):
54+
* platform/graphics/chromium/LayerRendererChromium.h:
55+
* platform/graphics/chromium/PluginLayerChromium.cpp:
56+
(WebCore::PluginLayerChromium::draw):
57+
* platform/graphics/chromium/RenderSurfaceChromium.cpp:
58+
(WebCore::RenderSurfaceChromium::RenderSurfaceChromium):
59+
(WebCore::RenderSurfaceChromium::drawSurface):
60+
(WebCore::RenderSurfaceChromium::draw):
61+
* platform/graphics/chromium/RenderSurfaceChromium.h:
62+
* platform/graphics/chromium/VideoLayerChromium.cpp:
63+
(WebCore::VideoLayerChromium::drawYUV):
64+
(WebCore::VideoLayerChromium::drawRGBA):
65+
* platform/graphics/chromium/cc/CCLayerImpl.cpp: Added.
66+
(WebCore::CCLayerImpl::CCLayerImpl):
67+
(WebCore::CCLayerImpl::~CCLayerImpl):
68+
(WebCore::CCLayerImpl::superlayer):
69+
(WebCore::CCLayerImpl::maskLayer):
70+
(WebCore::CCLayerImpl::replicaLayer):
71+
(WebCore::CCLayerImpl::setLayerRenderer):
72+
(WebCore::CCLayerImpl::createRenderSurface):
73+
(WebCore::CCLayerImpl::updateContentsIfDirty):
74+
(WebCore::CCLayerImpl::drawsContent):
75+
(WebCore::CCLayerImpl::draw):
76+
(WebCore::CCLayerImpl::unreserveContentsTexture):
77+
(WebCore::CCLayerImpl::bindContentsTexture):
78+
(WebCore::CCLayerImpl::cleanupResources):
79+
(WebCore::CCLayerImpl::getDrawRect):
80+
(WebCore::CCLayerImpl::drawDebugBorder):
81+
* platform/graphics/chromium/cc/CCLayerImpl.h: Added.
82+
(WebCore::CCLayerImpl::create):
83+
(WebCore::CCLayerImpl::setDebugBorderColor):
84+
(WebCore::CCLayerImpl::debugBorderColor):
85+
(WebCore::CCLayerImpl::setDebugBorderWidth):
86+
(WebCore::CCLayerImpl::debugBorderWidth):
87+
(WebCore::CCLayerImpl::layerRenderer):
88+
(WebCore::CCLayerImpl::renderSurface):
89+
(WebCore::CCLayerImpl::clearRenderSurface):
90+
(WebCore::CCLayerImpl::drawDepth):
91+
(WebCore::CCLayerImpl::setDrawDepth):
92+
(WebCore::CCLayerImpl::drawOpacity):
93+
(WebCore::CCLayerImpl::setDrawOpacity):
94+
(WebCore::CCLayerImpl::scissorRect):
95+
(WebCore::CCLayerImpl::setScissorRect):
96+
(WebCore::CCLayerImpl::targetRenderSurface):
97+
(WebCore::CCLayerImpl::setTargetRenderSurface):
98+
(WebCore::CCLayerImpl::doubleSided):
99+
(WebCore::CCLayerImpl::setDoubleSided):
100+
(WebCore::CCLayerImpl::bounds):
101+
(WebCore::CCLayerImpl::setBounds):
102+
(WebCore::CCLayerImpl::drawTransform):
103+
(WebCore::CCLayerImpl::setDrawTransform):
104+
(WebCore::CCLayerImpl::drawableContentRect):
105+
(WebCore::CCLayerImpl::setDrawableContentRect):
106+
1107
2011-02-24 Dan Bernstein <[email protected]>
2108

3109
Reviewed by Simon Fraser.

Source/WebCore/WebCore.gypi

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2597,10 +2597,10 @@
25972597
'platform/graphics/chromium/FontPlatformDataLinux.h',
25982598
'platform/graphics/chromium/FontUtilsChromiumWin.cpp',
25992599
'platform/graphics/chromium/FontUtilsChromiumWin.h',
2600-
'platform/graphics/chromium/GeometryBinding.cpp',
2601-
'platform/graphics/chromium/GeometryBinding.h',
26022600
'platform/graphics/chromium/GLES2Canvas.cpp',
26032601
'platform/graphics/chromium/GLES2Canvas.h',
2602+
'platform/graphics/chromium/GeometryBinding.cpp',
2603+
'platform/graphics/chromium/GeometryBinding.h',
26042604
'platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp',
26052605
'platform/graphics/chromium/GraphicsLayerChromium.cpp',
26062606
'platform/graphics/chromium/GraphicsLayerChromium.h',
@@ -2626,8 +2626,8 @@
26262626
'platform/graphics/chromium/PluginLayerChromium.h',
26272627
'platform/graphics/chromium/ProgramBinding.cpp',
26282628
'platform/graphics/chromium/ProgramBinding.h',
2629-
'platform/graphics/chromium/RenderSurfaceChromium.h',
26302629
'platform/graphics/chromium/RenderSurfaceChromium.cpp',
2630+
'platform/graphics/chromium/RenderSurfaceChromium.h',
26312631
'platform/graphics/chromium/ShaderChromium.cpp',
26322632
'platform/graphics/chromium/ShaderChromium.h',
26332633
'platform/graphics/chromium/SimpleFontDataChromiumWin.cpp',
@@ -2640,14 +2640,16 @@
26402640
'platform/graphics/chromium/UniscribeHelper.h',
26412641
'platform/graphics/chromium/UniscribeHelperTextRun.cpp',
26422642
'platform/graphics/chromium/UniscribeHelperTextRun.h',
2643+
'platform/graphics/chromium/VDMXParser.cpp',
2644+
'platform/graphics/chromium/VDMXParser.h',
26432645
'platform/graphics/chromium/VideoFrameChromium.cpp',
26442646
'platform/graphics/chromium/VideoFrameChromium.h',
26452647
'platform/graphics/chromium/VideoLayerChromium.cpp',
26462648
'platform/graphics/chromium/VideoLayerChromium.h',
2647-
'platform/graphics/chromium/VDMXParser.cpp',
2648-
'platform/graphics/chromium/VDMXParser.h',
26492649
'platform/graphics/chromium/WebGLLayerChromium.cpp',
26502650
'platform/graphics/chromium/WebGLLayerChromium.h',
2651+
'platform/graphics/chromium/cc/CCLayerImpl.cpp',
2652+
'platform/graphics/chromium/cc/CCLayerImpl.h',
26512653
'platform/graphics/cocoa/FontPlatformData.h',
26522654
'platform/graphics/cocoa/FontPlatformDataCocoa.mm',
26532655
'platform/graphics/filters/DistantLightSource.cpp',

Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#include "CanvasLayerChromium.h"
3636

37+
#include "cc/CCLayerImpl.h"
3738
#include "GraphicsContext3D.h"
3839
#include "LayerRendererChromium.h"
3940

@@ -62,11 +63,10 @@ void CanvasLayerChromium::draw()
6263
GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId));
6364
layerRenderer()->useShader(program->program());
6465
GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0));
65-
drawTexturedQuad(context, layerRenderer()->projectionMatrix(), drawTransform(),
66-
bounds().width(), bounds().height(), drawOpacity(),
66+
drawTexturedQuad(context, layerRenderer()->projectionMatrix(), ccLayerImpl()->drawTransform(),
67+
bounds().width(), bounds().height(), ccLayerImpl()->drawOpacity(),
6768
program->vertexShader().matrixLocation(),
6869
program->fragmentShader().alphaLocation());
69-
7070
}
7171

7272
}

Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#include "ContentLayerChromium.h"
3636

37+
#include "cc/CCLayerImpl.h"
3738
#include "GraphicsContext3D.h"
3839
#include "LayerRendererChromium.h"
3940
#include "LayerTexture.h"
@@ -79,8 +80,8 @@ bool ContentLayerChromium::requiresClippedUpdateRect() const
7980
// one of the layer's dimensions is larger than 2000 pixels or the size of
8081
// surface it's rendering into. This is a temporary measure until layer tiling is implemented.
8182
static const int maxLayerSize = 2000;
82-
return (bounds().width() > max(maxLayerSize, m_targetRenderSurface->contentRect().width())
83-
|| bounds().height() > max(maxLayerSize, m_targetRenderSurface->contentRect().height())
83+
return (bounds().width() > max(maxLayerSize, ccLayerImpl()->targetRenderSurface()->contentRect().width())
84+
|| bounds().height() > max(maxLayerSize, ccLayerImpl()->targetRenderSurface()->contentRect().height())
8485
|| !layerRenderer()->checkTextureSize(bounds()));
8586
}
8687

@@ -103,15 +104,15 @@ void ContentLayerChromium::updateContentsIfDirty()
103104
// A layer with 3D transforms could require an arbitrarily large number
104105
// of texels to be repainted, so ignore these layers until tiling is
105106
// implemented.
106-
if (!drawTransform().isIdentityOrTranslation()) {
107+
if (!ccLayerImpl()->drawTransform().isIdentityOrTranslation()) {
107108
m_skipsDraw = true;
108109
return;
109110
}
110111

111112
// Calculate the region of this layer that is currently visible.
112-
const IntRect clipRect = m_targetRenderSurface->contentRect();
113+
const IntRect clipRect = ccLayerImpl()->targetRenderSurface()->contentRect();
113114

114-
TransformationMatrix layerOriginTransform = drawTransform();
115+
TransformationMatrix layerOriginTransform = ccLayerImpl()->drawTransform();
115116
layerOriginTransform.translate3d(-0.5 * bounds().width(), -0.5 * bounds().height(), 0);
116117

117118
// For now we apply the large layer treatment only for layers that are either untransformed
@@ -341,18 +342,18 @@ void ContentLayerChromium::draw()
341342
GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0));
342343

343344
if (requiresClippedUpdateRect()) {
344-
float m43 = drawTransform().m43();
345+
float m43 = ccLayerImpl()->drawTransform().m43();
345346
TransformationMatrix transform;
346347
transform.translate3d(m_layerCenterInSurfaceCoords.x(), m_layerCenterInSurfaceCoords.y(), m43);
347348
drawTexturedQuad(context, layerRenderer()->projectionMatrix(),
348349
transform, m_visibleRectInLayerCoords.width(),
349-
m_visibleRectInLayerCoords.height(), drawOpacity(),
350+
m_visibleRectInLayerCoords.height(), ccLayerImpl()->drawOpacity(),
350351
program->vertexShader().matrixLocation(),
351352
program->fragmentShader().alphaLocation());
352353
} else {
353354
drawTexturedQuad(context, layerRenderer()->projectionMatrix(),
354-
drawTransform(), bounds().width(), bounds().height(),
355-
drawOpacity(), program->vertexShader().matrixLocation(),
355+
ccLayerImpl()->drawTransform(), bounds().width(), bounds().height(),
356+
ccLayerImpl()->drawOpacity(), program->vertexShader().matrixLocation(),
356357
program->fragmentShader().alphaLocation());
357358
}
358359
unreserveContentsTexture();

0 commit comments

Comments
 (0)