diff options
Diffstat (limited to 'WebCore/platform/graphics/mac')
-rw-r--r-- | WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp | 15 | ||||
-rw-r--r-- | WebCore/platform/graphics/mac/GraphicsLayerCA.h | 2 | ||||
-rw-r--r-- | WebCore/platform/graphics/mac/GraphicsLayerCA.mm | 30 |
3 files changed, 45 insertions, 2 deletions
diff --git a/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp b/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp index 3b3158f..80c0d03 100644 --- a/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp +++ b/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp @@ -840,10 +840,21 @@ void GraphicsContext3D::releaseShaderCompiler() void GraphicsContext3D::renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height) { ensureContext(m_contextObj); - if (internalformat == DEPTH_STENCIL) + switch (internalformat) { + case DEPTH_STENCIL: internalformat = GL_DEPTH24_STENCIL8_EXT; - else if (internalformat == DEPTH_COMPONENT16) + break; + case DEPTH_COMPONENT16: internalformat = GL_DEPTH_COMPONENT; + break; + case RGBA4: + case RGB5_A1: + internalformat = GL_RGBA; + break; + case RGB565: + internalformat = GL_RGB; + break; + } ::glRenderbufferStorageEXT(target, internalformat, width, height); } diff --git a/WebCore/platform/graphics/mac/GraphicsLayerCA.h b/WebCore/platform/graphics/mac/GraphicsLayerCA.h index 49aebba..26a5de6 100644 --- a/WebCore/platform/graphics/mac/GraphicsLayerCA.h +++ b/WebCore/platform/graphics/mac/GraphicsLayerCA.h @@ -165,6 +165,8 @@ private: void commitLayerChangesBeforeSublayers(); void commitLayerChangesAfterSublayers(); + FloatSize constrainedSize() const; + bool requiresTiledLayer(const FloatSize&) const; void swapFromOrToTiledLayer(bool useTiledLayer); diff --git a/WebCore/platform/graphics/mac/GraphicsLayerCA.mm b/WebCore/platform/graphics/mac/GraphicsLayerCA.mm index 294c82f..bd01353 100644 --- a/WebCore/platform/graphics/mac/GraphicsLayerCA.mm +++ b/WebCore/platform/graphics/mac/GraphicsLayerCA.mm @@ -1050,6 +1050,8 @@ void GraphicsLayerCA::updateSublayerList() void GraphicsLayerCA::updateLayerPosition() { + // FIXME: if constrained the size, the position will be wrong. Fixing this is not trivial. + // Position is offset on the layer by the layer anchor point. CGPoint posPoint = CGPointMake(m_position.x() + m_anchorPoint.x() * m_size.width(), m_position.y() + m_anchorPoint.y() * m_size.height()); @@ -1098,6 +1100,11 @@ void GraphicsLayerCA::updateLayerSize() if (needTiledLayer != m_usingTiledLayer) swapFromOrToTiledLayer(needTiledLayer); + if (m_usingTiledLayer) { + FloatSize sizeToUse = constrainedSize(); + rect = CGRectMake(0, 0, sizeToUse.width(), sizeToUse.height()); + } + [m_layer.get() setBounds:rect]; if (LayerMap* layerCloneMap = m_layerClones.get()) { LayerMap::const_iterator end = layerCloneMap->end(); @@ -2144,6 +2151,29 @@ void GraphicsLayerCA::setDebugBorder(const Color& color, float borderWidth) END_BLOCK_OBJC_EXCEPTIONS } +FloatSize GraphicsLayerCA::constrainedSize() const +{ + float tileColumns = ceilf(m_size.width() / cTiledLayerTileSize); + float tileRows = ceilf(m_size.height() / cTiledLayerTileSize); + double numTiles = tileColumns * tileRows; + + FloatSize constrainedSize = m_size; + const unsigned cMaxTileCount = 512; + while (numTiles > cMaxTileCount) { + // Constrain the wider dimension. + if (constrainedSize.width() >= constrainedSize.height()) { + tileColumns = max(floorf(cMaxTileCount / tileRows), 1.0f); + constrainedSize.setWidth(tileColumns * cTiledLayerTileSize); + } else { + tileRows = max(floorf(cMaxTileCount / tileColumns), 1.0f); + constrainedSize.setHeight(tileRows * cTiledLayerTileSize); + } + numTiles = tileColumns * tileRows; + } + + return constrainedSize; +} + bool GraphicsLayerCA::requiresTiledLayer(const FloatSize& size) const { if (!m_drawsContent) |