summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/chromium/LayerRendererChromium.cpp')
-rw-r--r--WebCore/platform/graphics/chromium/LayerRendererChromium.cpp198
1 files changed, 76 insertions, 122 deletions
diff --git a/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp b/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
index 91580cc..882baae 100644
--- a/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
+++ b/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
@@ -37,7 +37,9 @@
#include "Canvas2DLayerChromium.h"
#include "GraphicsContext3D.h"
#include "LayerChromium.h"
+#include "LayerTexture.h"
#include "NotImplemented.h"
+#include "TextureManager.h"
#include "WebGLLayerChromium.h"
#if PLATFORM(SKIA)
#include "NativeImageSkia.h"
@@ -48,6 +50,9 @@
namespace WebCore {
+// FIXME: Make this limit adjustable and give it a useful value.
+static size_t textureMemoryLimitBytes = 64 * 1024 * 1024;
+
static TransformationMatrix orthoMatrix(float left, float right, float bottom, float top)
{
float deltaX = right - left;
@@ -98,7 +103,6 @@ LayerRendererChromium::LayerRendererChromium(PassRefPtr<GraphicsContext3D> conte
: m_rootLayerTextureId(0)
, m_rootLayerTextureWidth(0)
, m_rootLayerTextureHeight(0)
- , m_textureLayerShaderProgram(0)
, m_rootLayer(0)
, m_scrollPosition(IntPoint(-1, -1))
, m_currentShader(0)
@@ -164,7 +168,7 @@ void LayerRendererChromium::setRootLayerCanvasSize(const IntSize& size)
void LayerRendererChromium::useShader(unsigned programId)
{
if (programId != m_currentShader) {
- GLC(m_context, m_context->useProgram(programId));
+ GLC(m_context.get(), m_context->useProgram(programId));
m_currentShader = programId;
}
}
@@ -173,7 +177,7 @@ void LayerRendererChromium::useShader(unsigned programId)
// root layer texture. It resizes the root layer texture and scrolls its
// contents as needed. It also sets up common GL state used by the rest
// of the layer drawing code.
-void LayerRendererChromium::prepareToDrawLayers(const IntRect& visibleRect, const IntRect& contentRect,
+void LayerRendererChromium::prepareToDrawLayers(const IntRect& visibleRect, const IntRect& contentRect,
const IntPoint& scrollPosition)
{
ASSERT(m_hardwareCompositing);
@@ -183,8 +187,8 @@ void LayerRendererChromium::prepareToDrawLayers(const IntRect& visibleRect, cons
makeContextCurrent();
- GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_rootLayerTextureId));
-
+ GLC(m_context.get(), m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_rootLayerTextureId));
+
bool skipScroll = false;
// If the size of the visible area has changed then allocate a new texture
@@ -195,8 +199,7 @@ void LayerRendererChromium::prepareToDrawLayers(const IntRect& visibleRect, cons
if (visibleRectWidth != m_rootLayerTextureWidth || visibleRectHeight != m_rootLayerTextureHeight) {
m_rootLayerTextureWidth = visibleRectWidth;
m_rootLayerTextureHeight = visibleRectHeight;
-
- GLC(m_context, m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, m_rootLayerTextureWidth, m_rootLayerTextureHeight, 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, 0));
+ GLC(m_context.get(), m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, m_rootLayerTextureWidth, m_rootLayerTextureHeight, 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE));
// Reset the current render surface to force an update of the viewport and
// projection matrix next time useRenderSurface is called.
@@ -208,17 +211,17 @@ void LayerRendererChromium::prepareToDrawLayers(const IntRect& visibleRect, cons
}
// The GL viewport covers the entire visible area, including the scrollbars.
- GLC(m_context, m_context->viewport(0, 0, visibleRectWidth, visibleRectHeight));
+ GLC(m_context.get(), m_context->viewport(0, 0, visibleRectWidth, visibleRectHeight));
// Bind the common vertex attributes used for drawing all the layers.
LayerChromium::prepareForDraw(layerSharedValues());
// FIXME: These calls can be made once, when the compositor context is initialized.
- GLC(m_context, m_context->disable(GraphicsContext3D::DEPTH_TEST));
- GLC(m_context, m_context->disable(GraphicsContext3D::CULL_FACE));
+ GLC(m_context.get(), m_context->disable(GraphicsContext3D::DEPTH_TEST));
+ GLC(m_context.get(), m_context->disable(GraphicsContext3D::CULL_FACE));
- // Blending disabled by default. Root layer alpha channel on Windows is incorrect when Skia uses ClearType.
- GLC(m_context, m_context->disable(GraphicsContext3D::BLEND));
+ // Blending disabled by default. Root layer alpha channel on Windows is incorrect when Skia uses ClearType.
+ GLC(m_context.get(), m_context->disable(GraphicsContext3D::BLEND));
if (m_scrollPosition == IntPoint(-1, -1)) {
m_scrollPosition = scrollPosition;
@@ -244,13 +247,14 @@ void LayerRendererChromium::prepareToDrawLayers(const IntRect& visibleRect, cons
0.5 * visibleRect.height() + scrollDelta.y(), 0);
scrolledLayerMatrix.scale3d(1, -1, 1);
- useShader(m_textureLayerShaderProgram);
- GLC(m_context, m_context->uniform1i(m_textureLayerShaderSamplerLocation, 0));
+ const RenderSurfaceChromium::SharedValues* rsv = renderSurfaceSharedValues();
+ useShader(rsv->shaderProgram());
+ GLC(m_context.get(), m_context->uniform1i(rsv->shaderSamplerLocation(), 0));
LayerChromium::drawTexturedQuad(m_context.get(), m_projectionMatrix, scrolledLayerMatrix,
visibleRect.width(), visibleRect.height(), 1,
- m_textureLayerShaderMatrixLocation, m_textureLayerShaderAlphaLocation);
+ rsv->shaderMatrixLocation(), rsv->shaderAlphaLocation());
- GLC(m_context, m_context->copyTexSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, 0, 0, contentRect.width(), contentRect.height()));
+ GLC(m_context.get(), m_context->copyTexSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, 0, 0, contentRect.width(), contentRect.height()));
}
m_scrollPosition = scrollPosition;
@@ -263,7 +267,7 @@ void LayerRendererChromium::updateRootLayerTextureRect(const IntRect& updateRect
if (!m_rootLayer)
return;
- GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_rootLayerTextureId));
+ GLC(m_context.get(), m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_rootLayerTextureId));
// Update the root layer texture.
ASSERT((updateRect.right() <= m_rootLayerTextureWidth)
@@ -282,7 +286,7 @@ void LayerRendererChromium::updateRootLayerTextureRect(const IntRect& updateRect
#error "Need to implement for your platform."
#endif
// Copy the contents of the updated rect to the root layer texture.
- GLC(m_context, m_context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, updateRect.x(), updateRect.y(), updateRect.width(), updateRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixels));
+ GLC(m_context.get(), m_context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, updateRect.x(), updateRect.y(), updateRect.width(), updateRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixels));
}
void LayerRendererChromium::drawLayers(const IntRect& visibleRect, const IntRect& contentRect)
@@ -300,22 +304,22 @@ void LayerRendererChromium::drawLayers(const IntRect& visibleRect, const IntRect
m_context->clearColor(0, 0, 1, 1);
m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
- GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_rootLayerTextureId));
+ GLC(m_context.get(), m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_rootLayerTextureId));
// Render the root layer using a quad that takes up the entire visible area of the window.
// We reuse the shader program used by ContentLayerChromium.
const ContentLayerChromium::SharedValues* contentLayerValues = contentLayerSharedValues();
useShader(contentLayerValues->contentShaderProgram());
- GLC(m_context, m_context->uniform1i(contentLayerValues->shaderSamplerLocation(), 0));
+ GLC(m_context.get(), m_context->uniform1i(contentLayerValues->shaderSamplerLocation(), 0));
// Mask out writes to alpha channel: ClearType via Skia results in invalid
// zero alpha values on text glyphs. The root layer is always opaque.
- GLC(m_context, m_context->colorMask(true, true, true, false));
+ GLC(m_context.get(), m_context->colorMask(true, true, true, false));
TransformationMatrix layerMatrix;
layerMatrix.translate3d(visibleRect.width() * 0.5f, visibleRect.height() * 0.5f, 0);
LayerChromium::drawTexturedQuad(m_context.get(), m_projectionMatrix, layerMatrix,
visibleRect.width(), visibleRect.height(), 1,
contentLayerValues->shaderMatrixLocation(), contentLayerValues->shaderAlphaLocation());
- GLC(m_context, m_context->colorMask(true, true, true, true));
+ GLC(m_context.get(), m_context->colorMask(true, true, true, true));
// Set the root visible/content rects --- used by subsequent drawLayers calls.
m_rootVisibleRect = visibleRect;
@@ -336,9 +340,9 @@ void LayerRendererChromium::drawLayers(const IntRect& visibleRect, const IntRect
// The shader used to render layers returns pre-multiplied alpha colors
// so we need to send the blending mode appropriately.
- GLC(m_context, m_context->enable(GraphicsContext3D::BLEND));
- GLC(m_context, m_context->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA));
- GLC(m_context, m_context->enable(GraphicsContext3D::SCISSOR_TEST));
+ GLC(m_context.get(), m_context->enable(GraphicsContext3D::BLEND));
+ GLC(m_context.get(), m_context->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA));
+ GLC(m_context.get(), m_context->enable(GraphicsContext3D::SCISSOR_TEST));
// Update the contents of the render surfaces. We traverse the array from
// back to front to guarantee that nested render surfaces get rendered in the
@@ -352,22 +356,23 @@ void LayerRendererChromium::drawLayers(const IntRect& visibleRect, const IntRect
if (!renderSurfaceLayer->m_renderSurface->m_layerList.size())
continue;
- useRenderSurface(renderSurfaceLayer->m_renderSurface.get());
- if (renderSurfaceLayer != m_rootLayer) {
- GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST));
- GLC(m_context, m_context->clearColor(0, 0, 0, 0));
- GLC(m_context, m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT));
- GLC(m_context, m_context->enable(GraphicsContext3D::SCISSOR_TEST));
+ if (useRenderSurface(renderSurfaceLayer->m_renderSurface.get())) {
+ if (renderSurfaceLayer != m_rootLayer) {
+ GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST));
+ GLC(m_context.get(), m_context->clearColor(0, 0, 0, 0));
+ GLC(m_context.get(), m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT));
+ GLC(m_context.get(), m_context->enable(GraphicsContext3D::SCISSOR_TEST));
+ }
+
+ Vector<LayerChromium*>& layerList = renderSurfaceLayer->m_renderSurface->m_layerList;
+ ASSERT(layerList.size());
+ for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex)
+ drawLayer(layerList[layerIndex], renderSurfaceLayer->m_renderSurface.get());
}
-
- Vector<LayerChromium*>& layerList = renderSurfaceLayer->m_renderSurface->m_layerList;
- ASSERT(layerList.size());
- for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex)
- drawLayer(layerList[layerIndex], renderSurfaceLayer->m_renderSurface.get());
}
- GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST));
- GLC(m_context, m_context->disable(GraphicsContext3D::BLEND));
+ GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST));
+ GLC(m_context.get(), m_context->disable(GraphicsContext3D::BLEND));
}
void LayerRendererChromium::finish()
@@ -394,7 +399,7 @@ void LayerRendererChromium::getFramebufferPixels(void *pixels, const IntRect& re
makeContextCurrent();
- GLC(m_context, m_context->readPixels(rect.x(), rect.y(), rect.width(), rect.height(),
+ GLC(m_context.get(), m_context->readPixels(rect.x(), rect.y(), rect.width(), rect.height(),
GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixels));
}
@@ -402,14 +407,14 @@ void LayerRendererChromium::getFramebufferPixels(void *pixels, const IntRect& re
unsigned LayerRendererChromium::createLayerTexture()
{
unsigned textureId = 0;
- GLC(m_context, textureId = m_context->createTexture());
- GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId));
+ GLC(m_context.get(), textureId = m_context->createTexture());
+ GLC(m_context.get(), m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId));
// Do basic linear filtering on resize.
- GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR));
- GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
+ GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR));
+ GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
// NPOT textures in GL ES only work when the wrap mode is set to GraphicsContext3D::CLAMP_TO_EDGE.
- GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
- GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
+ GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
+ GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
return textureId;
}
@@ -418,7 +423,7 @@ void LayerRendererChromium::deleteLayerTexture(unsigned textureId)
if (!textureId)
return;
- GLC(m_context, m_context->deleteTexture(textureId));
+ GLC(m_context.get(), m_context->deleteTexture(textureId));
}
// Returns true if any part of the layer falls within the visibleRect
@@ -507,7 +512,7 @@ void LayerRendererChromium::updateLayersRecursive(LayerChromium* layer, const Tr
// Layer's opacity will be applied when drawing the render surface.
renderSurface->m_drawOpacity = layer->opacity();
if (layer->superlayer()->preserves3D())
- renderSurface->m_drawOpacity *= layer->superlayer()->m_drawOpacity;
+ renderSurface->m_drawOpacity *= layer->superlayer()->drawOpacity();
layer->m_drawOpacity = 1;
TransformationMatrix layerOriginTransform = combinedTransform;
@@ -598,7 +603,7 @@ void LayerRendererChromium::updateLayersRecursive(LayerChromium* layer, const Tr
if (sublayer->m_renderSurface) {
RenderSurfaceChromium* sublayerRenderSurface = sublayer->m_renderSurface.get();
- const IntRect& contentRect = sublayerRenderSurface->m_contentRect;
+ const IntRect& contentRect = sublayerRenderSurface->contentRect();
FloatRect sublayerRect(-0.5 * contentRect.width(), -0.5 * contentRect.height(),
contentRect.width(), contentRect.height());
layer->m_drawableContentRect.unite(enclosingIntRect(sublayerRenderSurface->m_drawTransform.mapRect(sublayerRect)));
@@ -664,17 +669,17 @@ bool LayerRendererChromium::useRenderSurface(RenderSurfaceChromium* renderSurfac
m_currentRenderSurface = renderSurface;
if (renderSurface == m_defaultRenderSurface) {
- GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0));
+ GLC(m_context.get(), m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0));
setDrawViewportRect(renderSurface->m_contentRect, true);
return true;
}
- GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_offscreenFramebufferId));
+ GLC(m_context.get(), m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_offscreenFramebufferId));
- renderSurface->prepareContentsTexture();
+ if (!renderSurface->prepareContentsTexture())
+ return false;
- GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0,
- GraphicsContext3D::TEXTURE_2D, renderSurface->m_contentsTextureId, 0));
+ renderSurface->m_contentsTexture->framebufferTexture2D();
#if !defined ( NDEBUG )
if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
@@ -690,15 +695,7 @@ bool LayerRendererChromium::useRenderSurface(RenderSurfaceChromium* renderSurfac
void LayerRendererChromium::drawLayer(LayerChromium* layer, RenderSurfaceChromium* targetSurface)
{
if (layer->m_renderSurface && layer->m_renderSurface != targetSurface) {
- GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, layer->m_renderSurface->m_contentsTextureId));
- useShader(m_textureLayerShaderProgram);
-
- setScissorToRect(layer->m_renderSurface->m_scissorRect);
-
- IntRect contentRect = layer->m_renderSurface->m_contentRect;
- LayerChromium::drawTexturedQuad(m_context.get(), m_projectionMatrix, layer->m_renderSurface->m_drawTransform,
- contentRect.width(), contentRect.height(), layer->m_renderSurface->m_drawOpacity,
- m_textureLayerShaderMatrixLocation, m_textureLayerShaderAlphaLocation);
+ layer->m_renderSurface->draw();
return;
}
@@ -721,12 +718,8 @@ void LayerRendererChromium::drawLayer(LayerChromium* layer, RenderSurfaceChromiu
if (layer->drawsContent()) {
// Update the contents of the layer if necessary.
- if (layer->contentsDirty()) {
- // Update the backing texture contents for any dirty portion of the layer.
- layer->updateContents();
- m_context->makeContextCurrent();
- }
-
+ layer->updateContentsIfDirty();
+ m_context->makeContextCurrent();
layer->draw();
}
@@ -748,7 +741,7 @@ void LayerRendererChromium::setScissorToRect(const IntRect& scissorRect)
scissorY = m_currentRenderSurface->m_contentRect.height() - (scissorRect.bottom() - m_currentRenderSurface->m_contentRect.y());
else
scissorY = scissorRect.y() - m_currentRenderSurface->m_contentRect.y();
- GLC(m_context, m_context->scissor(scissorX, scissorY, scissorRect.width(), scissorRect.height()));
+ GLC(m_context.get(), m_context->scissor(scissorX, scissorY, scissorRect.width(), scissorRect.height()));
}
bool LayerRendererChromium::makeContextCurrent()
@@ -774,7 +767,7 @@ void LayerRendererChromium::setDrawViewportRect(const IntRect& drawRect, bool fl
m_projectionMatrix = orthoMatrix(drawRect.x(), drawRect.right(), drawRect.bottom(), drawRect.y());
else
m_projectionMatrix = orthoMatrix(drawRect.x(), drawRect.right(), drawRect.y(), drawRect.bottom());
- GLC(m_context, m_context->viewport(0, 0, drawRect.width(), drawRect.height()));
+ GLC(m_context.get(), m_context->viewport(0, 0, drawRect.width(), drawRect.height()));
}
@@ -789,46 +782,6 @@ bool LayerRendererChromium::initializeSharedObjects()
{
makeContextCurrent();
- // The following program composites layers whose contents are the results of a previous
- // render operation and therefore doesn't perform any color swizzling. It is used
- // in scrolling and for compositing offscreen textures.
- char textureLayerVertexShaderString[] =
- "attribute vec4 a_position; \n"
- "attribute vec2 a_texCoord; \n"
- "uniform mat4 matrix; \n"
- "varying vec2 v_texCoord; \n"
- "void main() \n"
- "{ \n"
- " gl_Position = matrix * a_position; \n"
- " v_texCoord = a_texCoord; \n"
- "} \n";
- char textureLayerFragmentShaderString[] =
- "precision mediump float; \n"
- "varying vec2 v_texCoord; \n"
- "uniform sampler2D s_texture; \n"
- "uniform float alpha; \n"
- "void main() \n"
- "{ \n"
- " vec4 texColor = texture2D(s_texture, v_texCoord); \n"
- " gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w) * alpha; \n"
- "} \n";
-
- m_textureLayerShaderProgram = LayerChromium::createShaderProgram(m_context.get(), textureLayerVertexShaderString, textureLayerFragmentShaderString);
- if (!m_textureLayerShaderProgram) {
- LOG_ERROR("LayerRendererChromium: Failed to create scroll shader program");
- cleanupSharedObjects();
- return false;
- }
-
- GLC(m_context, m_textureLayerShaderSamplerLocation = m_context->getUniformLocation(m_textureLayerShaderProgram, "s_texture"));
- GLC(m_context, m_textureLayerShaderMatrixLocation = m_context->getUniformLocation(m_textureLayerShaderProgram, "matrix"));
- GLC(m_context, m_textureLayerShaderAlphaLocation = m_context->getUniformLocation(m_textureLayerShaderProgram, "alpha"));
- if (m_textureLayerShaderSamplerLocation == -1 || m_textureLayerShaderMatrixLocation == -1 || m_textureLayerShaderAlphaLocation == -1) {
- LOG_ERROR("Failed to initialize texture layer shader.");
- cleanupSharedObjects();
- return false;
- }
-
// Create a texture object to hold the contents of the root layer.
m_rootLayerTextureId = createLayerTexture();
if (!m_rootLayerTextureId) {
@@ -838,28 +791,31 @@ bool LayerRendererChromium::initializeSharedObjects()
}
// Turn off filtering for the root layer to avoid blurring from the repeated
// writes and reads to the framebuffer that happen while scrolling.
- GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_rootLayerTextureId));
- GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::NEAREST));
- GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::NEAREST));
+ GLC(m_context.get(), m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_rootLayerTextureId));
+ GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::NEAREST));
+ GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::NEAREST));
// Get the max texture size supported by the system.
- GLC(m_context, m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &m_maxTextureSize));
+ m_maxTextureSize = 0;
+ GLC(m_context.get(), m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &m_maxTextureSize));
// Create an FBO for doing offscreen rendering.
- GLC(m_context, m_offscreenFramebufferId = m_context->createFramebuffer());
+ GLC(m_context.get(), m_offscreenFramebufferId = m_context->createFramebuffer());
m_layerSharedValues = adoptPtr(new LayerChromium::SharedValues(m_context.get()));
m_contentLayerSharedValues = adoptPtr(new ContentLayerChromium::SharedValues(m_context.get()));
m_canvasLayerSharedValues = adoptPtr(new CanvasLayerChromium::SharedValues(m_context.get()));
m_videoLayerSharedValues = adoptPtr(new VideoLayerChromium::SharedValues(m_context.get()));
m_pluginLayerSharedValues = adoptPtr(new PluginLayerChromium::SharedValues(m_context.get()));
+ m_renderSurfaceSharedValues = adoptPtr(new RenderSurfaceChromium::SharedValues(m_context.get()));
if (!m_layerSharedValues->initialized() || !m_contentLayerSharedValues->initialized() || !m_canvasLayerSharedValues->initialized()
- || !m_videoLayerSharedValues->initialized() || !m_pluginLayerSharedValues->initialized()) {
+ || !m_videoLayerSharedValues->initialized() || !m_pluginLayerSharedValues->initialized() || !m_renderSurfaceSharedValues->initialized()) {
cleanupSharedObjects();
return false;
}
+ m_textureManager = TextureManager::create(m_context.get(), textureMemoryLimitBytes, m_maxTextureSize);
return true;
}
@@ -872,11 +828,7 @@ void LayerRendererChromium::cleanupSharedObjects()
m_canvasLayerSharedValues.clear();
m_videoLayerSharedValues.clear();
m_pluginLayerSharedValues.clear();
-
- if (m_textureLayerShaderProgram) {
- GLC(m_context, m_context->deleteProgram(m_textureLayerShaderProgram));
- m_textureLayerShaderProgram = 0;
- }
+ m_renderSurfaceSharedValues.clear();
if (m_rootLayerTextureId) {
deleteLayerTexture(m_rootLayerTextureId);
@@ -884,7 +836,9 @@ void LayerRendererChromium::cleanupSharedObjects()
}
if (m_offscreenFramebufferId)
- GLC(m_context, m_context->deleteFramebuffer(m_offscreenFramebufferId));
+ GLC(m_context.get(), m_context->deleteFramebuffer(m_offscreenFramebufferId));
+
+ m_textureManager.clear();
}
} // namespace WebCore