Commit aeecdca9 authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

2011-05-11 Nat Duca <nduca@chromium.org>

        Reviewed by James Robinson.

        [chromium] Use mapTexSubImage2D for tile uploads if available
        https://bugs.webkit.org/show_bug.cgi?id=60008

        * platform/graphics/chromium/LayerTilerChromium.cpp:
        (WebCore::LayerTilerChromium::LayerTilerChromium):
        (WebCore::LayerTilerChromium::update):
        (WebCore::LayerTilerChromium::updateFromPixels):
        * platform/graphics/chromium/LayerTilerChromium.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86301 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 60de6041
2011-05-11 Nat Duca <nduca@chromium.org>
Reviewed by James Robinson.
[chromium] Use mapTexSubImage2D for tile uploads if available
https://bugs.webkit.org/show_bug.cgi?id=60008
* platform/graphics/chromium/LayerTilerChromium.cpp:
(WebCore::LayerTilerChromium::LayerTilerChromium):
(WebCore::LayerTilerChromium::update):
(WebCore::LayerTilerChromium::updateFromPixels):
* platform/graphics/chromium/LayerTilerChromium.h:
2011-05-11 Alexis Menard <alexis.menard@openbossa.org>
 
Reviewed by Kenneth Rohde Christiansen.
......@@ -121,6 +121,9 @@ LayerRendererChromium::LayerRendererChromium(PassRefPtr<GraphicsContext3D> conte
, m_defaultRenderSurface(0)
{
m_contextSupportsLatch = m_context->getExtensions()->supports("GL_CHROMIUM_latch");
m_contextSupportsMapSub = m_context->getExtensions()->supports("GL_CHROMIUM_map_sub");
if (m_contextSupportsMapSub)
m_context->getExtensions()->ensureEnabled("GL_CHROMIUM_map_sub");
m_hardwareCompositing = initializeSharedObjects();
m_rootLayerContentTiler = LayerTilerChromium::create(this, IntSize(256, 256), LayerTilerChromium::NoBorderTexels);
ASSERT(m_rootLayerContentTiler);
......
......@@ -73,6 +73,7 @@ public:
~LayerRendererChromium();
GraphicsContext3D* context();
bool contextSupportsMapSub() const { return m_contextSupportsMapSub; }
void invalidateRootLayerRect(const IntRect& dirtyRect);
......@@ -240,6 +241,7 @@ private:
bool m_childContextsWereCopied;
bool m_contextSupportsLatch;
bool m_contextSupportsMapSub;
bool m_animating;
......
......@@ -30,6 +30,7 @@
#include "LayerTilerChromium.h"
#include "Extensions3DChromium.h"
#include "GraphicsContext.h"
#include "GraphicsContext3D.h"
#include "LayerRendererChromium.h"
......@@ -53,6 +54,7 @@ PassOwnPtr<LayerTilerChromium> LayerTilerChromium::create(LayerRendererChromium*
LayerTilerChromium::LayerTilerChromium(LayerRendererChromium* layerRenderer, const IntSize& tileSize, BorderTexelOption border)
: m_skipsDraw(false)
, m_tilingData(max(tileSize.width(), tileSize.height()), 0, 0, border == HasBorderTexels)
, m_useMapSubForUploads(layerRenderer->contextSupportsMapSub())
, m_layerRenderer(layerRenderer)
{
setTileSize(tileSize);
......@@ -84,7 +86,8 @@ void LayerTilerChromium::setTileSize(const IntSize& size)
reset();
m_tileSize = size;
m_tilePixels = adoptArrayPtr(new uint8_t[m_tileSize.width() * m_tileSize.height() * 4]);
if (!m_useMapSubForUploads)
m_tilePixels = adoptArrayPtr(new uint8_t[m_tileSize.width() * m_tileSize.height() * 4]);
m_tilingData.setMaxTextureSize(max(size.width(), size.height()));
}
......@@ -341,27 +344,46 @@ void LayerTilerChromium::updateFromPixels(const IntRect& contentRect, const IntR
if (paintOffset.y() + destRect.height() > paintRect.height())
CRASH();
const uint8_t* pixelSource;
if (paintRect.width() == sourceRect.width() && !paintOffset.x())
pixelSource = &paintPixels[4 * paintOffset.y() * paintRect.width()];
else {
// Strides not equal, so do a row-by-row memcpy from the
// paint results into a temp buffer for uploading.
for (int row = 0; row < destRect.height(); ++row)
memcpy(&m_tilePixels[destRect.width() * 4 * row],
&paintPixels[4 * (paintOffset.x() + (paintOffset.y() + row) * paintRect.width())],
destRect.width() * 4);
pixelSource = &m_tilePixels[0];
}
tile->texture()->bindTexture();
const GC3Dint filter = m_tilingData.borderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST;
GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter));
GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter));
GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixelSource));
tile->texture()->bindTexture();
if (m_useMapSubForUploads) {
// Upload tile data via a mapped transfer buffer
Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context->getExtensions());
uint8_t* pixelDest = static_cast<uint8_t*>(extensions->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY));
ASSERT(pixelDest);
if (paintRect.width() == sourceRect.width() && !paintOffset.x())
memcpy(pixelDest, &paintPixels[4 * paintOffset.y() * paintRect.width()], paintRect.width() * destRect.height() * 4);
else {
// Strides not equal, so do a row-by-row memcpy from the
// paint results into the pixelDest
for (int row = 0; row < destRect.height(); ++row)
memcpy(&pixelDest[destRect.width() * 4 * row],
&paintPixels[4 * (paintOffset.x() + (paintOffset.y() + row) * paintRect.width())],
destRect.width() * 4);
}
extensions->unmapTexSubImage2DCHROMIUM(pixelDest);
} else {
const uint8_t* pixelSource;
if (paintRect.width() == sourceRect.width() && !paintOffset.x())
pixelSource = &paintPixels[4 * paintOffset.y() * paintRect.width()];
else {
// Strides not equal, so do a row-by-row memcpy from the
// paint results into a temp buffer for uploading.
for (int row = 0; row < destRect.height(); ++row)
memcpy(&m_tilePixels[destRect.width() * 4 * row],
&paintPixels[4 * (paintOffset.x() + (paintOffset.y() + row) * paintRect.width())],
destRect.width() * 4);
pixelSource = &m_tilePixels[0];
}
GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixelSource));
}
tile->clearDirty();
}
......
......@@ -167,6 +167,9 @@ private:
TilingData m_tilingData;
// Whether the tiler will use GL_CHROMIUM_map_sub for texture uploads.
bool m_useMapSubForUploads;
LayerRendererChromium* m_layerRenderer;
};
......
......@@ -27,6 +27,7 @@
#if USE(ACCELERATED_COMPOSITING)
#include "CCHeadsUpDisplay.h"
#include "Extensions3DChromium.h"
#include "Font.h"
#include "FontDescription.h"
#include "GraphicsContext3D.h"
......@@ -50,6 +51,7 @@ CCHeadsUpDisplay::CCHeadsUpDisplay(LayerRendererChromium* owner)
, m_layerRenderer(owner)
, m_showFPSCounter(false)
, m_showPlatformLayerTree(false)
, m_useMapSubForUploads(owner->contextSupportsMapSub())
{
m_beginTimeHistoryInSec[0] = currentTime();
m_beginTimeHistoryInSec[1] = m_beginTimeHistoryInSec[0];
......@@ -106,7 +108,13 @@ void CCHeadsUpDisplay::draw()
PlatformCanvas::AutoLocker locker(&canvas);
m_hudTexture->bindTexture();
GLC(context.get(), context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, canvas.size().width(), canvas.size().height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, locker.pixels()));
if (m_useMapSubForUploads) {
Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context->getExtensions());
uint8_t* pixelDest = static_cast<uint8_t*>(extensions->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, hudSize.width(), hudSize.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY));
memcpy(pixelDest, locker.pixels(), hudSize.width() * hudSize.height() * 4);
extensions->unmapTexSubImage2DCHROMIUM(pixelDest);
} else
GLC(context.get(), context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, canvas.size().width(), canvas.size().height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, locker.pixels()));
}
// Draw the HUD onto the default render surface.
......
......@@ -86,6 +86,8 @@ private:
OwnPtr<Font> m_smallFont;
OwnPtr<Font> m_mediumFont;
bool m_useMapSubForUploads;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment