Diff
Modified: trunk/Source/Platform/ChangeLog (124395 => 124396)
--- trunk/Source/Platform/ChangeLog 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/Platform/ChangeLog 2012-08-02 01:18:42 UTC (rev 124396)
@@ -1,3 +1,18 @@
+2012-08-01 James Robinson <[email protected]>
+
+ [chromium] Move compositor HUD font atlas initialization code out of compositor core
+ https://bugs.webkit.org/show_bug.cgi?id=92924
+
+ Reviewed by Adrienne Walker.
+
+ The chromium compositor does not have any text rendering capabilities. It generally does not need them, but it
+ is helpful for some debugging aids to be able to render at least ASCII text to the screen. This provides an API
+ on WebLayerTreeView by which an embedder can provide an ASCII glyph atlas to use for displaying debug
+ information.
+
+ * chromium/public/WebLayerTreeView.h:
+ (WebLayerTreeView):
+
2012-08-01 Jian Li <[email protected]>
Unreviewed. Fix build break for chromium.
Modified: trunk/Source/Platform/chromium/public/WebLayerTreeView.h (124395 => 124396)
--- trunk/Source/Platform/chromium/public/WebLayerTreeView.h 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/Platform/chromium/public/WebLayerTreeView.h 2012-08-02 01:18:42 UTC (rev 124396)
@@ -26,6 +26,7 @@
#ifndef WebLayerTreeView_h
#define WebLayerTreeView_h
+#include "SkBitmap.h"
#include "WebColor.h"
#include "WebCommon.h"
#include "WebNonCopyable.h"
@@ -175,6 +176,10 @@
// This call is relatively expensive in threaded mode as it blocks on the compositor thread.
WEBKIT_EXPORT void renderingStats(WebRenderingStats&) const;
+ // Provides a font atlas to use for debug visualizations. The atlas must be a bitmap containing glyph data, a table of
+ // ASCII character values to a subrectangle of the atlas representing the corresponding glyph, and the glyph height.
+ WEBKIT_EXPORT void setFontAtlas(SkBitmap, WebRect asciiToRectTable[128], int fontHeight);
+
// Simulates a lost context. For testing only.
WEBKIT_EXPORT void loseCompositorContext(int numTimes);
Modified: trunk/Source/WebCore/ChangeLog (124395 => 124396)
--- trunk/Source/WebCore/ChangeLog 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/WebCore/ChangeLog 2012-08-02 01:18:42 UTC (rev 124396)
@@ -1,3 +1,52 @@
+2012-08-01 James Robinson <[email protected]>
+
+ [chromium] Move compositor HUD font atlas initialization code out of compositor core
+ https://bugs.webkit.org/show_bug.cgi?id=92924
+
+ Reviewed by Adrienne Walker.
+
+ This moves the HUD font atlas initialization code out of the compositor implementation to cut out Font-related
+ dependencies. The new flow is that an embedder can pass a font atlas to the CCLayerTreeHost, after which the
+ atlas is provided the HUD layer (if any) on the next commit. The HUD layer renders text using the font atlas if
+ it has any if the settings require text.
+
+ HUD tested manually, we don't have automated tests for this debugging-only feature.
+
+ * platform/graphics/chromium/CompositorHUDFontAtlas.cpp:
+ (WebCore):
+ (WebCore::CompositorHUDFontAtlas::generateFontAtlas):
+ * platform/graphics/chromium/CompositorHUDFontAtlas.h:
+ (CompositorHUDFontAtlas):
+ * platform/graphics/chromium/HeadsUpDisplayLayerChromium.cpp:
+ (WebCore::HeadsUpDisplayLayerChromium::create):
+ (WebCore::HeadsUpDisplayLayerChromium::HeadsUpDisplayLayerChromium):
+ (WebCore::HeadsUpDisplayLayerChromium::setFontAtlas):
+ (WebCore):
+ (WebCore::HeadsUpDisplayLayerChromium::createCCLayerImpl):
+ (WebCore::HeadsUpDisplayLayerChromium::pushPropertiesTo):
+ * platform/graphics/chromium/HeadsUpDisplayLayerChromium.h:
+ (HeadsUpDisplayLayerChromium):
+ * platform/graphics/chromium/cc/CCFontAtlas.cpp:
+ (WebCore::CCFontAtlas::CCFontAtlas):
+ * platform/graphics/chromium/cc/CCFontAtlas.h:
+ (WebCore):
+ (WebCore::CCFontAtlas::create):
+ (CCFontAtlas):
+ * platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp:
+ (WebCore::CCHeadsUpDisplayLayerImpl::CCHeadsUpDisplayLayerImpl):
+ (WebCore::CCHeadsUpDisplayLayerImpl::setFontAtlas):
+ (WebCore):
+ * platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h:
+ (WebCore::CCHeadsUpDisplayLayerImpl::create):
+ (CCHeadsUpDisplayLayerImpl):
+ * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+ (WebCore::CCLayerTreeHost::setFontAtlas):
+ (WebCore):
+ (WebCore::CCLayerTreeHost::willCommit):
+ * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+ (WebCore):
+ (CCLayerTreeHost):
+
2012-08-01 Antoine Labour <[email protected]>
[chromium] factor out the optimization pass in CCRenderSurfaceFilters::apply
Modified: trunk/Source/WebCore/platform/graphics/chromium/CompositorHUDFontAtlas.cpp (124395 => 124396)
--- trunk/Source/WebCore/platform/graphics/chromium/CompositorHUDFontAtlas.cpp 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/WebCore/platform/graphics/chromium/CompositorHUDFontAtlas.cpp 2012-08-02 01:18:42 UTC (rev 124396)
@@ -37,6 +37,8 @@
#include "TextRun.h"
#include "skia/ext/platform_canvas.h"
+using WebKit::WebRect;
+
namespace WebCore {
#define ATLAS_SIZE 128
@@ -48,10 +50,10 @@
}
// Paints the font into the atlas, from left-to-right, top-to-bottom, starting at
-// startingPosition. At the same time, it updates the ascii-to-IntRect mapping for
+// startingPosition. At the same time, it updates the ascii-to-WebRect mapping for
// each character. By doing things this way, it is possible to support variable-width
// fonts and multiple fonts on the same atlas.
-SkBitmap CompositorHUDFontAtlas::generateFontAtlas(IntRect asciiToRectTable[128], int& fontHeight)
+SkBitmap CompositorHUDFontAtlas::generateFontAtlas(WebRect asciiToRectTable[128], int& fontHeight)
{
fontHeight = 14;
@@ -91,7 +93,7 @@
atlasContext.strokeRect(FloatRect(FloatPoint(position.x() + 1, position.y() - textHeight + 1 + inflation), FloatSize(textWidth - 2, textHeight - 2 - inflation)), 1);
// Initialize the rect that would be copied when drawing this glyph from the atlas.
- asciiToRectTable[0] = IntRect(IntPoint(position.x(), position.y() - textHeight), IntSize(textWidth, textHeight + inflation));
+ asciiToRectTable[0] = WebRect(position.x(), position.y() - textHeight, textWidth, textHeight + inflation);
// Increment to the position where the next glyph will be placed.
position.setX(position.x() + textWidth);
@@ -114,7 +116,7 @@
atlasContext.drawText(font, text, position);
// Initialize the rect that would be copied when drawing this glyph from the atlas.
- asciiToRectTable[i] = IntRect(IntPoint(position.x(), position.y() - textHeight), IntSize(textWidth, textHeight + inflation));
+ asciiToRectTable[i] = WebRect(position.x(), position.y() - textHeight, textWidth, textHeight + inflation);
// Increment to the position where the next glyph will be placed.
position.setX(position.x() + textWidth);
Modified: trunk/Source/WebCore/platform/graphics/chromium/CompositorHUDFontAtlas.h (124395 => 124396)
--- trunk/Source/WebCore/platform/graphics/chromium/CompositorHUDFontAtlas.h 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/WebCore/platform/graphics/chromium/CompositorHUDFontAtlas.h 2012-08-02 01:18:42 UTC (rev 124396)
@@ -26,8 +26,8 @@
#ifndef CompositorHUDFontAtlas_h
#define CompositorHUDFontAtlas_h
-#include "IntRect.h"
#include "SkBitmap.h"
+#include <public/WebRect.h>
namespace WebCore {
@@ -36,7 +36,7 @@
// This is a helper function that can generate a font atlas suitable for the compositor's heads up display.
// Returns a bitmap containing glyphs and populates asciiToRectTable with the
// location of each glyph.
- static SkBitmap generateFontAtlas(IntRect asciiToRectTable[128], int& fontHeight);
+ static SkBitmap generateFontAtlas(WebKit::WebRect asciiToRectTable[128], int& fontHeight);
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/chromium/HeadsUpDisplayLayerChromium.cpp (124395 => 124396)
--- trunk/Source/WebCore/platform/graphics/chromium/HeadsUpDisplayLayerChromium.cpp 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/WebCore/platform/graphics/chromium/HeadsUpDisplayLayerChromium.cpp 2012-08-02 01:18:42 UTC (rev 124396)
@@ -33,23 +33,16 @@
namespace WebCore {
-PassRefPtr<HeadsUpDisplayLayerChromium> HeadsUpDisplayLayerChromium::create(const CCLayerTreeSettings& settings)
+PassRefPtr<HeadsUpDisplayLayerChromium> HeadsUpDisplayLayerChromium::create()
{
- return adoptRef(new HeadsUpDisplayLayerChromium(settings));
+ return adoptRef(new HeadsUpDisplayLayerChromium());
}
-HeadsUpDisplayLayerChromium::HeadsUpDisplayLayerChromium(const CCLayerTreeSettings& settings)
+HeadsUpDisplayLayerChromium::HeadsUpDisplayLayerChromium()
: LayerChromium()
{
setBounds(IntSize(512, 128));
-
- // Only allocate the font atlas if we have reason to use the heads-up display.
- if (settings.showFPSCounter || settings.showPlatformLayerTree) {
- TRACE_EVENT0("cc", "HeadsUpDisplayLayerChromium::initializeFontAtlas");
- m_fontAtlas = CCFontAtlas::create();
- m_fontAtlas->initialize();
- }
}
HeadsUpDisplayLayerChromium::~HeadsUpDisplayLayerChromium()
@@ -73,9 +66,26 @@
setBounds(bounds);
}
+void HeadsUpDisplayLayerChromium::setFontAtlas(PassOwnPtr<CCFontAtlas> fontAtlas)
+{
+ m_fontAtlas = fontAtlas;
+ setNeedsCommit();
+}
+
PassOwnPtr<CCLayerImpl> HeadsUpDisplayLayerChromium::createCCLayerImpl()
{
- return CCHeadsUpDisplayLayerImpl::create(m_layerId, m_fontAtlas.release());
+ return CCHeadsUpDisplayLayerImpl::create(m_layerId);
}
+void HeadsUpDisplayLayerChromium::pushPropertiesTo(CCLayerImpl* layerImpl)
+{
+ LayerChromium::pushPropertiesTo(layerImpl);
+
+ if (!m_fontAtlas)
+ return;
+
+ CCHeadsUpDisplayLayerImpl* hudLayerImpl = static_cast<CCHeadsUpDisplayLayerImpl*>(layerImpl);
+ hudLayerImpl->setFontAtlas(m_fontAtlas.release());
}
+
+}
Modified: trunk/Source/WebCore/platform/graphics/chromium/HeadsUpDisplayLayerChromium.h (124395 => 124396)
--- trunk/Source/WebCore/platform/graphics/chromium/HeadsUpDisplayLayerChromium.h 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/WebCore/platform/graphics/chromium/HeadsUpDisplayLayerChromium.h 2012-08-02 01:18:42 UTC (rev 124396)
@@ -33,20 +33,21 @@
namespace WebCore {
-struct CCLayerTreeSettings;
-
class HeadsUpDisplayLayerChromium : public LayerChromium {
public:
- static PassRefPtr<HeadsUpDisplayLayerChromium> create(const CCLayerTreeSettings&);
+ static PassRefPtr<HeadsUpDisplayLayerChromium> create();
virtual ~HeadsUpDisplayLayerChromium();
virtual void update(CCTextureUpdater&, const CCOcclusionTracker*, CCRenderingStats&) OVERRIDE;
virtual bool drawsContent() const OVERRIDE { return true; }
+ void setFontAtlas(PassOwnPtr<CCFontAtlas>);
+
virtual PassOwnPtr<CCLayerImpl> createCCLayerImpl() OVERRIDE;
+ virtual void pushPropertiesTo(CCLayerImpl*) OVERRIDE;
protected:
- explicit HeadsUpDisplayLayerChromium(const CCLayerTreeSettings&);
+ HeadsUpDisplayLayerChromium();
private:
OwnPtr<CCFontAtlas> m_fontAtlas;
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCFontAtlas.cpp (124395 => 124396)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCFontAtlas.cpp 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCFontAtlas.cpp 2012-08-02 01:18:42 UTC (rev 124396)
@@ -27,7 +27,6 @@
#if USE(ACCELERATED_COMPOSITING)
#include "CCFontAtlas.h"
-#include "CompositorHUDFontAtlas.h"
#include "SkCanvas.h"
#include "cc/CCProxy.h"
@@ -35,24 +34,18 @@
using namespace std;
-
-CCFontAtlas::CCFontAtlas()
- : m_fontHeight(0)
+CCFontAtlas::CCFontAtlas(SkBitmap bitmap, IntRect asciiToRectTable[128], int fontHeight)
+ : m_atlas(bitmap)
+ , m_fontHeight(fontHeight)
{
+ for (size_t i = 0; i < 128; ++i)
+ m_asciiToRectTable[i] = asciiToRectTable[i];
}
-
CCFontAtlas::~CCFontAtlas()
{
}
-void CCFontAtlas::initialize()
-{
- ASSERT(CCProxy::isMainThread());
-
- m_atlas = CompositorHUDFontAtlas::generateFontAtlas(m_asciiToRectTable, m_fontHeight);
-}
-
void CCFontAtlas::drawText(SkCanvas* canvas, const String& text, const IntPoint& destPosition, const IntSize& clip) const
{
ASSERT(CCProxy::isImplThread());
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCFontAtlas.h (124395 => 124396)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCFontAtlas.h 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCFontAtlas.h 2012-08-02 01:18:42 UTC (rev 124396)
@@ -44,20 +44,15 @@
class IntSize;
// This class provides basic ability to draw text onto the heads-up display.
-// It must be initialized on the main thread, and it can only draw text on the impl thread.
class CCFontAtlas {
WTF_MAKE_NONCOPYABLE(CCFontAtlas);
public:
- static PassOwnPtr<CCFontAtlas> create()
+ static PassOwnPtr<CCFontAtlas> create(SkBitmap bitmap, IntRect asciiToRectTable[128], int fontHeight)
{
- return adoptPtr(new CCFontAtlas());
+ return adoptPtr(new CCFontAtlas(bitmap, asciiToRectTable, fontHeight));
}
~CCFontAtlas();
- // Creates the font atlas.
- // - Should only be called on the main thread.
- void initialize();
-
// Draws multiple lines of text where each line of text is separated by '\n'.
// - Correct glyphs will be drawn for ASCII codes in the range 32-127; any characters
// outside that range will be displayed as a default rectangle glyph.
@@ -70,7 +65,7 @@
void drawDebugAtlas(SkCanvas*, const IntPoint& destPosition) const;
private:
- CCFontAtlas();
+ CCFontAtlas(SkBitmap, IntRect asciiToRectTable[128], int fontHeight);
void drawOneLineOfTextInternal(SkCanvas*, const String&, const IntPoint& destPosition) const;
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp (124395 => 124396)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp 2012-08-02 01:18:42 UTC (rev 124396)
@@ -45,9 +45,8 @@
namespace WebCore {
-CCHeadsUpDisplayLayerImpl::CCHeadsUpDisplayLayerImpl(int id, PassOwnPtr<CCFontAtlas> fontAtlas)
- : CCLayerImpl(id),
- m_fontAtlas(fontAtlas)
+CCHeadsUpDisplayLayerImpl::CCHeadsUpDisplayLayerImpl(int id)
+ : CCLayerImpl(id)
{
}
@@ -55,6 +54,11 @@
{
}
+void CCHeadsUpDisplayLayerImpl::setFontAtlas(PassOwnPtr<CCFontAtlas> fontAtlas)
+{
+ m_fontAtlas = fontAtlas;
+}
+
void CCHeadsUpDisplayLayerImpl::willDraw(CCResourceProvider* resourceProvider)
{
CCLayerImpl::willDraw(resourceProvider);
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h (124395 => 124396)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h 2012-08-02 01:18:42 UTC (rev 124396)
@@ -40,12 +40,14 @@
class CCHeadsUpDisplayLayerImpl : public CCLayerImpl {
public:
- static PassOwnPtr<CCHeadsUpDisplayLayerImpl> create(int id, PassOwnPtr<CCFontAtlas> fontAtlas)
+ static PassOwnPtr<CCHeadsUpDisplayLayerImpl> create(int id)
{
- return adoptPtr(new CCHeadsUpDisplayLayerImpl(id, fontAtlas));
+ return adoptPtr(new CCHeadsUpDisplayLayerImpl(id));
}
virtual ~CCHeadsUpDisplayLayerImpl();
+ void setFontAtlas(PassOwnPtr<CCFontAtlas>);
+
virtual void willDraw(CCResourceProvider*) OVERRIDE;
virtual void appendQuads(CCQuadSink&, const CCSharedQuadState*, bool& hadMissingTiles) OVERRIDE;
virtual void didDraw(CCResourceProvider*) OVERRIDE;
@@ -55,7 +57,7 @@
virtual bool layerIsAlwaysDamaged() const OVERRIDE { return true; }
private:
- CCHeadsUpDisplayLayerImpl(int, PassOwnPtr<CCFontAtlas>);
+ explicit CCHeadsUpDisplayLayerImpl(int);
virtual const char* layerTypeAsString() const OVERRIDE { return "HeadsUpDisplayLayer"; }
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (124395 => 124396)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2012-08-02 01:18:42 UTC (rev 124396)
@@ -251,12 +251,22 @@
m_commitNumber++;
}
+void CCLayerTreeHost::setFontAtlas(PassOwnPtr<CCFontAtlas> fontAtlas)
+{
+ m_fontAtlas = fontAtlas;
+ setNeedsCommit();
+}
+
void CCLayerTreeHost::willCommit()
{
m_client->willCommit();
if (m_rootLayer && m_settings.showDebugInfo()) {
if (!m_hudLayer)
- m_hudLayer = HeadsUpDisplayLayerChromium::create(m_settings);
+ m_hudLayer = HeadsUpDisplayLayerChromium::create();
+
+ if (m_fontAtlas)
+ m_hudLayer->setFontAtlas(m_fontAtlas.release());
+
if (m_hudLayer->parent() != m_rootLayer.get()) {
m_hudLayer->removeFromParent();
m_rootLayer->addChild(m_hudLayer);
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (124395 => 124396)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h 2012-08-02 01:18:42 UTC (rev 124396)
@@ -47,13 +47,15 @@
namespace WebCore {
+class CCFontAtlas;
class CCGraphicsContext;
class CCLayerChromium;
class CCLayerTreeHostImpl;
class CCLayerTreeHostImplClient;
+class CCPrioritizedTextureManager;
class CCTextureUpdater;
+class HeadsUpDisplayLayerChromium;
class Region;
-class CCPrioritizedTextureManager;
struct CCScrollAndScaleSet;
class CCLayerTreeHostClient {
@@ -265,6 +267,8 @@
void setDeviceScaleFactor(float);
float deviceScaleFactor() const { return m_deviceScaleFactor; }
+ void setFontAtlas(PassOwnPtr<CCFontAtlas>);
+
protected:
CCLayerTreeHost(CCLayerTreeHostClient*, const CCLayerTreeSettings&);
bool initialize();
@@ -307,7 +311,9 @@
int m_numFailedRecreateAttempts;
RefPtr<LayerChromium> m_rootLayer;
- RefPtr<LayerChromium> m_hudLayer;
+ RefPtr<HeadsUpDisplayLayerChromium> m_hudLayer;
+ OwnPtr<CCFontAtlas> m_fontAtlas;
+
OwnPtr<CCPrioritizedTextureManager> m_contentsTextureManager;
OwnPtr<CCPrioritizedTexture> m_surfaceMemoryPlaceholder;
@@ -331,6 +337,7 @@
TextureList m_deleteTextureAfterCommitList;
size_t m_partialTextureUpdateRequests;
+
static bool s_needsFilterContext;
};
Modified: trunk/Source/WebKit/chromium/ChangeLog (124395 => 124396)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-08-02 01:18:42 UTC (rev 124396)
@@ -1,3 +1,19 @@
+2012-08-01 James Robinson <[email protected]>
+
+ [chromium] Move compositor HUD font atlas initialization code out of compositor core
+ https://bugs.webkit.org/show_bug.cgi?id=92924
+
+ Reviewed by Adrienne Walker.
+
+ This initializes the compositor's font atlas when initialization the compositor if the "Show FPS counter" or
+ "Show layer tree" settings are true.
+
+ * src/WebLayerTreeView.cpp:
+ (WebKit::WebLayerTreeView::setFontAtlas):
+ (WebKit):
+ * src/WebViewImpl.cpp:
+ (WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
+
2012-08-01 Jian Li <[email protected]>
[chromium] Make WebKit API support draggable region change update
Modified: trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp (124395 => 124396)
--- trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp 2012-08-02 01:18:42 UTC (rev 124396)
@@ -29,6 +29,7 @@
#include "GraphicsContext3DPrivate.h"
#include "LayerChromium.h"
#include "WebLayerTreeViewImpl.h"
+#include "cc/CCFontAtlas.h"
#include "cc/CCGraphicsContext.h"
#include "cc/CCLayerTreeHost.h"
#include "cc/CCRenderingStats.h"
@@ -189,6 +190,15 @@
stats.totalRasterizeTimeInSeconds = ccStats.totalRasterizeTimeInSeconds;
}
+void WebLayerTreeView::setFontAtlas(SkBitmap bitmap, WebRect asciiToWebRectTable[128], int fontHeight)
+{
+ IntRect asciiToRectTable[128];
+ for (int i = 0; i < 128; ++i)
+ asciiToRectTable[i] = asciiToWebRectTable[i];
+ OwnPtr<CCFontAtlas> fontAtlas = CCFontAtlas::create(bitmap, asciiToRectTable, fontHeight);
+ m_private->layerTreeHost()->setFontAtlas(fontAtlas.release());
+}
+
void WebLayerTreeView::loseCompositorContext(int numTimes)
{
m_private->layerTreeHost()->loseContext(numTimes);
Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (124395 => 124396)
--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2012-08-02 01:18:42 UTC (rev 124396)
@@ -42,6 +42,7 @@
#include "Color.h"
#include "ColorSpace.h"
#include "CompositionUnderlineVectorBuilder.h"
+#include "CompositorHUDFontAtlas.h"
#include "ContextFeaturesClientImpl.h"
#include "ContextMenu.h"
#include "ContextMenuController.h"
@@ -3668,6 +3669,15 @@
m_compositorCreationFailed = false;
if (m_pageOverlays)
m_pageOverlays->update();
+
+ // Only allocate the font atlas if we have reason to use the heads-up display.
+ if (layerTreeViewSettings.showFPSCounter || layerTreeViewSettings.showPlatformLayerTree) {
+ TRACE_EVENT0("cc", "WebViewImpl::setIsAcceleratedCompositingActive(true) initialize font atlas");
+ WebRect asciiToRectTable[128];
+ int fontHeight;
+ SkBitmap bitmap = WebCore::CompositorHUDFontAtlas::generateFontAtlas(asciiToRectTable, fontHeight);
+ m_layerTreeView.setFontAtlas(bitmap, asciiToRectTable, fontHeight);
+ }
} else {
m_nonCompositedContentHost.clear();
m_isAcceleratedCompositingActive = false;
Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp (124395 => 124396)
--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp 2012-08-02 00:49:47 UTC (rev 124395)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp 2012-08-02 01:18:42 UTC (rev 124396)
@@ -2336,7 +2336,7 @@
ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get());
rootLayer->addChild(ioSurfaceLayer.release());
- OwnPtr<CCHeadsUpDisplayLayerImpl> hudLayer = CCHeadsUpDisplayLayerImpl::create(6, nullptr);
+ OwnPtr<CCHeadsUpDisplayLayerImpl> hudLayer = CCHeadsUpDisplayLayerImpl::create(6);
hudLayer->setBounds(IntSize(10, 10));
hudLayer->setAnchorPoint(FloatPoint(0, 0));
hudLayer->setContentBounds(IntSize(10, 10));