Changeset 89837 in webkit
- Timestamp:
- Jun 27, 2011 11:05:54 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 19 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r89836 r89837 1 2011-05-17 Nat Duca <nduca@chromium.org> 2 3 Reviewed by James Robinson. 4 5 [chromium] Implement CCLayerTreeHost and CCLayerTreeHostImpl portions of threaded compositor 6 https://bugs.webkit.org/show_bug.cgi?id=58408 7 8 Create CCLayerTreeHost and CCLayerTreeHostImpl, which are the main 9 thread and compositor thread halves of a composited view. Communication 10 between the two is based on the design used in FileStreamProxy. 11 12 * WebCore.gypi: 13 * platform/chromium/TraceEvent.h: 14 * platform/graphics/chromium/LayerRendererChromium.cpp: 15 (WebCore::LayerRendererChromium::create): 16 (WebCore::LayerRendererChromium::LayerRendererChromium): 17 (WebCore::LayerRendererChromium::setViewport): 18 (WebCore::LayerRendererChromium::updateLayers): 19 (WebCore::LayerRendererChromium::drawLayers): 20 (WebCore::LayerRendererChromiumImpl::create): 21 (WebCore::LayerRendererChromiumImpl::drawLayersAndPresent): 22 (WebCore::LayerRendererChromiumImpl::LayerRendererChromiumImpl): 23 (WebCore::LayerRendererChromiumImpl::drawLayersOnMainThread): 24 (WebCore::LayerRendererChromiumImplProxy::create): 25 (WebCore::LayerRendererChromiumImplProxy::createLayerTreeHostImpl): 26 (WebCore::LayerRendererChromiumImplProxy::LayerRendererChromiumImplProxy): 27 (WebCore::LayerRendererChromium::createLayerTreeHostImplProxy): 28 * platform/graphics/chromium/LayerRendererChromium.h: 29 * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp: 30 (WebCore::CCHeadsUpDisplay::setShowFPSCounter): 31 (WebCore::CCHeadsUpDisplay::setShowPlatformLayerTree): 32 * platform/graphics/chromium/cc/CCHeadsUpDisplay.h: 33 (WebCore::CCHeadsUpDisplay::currentFrameNumber): 34 * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: Copied from Source/WebCore/platform/graphics/chromium/cc/CCThread.cpp. 35 (WebCore::CCLayerTreeHost::CCLayerTreeHost): 36 (WebCore::CCLayerTreeHost::init): 37 (WebCore::CCLayerTreeHost::~CCLayerTreeHost): 38 (WebCore::CCLayerTreeHost::beginCommit): 39 (WebCore::CCLayerTreeHost::commitComplete): 40 (WebCore::CCLayerTreeHost::animateAndLayout): 41 (WebCore::CCLayerTreeHost::createLayerTreeHostCommitter): 42 (WebCore::CCLayerTreeHost::setNeedsCommitAndRedraw): 43 (WebCore::CCLayerTreeHost::setNeedsRedraw): 44 (WebCore::CCLayerTreeHost::updateLayers): 45 * platform/graphics/chromium/cc/CCLayerTreeHost.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCThread.cpp. 46 (WebCore::CCLayerTreeHost::frameNumber): 47 * platform/graphics/chromium/cc/CCLayerTreeHostCommitter.cpp: Copied from Source/WebCore/platform/graphics/chromium/cc/CCThread.cpp. 48 (WebCore::CCLayerTreeHostCommitter::create): 49 (WebCore::CCLayerTreeHostCommitter::commit): 50 * platform/graphics/chromium/cc/CCLayerTreeHostCommitter.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCThread.cpp. 51 (WebCore::CCLayerTreeHostCommitter::CCLayerTreeHostCommitter): 52 * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp: Added. 53 (WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl): 54 (WebCore::CCLayerTreeHostImpl::~CCLayerTreeHostImpl): 55 (WebCore::CCLayerTreeHostImpl::beginCommit): 56 (WebCore::CCLayerTreeHostImpl::commitComplete): 57 (WebCore::CCLayerTreeHostImpl::drawLayers): 58 (WebCore::CCLayerTreeHostImpl::setNeedsCommitAndRedraw): 59 (WebCore::CCLayerTreeHostImpl::setNeedsRedraw): 60 * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCThread.cpp. 61 (WebCore::CCLayerTreeHostImplClient::~CCLayerTreeHostImplClient): 62 (WebCore::CCLayerTreeHostImpl::frameNumber): 63 (WebCore::CCLayerTreeHostImpl::sourceFrameNumber): 64 (WebCore::CCLayerTreeHostImpl::setSourceFrameNumber): 65 * platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp: Added. 66 (WebCore::CCLayerTreeHostImplProxy::CCLayerTreeHostImplProxy): 67 (WebCore::CCLayerTreeHostImplProxy::start): 68 (WebCore::CCLayerTreeHostImplProxy::~CCLayerTreeHostImplProxy): 69 (WebCore::CCLayerTreeHostImplProxy::isStarted): 70 (WebCore::CCLayerTreeHostImplProxy::setNeedsCommitAndRedraw): 71 (WebCore::CCLayerTreeHostImplProxy::setNeedsRedraw): 72 (WebCore::CCLayerTreeHostImplProxy::stop): 73 (WebCore::CCLayerTreeHostImplProxy::postDrawLayersTaskOnCCThread): 74 (WebCore::CCLayerTreeHostImplProxy::requestFrameAndCommitOnCCThread): 75 (WebCore::CCLayerTreeHostImplProxy::isMainThread): 76 (WebCore::CCLayerTreeHostImplProxy::isCCThread): 77 (WebCore::CCLayerTreeHostImplProxy::requestFrameAndCommit): 78 (WebCore::CCLayerTreeHostImplProxy::commitOnCCThread): 79 (WebCore::CCLayerTreeHostImplProxy::drawLayersOnCCThread): 80 (WebCore::CCLayerTreeHostImplProxy::setNeedsCommitAndRedrawOnCCThread): 81 (WebCore::CCLayerTreeHostImplProxy::setNeedsRedrawOnCCThread): 82 (WebCore::CCLayerTreeHostImplProxy::initImplOnCCThread): 83 (WebCore::CCLayerTreeHostImplProxy::layerTreeHostClosedOnCCThread): 84 * platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.h: Added. 85 (WebCore::CCLayerTreeHostImplProxy::host): 86 * platform/graphics/chromium/cc/CCMainThreadTask.h: 87 * platform/graphics/chromium/cc/CCThread.cpp: 88 (WebCore::CCThread::runLoop): 89 * platform/graphics/chromium/cc/CCThreadTask.h: 90 1 91 2011-06-27 Abhishek Arya <inferno@chromium.org> 2 92 -
trunk/Source/WebCore/WebCore.gypi
r89833 r89837 4166 4166 'platform/graphics/chromium/cc/CCLayerSorter.cpp', 4167 4167 'platform/graphics/chromium/cc/CCLayerSorter.h', 4168 'platform/graphics/chromium/cc/CCLayerTreeHost.cpp', 4169 'platform/graphics/chromium/cc/CCLayerTreeHost.h', 4170 'platform/graphics/chromium/cc/CCLayerTreeHostCommitter.cpp', 4171 'platform/graphics/chromium/cc/CCLayerTreeHostCommitter.h', 4172 'platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp', 4173 'platform/graphics/chromium/cc/CCLayerTreeHostImpl.h', 4174 'platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp', 4175 'platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.h', 4168 4176 'platform/graphics/chromium/cc/CCMainThread.cpp', 4169 4177 'platform/graphics/chromium/cc/CCMainThread.h', -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
r89700 r89837 51 51 #include "WebGLLayerChromium.h" 52 52 #include "cc/CCLayerImpl.h" 53 #include "cc/CCLayerTreeHostImpl.h" 54 #include "cc/CCMainThreadTask.h" 53 55 #if USE(SKIA) 54 56 #include "Extensions3D.h" … … 99 101 } 100 102 101 PassRefPtr<LayerRendererChromium> LayerRendererChromium::create(PassRefPtr<GraphicsContext3D> context, PassOwnPtr<LayerPainterChromium> contentPaint, bool accelerateDrawing) 102 { 103 PassRefPtr<LayerRendererChromium> LayerRendererChromium::create(CCLayerTreeHostClient* client, PassOwnPtr<LayerPainterChromium> contentPaint, bool accelerateDrawing) 104 { 105 RefPtr<GraphicsContext3D> context = client->createLayerTreeHostContext3D(); 103 106 if (!context) 104 107 return 0; 105 108 106 RefPtr<LayerRendererChromium> layerRenderer(adoptRef(new LayerRendererChromium(context, contentPaint, accelerateDrawing))); 109 RefPtr<LayerRendererChromium> layerRenderer(adoptRef(new LayerRendererChromium(client, context, contentPaint, accelerateDrawing))); 110 layerRenderer->init(); 107 111 if (!layerRenderer->hardwareCompositing()) 108 112 return 0; … … 111 115 } 112 116 113 LayerRendererChromium::LayerRendererChromium(PassRefPtr<GraphicsContext3D> context, 117 LayerRendererChromium::LayerRendererChromium(CCLayerTreeHostClient* client, 118 PassRefPtr<GraphicsContext3D> context, 114 119 PassOwnPtr<LayerPainterChromium> contentPaint, 115 120 bool accelerateDrawing) 116 : m_viewportScrollPosition(IntPoint(-1, -1)) 121 : CCLayerTreeHost(client) 122 , m_viewportScrollPosition(IntPoint(-1, -1)) 117 123 , m_rootLayer(0) 118 124 , m_accelerateDrawing(false) … … 224 230 m_rootLayerContentTiler->invalidateEntireLayer(); 225 231 } 226 } 227 228 void LayerRendererChromium::updateAndDrawLayers() 229 { 232 setNeedsCommitAndRedraw(); 233 } 234 235 void LayerRendererChromium::updateLayers() 236 { 237 CCLayerTreeHost::updateLayers(); 230 238 if (m_viewportVisibleRect.isEmpty()) 231 239 return; … … 252 260 } 253 261 254 LayerList renderSurfaceLayerList; 255 updateLayers(renderSurfaceLayerList); 256 262 m_computedRenderSurfaceLayerList = adoptPtr(new LayerList()); 263 updateLayers(*m_computedRenderSurfaceLayerList); 264 } 265 266 void LayerRendererChromium::drawLayers() 267 { 268 ASSERT(m_hardwareCompositing); 269 ASSERT(m_computedRenderSurfaceLayerList); 257 270 // Before drawLayers: 258 271 if (hardwareCompositing() && m_contextSupportsLatch) { … … 277 290 } 278 291 279 drawLayers( renderSurfaceLayerList);292 drawLayers(*m_computedRenderSurfaceLayerList); 280 293 281 294 m_textureManager->unprotectAllTextures(); … … 1266 1279 } 1267 1280 1281 class LayerRendererChromiumImpl : public CCLayerTreeHostImpl { 1282 public: 1283 static PassOwnPtr<LayerRendererChromiumImpl> create(CCLayerTreeHostImplClient* client, LayerRendererChromium* layerRenderer) 1284 { 1285 return adoptPtr(new LayerRendererChromiumImpl(client, layerRenderer)); 1286 } 1287 1288 virtual void drawLayersAndPresent() 1289 { 1290 CCCompletionEvent completion; 1291 bool contextLost; 1292 CCMainThread::postTask(createMainThreadTask(this, &LayerRendererChromiumImpl::drawLayersOnMainThread, AllowCrossThreadAccess(&completion), AllowCrossThreadAccess(&contextLost))); 1293 completion.wait(); 1294 1295 // FIXME: Send the "UpdateRect" message up to the RenderWidget [or moveplugin equivalents...] 1296 1297 // FIXME: handle context lost 1298 if (contextLost) 1299 FATAL("LayerRendererChromiumImpl does not handle context lost yet."); 1300 } 1301 1302 private: 1303 LayerRendererChromiumImpl(CCLayerTreeHostImplClient* client, LayerRendererChromium* layerRenderer) 1304 : CCLayerTreeHostImpl(client) 1305 , m_layerRenderer(layerRenderer) { } 1306 1307 void drawLayersOnMainThread(CCCompletionEvent* completion, bool* contextLost) 1308 { 1309 ASSERT(isMainThread()); 1310 1311 if (m_layerRenderer->rootLayer()) { 1312 m_layerRenderer->drawLayers(); 1313 m_layerRenderer->present(); 1314 1315 GraphicsContext3D* context = m_layerRenderer->context(); 1316 *contextLost = context->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR; 1317 } else 1318 *contextLost = false; 1319 completion->signal(); 1320 } 1321 1322 LayerRendererChromium* m_layerRenderer; 1323 }; 1324 1325 class LayerRendererChromiumImplProxy : public CCLayerTreeHostImplProxy { 1326 public: 1327 static PassOwnPtr<LayerRendererChromiumImplProxy> create(LayerRendererChromium* layerRenderer) 1328 { 1329 return adoptPtr(new LayerRendererChromiumImplProxy(layerRenderer)); 1330 } 1331 1332 virtual PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl() 1333 { 1334 return LayerRendererChromiumImpl::create(this, static_cast<LayerRendererChromium*>(host())); 1335 } 1336 1337 private: 1338 LayerRendererChromiumImplProxy(LayerRendererChromium* layerRenderer) 1339 : CCLayerTreeHostImplProxy(layerRenderer) { } 1340 }; 1341 1342 PassOwnPtr<CCLayerTreeHostImplProxy> LayerRendererChromium::createLayerTreeHostImplProxy() 1343 { 1344 OwnPtr<CCLayerTreeHostImplProxy> proxy = LayerRendererChromiumImplProxy::create(this); 1345 proxy->start(); 1346 return proxy.release(); 1347 } 1348 1268 1349 } // namespace WebCore 1269 1350 -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
r89700 r89837 45 45 #include "cc/CCHeadsUpDisplay.h" 46 46 #include "cc/CCLayerSorter.h" 47 #include "cc/CCLayerTreeHost.h" 47 48 #include "cc/CCPluginLayerImpl.h" 48 49 #include "cc/CCVideoLayerImpl.h" … … 51 52 #include <wtf/PassOwnPtr.h> 52 53 #include <wtf/PassRefPtr.h> 53 #include <wtf/RefCounted.h>54 54 #include <wtf/Vector.h> 55 55 … … 67 67 class CCHeadsUpDisplay; 68 68 class CCLayerImpl; 69 class CCLayerTreeHostCommitter; 70 class CCLayerTreeHostImpl; 69 71 class GeometryBinding; 70 72 class GraphicsContext3D; … … 72 74 73 75 // Class that handles drawing of composited render layers using GL. 74 class LayerRendererChromium : public RefCounted<LayerRendererChromium>{76 class LayerRendererChromium : public CCLayerTreeHost { 75 77 public: 76 static PassRefPtr<LayerRendererChromium> create( PassRefPtr<GraphicsContext3D>, PassOwnPtr<LayerPainterChromium> contentPaint, bool accelerateDrawing);78 static PassRefPtr<LayerRendererChromium> create(CCLayerTreeHostClient*, PassOwnPtr<LayerPainterChromium> contentPaint, bool accelerateDrawing); 77 79 78 80 ~LayerRendererChromium(); … … 89 91 90 92 // updates and draws the current layers onto the backbuffer 91 void updateAndDrawLayers(); 93 virtual void updateLayers(); 94 void drawLayers(); 92 95 93 96 // Set by WebViewImpl when animation callbacks are running. … … 157 160 static bool s_inPaintLayerContents; 158 161 #endif 162 protected: 163 virtual PassOwnPtr<CCLayerTreeHostImplProxy> createLayerTreeHostImplProxy(); 164 159 165 private: 160 166 typedef Vector<RefPtr<CCLayerImpl> > LayerList; 161 167 typedef HashMap<GraphicsContext3D*, int> ChildContextMap; 162 168 163 // FIXME: This needs to be moved to the CC ViewImpl when that class exists.169 // FIXME: This needs to be moved to the CCLayerTreeHostImpl when that class exists. 164 170 RefPtr<CCLayerImpl> m_rootCCLayerImpl; 165 171 166 LayerRendererChromium( PassRefPtr<GraphicsContext3D>, PassOwnPtr<LayerPainterChromium> contentPaint, bool accelerateDrawing);172 LayerRendererChromium(CCLayerTreeHostClient*, PassRefPtr<GraphicsContext3D>, PassOwnPtr<LayerPainterChromium> contentPaint, bool accelerateDrawing); 167 173 168 174 void updateLayers(LayerList& renderSurfaceLayerList); … … 210 216 bool m_hardwareCompositing; 211 217 bool m_accelerateDrawing; 218 219 OwnPtr<LayerList> m_computedRenderSurfaceLayerList; 212 220 213 221 RenderSurfaceChromium* m_currentRenderSurface; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp
r89700 r89837 248 248 } 249 249 250 void CCHeadsUpDisplay::setShowFPSCounter(bool show) 251 { 252 m_showFPSCounter = show; 253 m_layerRenderer->setNeedsRedraw(); 254 } 255 256 void CCHeadsUpDisplay::setShowPlatformLayerTree(bool show) 257 { 258 m_showPlatformLayerTree = show; 259 m_layerRenderer->setNeedsRedraw(); 260 } 261 250 262 } 251 263 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.h
r89700 r89837 50 50 ~CCHeadsUpDisplay(); 51 51 52 int currentFrameNumber() const { return m_currentFrameNumber; } 53 52 54 void onFrameBegin(double timestamp); 53 55 void onPresent(); 54 56 55 void setShowFPSCounter(bool enable) { m_showFPSCounter = enable; }57 void setShowFPSCounter(bool enable); 56 58 bool showFPSCounter() const { return m_showFPSCounter; } 57 59 58 void setShowPlatformLayerTree(bool enable) { m_showPlatformLayerTree = enable; }60 void setShowPlatformLayerTree(bool enable); 59 61 bool showPlatformLayerTree() const { return m_showPlatformLayerTree; } 60 62 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
r89836 r89837 25 25 #include "config.h" 26 26 27 #include " CCThread.h"27 #include "cc/CCLayerTreeHost.h" 28 28 29 #include " LayerRendererChromium.h"30 #include <wtf/CurrentTime.h>31 #include <wtf/PassOwnPtr.h>32 #include <wtf/ThreadingPrimitives.h> 29 #include "TraceEvent.h" 30 #include "cc/CCLayerTreeHostCommitter.h" 31 #include "cc/CCLayerTreeHostImpl.h" 32 33 33 34 34 namespace WebCore { 35 35 36 using namespace WTF; 37 38 CCThread::CCThread()36 CCLayerTreeHost::CCLayerTreeHost(CCLayerTreeHostClient* client) 37 : m_client(client) 38 , m_frameNumber(0) 39 39 { 40 MutexLocker lock(m_threadCreationMutex);41 m_threadID = createThread(CCThread::compositorThreadStart, this, "Chromium Compositor");42 40 } 43 41 44 CCThread::~CCThread()42 void CCLayerTreeHost::init() 45 43 { 46 m_queue.kill(); 47 48 // Stop thread. 49 void* exitCode; 50 waitForThreadCompletion(m_threadID, &exitCode); 51 m_threadID = 0; 44 #if USE(THREADED_COMPOSITING) 45 m_proxy = createLayerTreeHostImplProxy(); 46 ASSERT(m_proxy->isStarted()); 47 m_proxy->setNeedsCommitAndRedraw(); 48 #endif 52 49 } 53 50 54 void CCThread::postTask(PassOwnPtr<Task> task)51 CCLayerTreeHost::~CCLayerTreeHost() 55 52 { 56 m_queue.append(task); 53 TRACE_EVENT("CCLayerTreeHost::~CCLayerTreeHost", this, 0); 54 #if USE(THREADED_COMPOSITING) 55 m_proxy->stop(); 56 m_proxy.clear(); 57 #endif 57 58 } 58 59 59 void * CCThread::compositorThreadStart(void* userdata)60 void CCLayerTreeHost::beginCommit() 60 61 { 61 CCThread* ccThread = static_cast<CCThread*>(userdata);62 return ccThread->runLoop();63 62 } 64 63 65 void * CCThread::runLoop()64 void CCLayerTreeHost::commitComplete() 66 65 { 67 { 68 // Wait for CCThread::start() to complete to have m_threadID 69 // established before starting the main loop. 70 MutexLocker lock(m_threadCreationMutex); 71 } 66 m_frameNumber++; 67 } 72 68 73 while (OwnPtr<Task> task = m_queue.waitForMessage()) 74 task->performTask(); 69 void CCLayerTreeHost::animateAndLayout(double frameBeginTime) 70 { 71 m_client->animateAndLayout(frameBeginTime); 72 } 75 73 76 return 0; 74 PassOwnPtr<CCLayerTreeHostCommitter> CCLayerTreeHost::createLayerTreeHostCommitter() 75 { 76 return CCLayerTreeHostCommitter::create(); 77 } 78 79 void CCLayerTreeHost::setNeedsCommitAndRedraw() 80 { 81 #if USE(THREADED_COMPOSITING) 82 m_proxy->setNeedsCommitAndRedraw(); 83 #endif 84 } 85 86 void CCLayerTreeHost::setNeedsRedraw() 87 { 88 TRACE_EVENT("CCLayerTreeHost::setNeedsRedraw", this, 0); 89 #if USE(THREADED_COMPOSITING) 90 m_proxy->setNeedsRedraw(); 91 #endif 92 } 93 94 void CCLayerTreeHost::updateLayers() 95 { 96 m_client->updateLayers(); 77 97 } 78 98 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
r89836 r89837 23 23 */ 24 24 25 #include "config.h" 25 #ifndef CCLayerTreeHost_h 26 #define CCLayerTreeHost_h 26 27 27 #include "CCThread.h" 28 29 #include "LayerRendererChromium.h" 30 #include <wtf/CurrentTime.h> 28 #include "cc/CCLayerTreeHostCommitter.h" 29 #include "cc/CCLayerTreeHostImplProxy.h" 31 30 #include <wtf/PassOwnPtr.h> 32 #include <wtf/ThreadingPrimitives.h> 31 #include <wtf/PassRefPtr.h> 32 #include <wtf/RefCounted.h> 33 33 34 34 namespace WebCore { 35 35 36 using namespace WTF; 36 class CCLayerTreeHostImpl; 37 class CCLayerTreeHostImplClient; 38 class GraphicsContext3D; 37 39 38 CCThread::CCThread() 39 { 40 MutexLocker lock(m_threadCreationMutex); 41 m_threadID = createThread(CCThread::compositorThreadStart, this, "Chromium Compositor"); 40 class CCLayerTreeHostClient { 41 public: 42 virtual void animateAndLayout(double frameBeginTime) = 0; 43 virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() = 0; 44 virtual void updateLayers() = 0; 45 46 protected: 47 virtual ~CCLayerTreeHostClient() { } 48 }; 49 50 class CCLayerTreeHost : public RefCounted<CCLayerTreeHost> { 51 public: 52 explicit CCLayerTreeHost(CCLayerTreeHostClient*); 53 void init(); 54 virtual ~CCLayerTreeHost(); 55 56 virtual void animateAndLayout(double frameBeginTime); 57 virtual void beginCommit(); 58 virtual void commitComplete(); 59 virtual PassOwnPtr<CCLayerTreeHostCommitter> createLayerTreeHostCommitter(); 60 61 int frameNumber() const { return m_frameNumber; } 62 63 void setNeedsCommitAndRedraw(); 64 void setNeedsRedraw(); 65 66 virtual void updateLayers(); 67 68 protected: 69 virtual PassOwnPtr<CCLayerTreeHostImplProxy> createLayerTreeHostImplProxy() = 0; 70 71 private: 72 CCLayerTreeHostClient* m_client; 73 int m_frameNumber; 74 OwnPtr<CCLayerTreeHostImplProxy> m_proxy; 75 }; 76 42 77 } 43 78 44 CCThread::~CCThread() 45 { 46 m_queue.kill(); 47 48 // Stop thread. 49 void* exitCode; 50 waitForThreadCompletion(m_threadID, &exitCode); 51 m_threadID = 0; 52 } 53 54 void CCThread::postTask(PassOwnPtr<Task> task) 55 { 56 m_queue.append(task); 57 } 58 59 void* CCThread::compositorThreadStart(void* userdata) 60 { 61 CCThread* ccThread = static_cast<CCThread*>(userdata); 62 return ccThread->runLoop(); 63 } 64 65 void* CCThread::runLoop() 66 { 67 { 68 // Wait for CCThread::start() to complete to have m_threadID 69 // established before starting the main loop. 70 MutexLocker lock(m_threadCreationMutex); 71 } 72 73 while (OwnPtr<Task> task = m_queue.waitForMessage()) 74 task->performTask(); 75 76 return 0; 77 } 78 79 } 79 #endif -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommitter.cpp
r89836 r89837 25 25 #include "config.h" 26 26 27 #include " CCThread.h"27 #include "cc/CCLayerTreeHostCommitter.h" 28 28 29 #include "LayerRendererChromium.h" 30 #include <wtf/CurrentTime.h> 31 #include <wtf/PassOwnPtr.h> 32 #include <wtf/ThreadingPrimitives.h> 29 #include "cc/CCLayerTreeHost.h" 30 #include "cc/CCLayerTreeHostImpl.h" 33 31 34 32 namespace WebCore { 35 33 36 using namespace WTF; 37 38 CCThread::CCThread() 34 PassOwnPtr<CCLayerTreeHostCommitter> CCLayerTreeHostCommitter::create() 39 35 { 40 MutexLocker lock(m_threadCreationMutex); 41 m_threadID = createThread(CCThread::compositorThreadStart, this, "Chromium Compositor"); 36 return adoptPtr(new CCLayerTreeHostCommitter()); 42 37 } 43 38 44 CCThread::~CCThread()39 void CCLayerTreeHostCommitter::commit(CCLayerTreeHost* host, CCLayerTreeHostImpl* hostImpl) 45 40 { 46 m_queue.kill(); 47 48 // Stop thread. 49 void* exitCode; 50 waitForThreadCompletion(m_threadID, &exitCode); 51 m_threadID = 0; 52 } 53 54 void CCThread::postTask(PassOwnPtr<Task> task) 55 { 56 m_queue.append(task); 57 } 58 59 void* CCThread::compositorThreadStart(void* userdata) 60 { 61 CCThread* ccThread = static_cast<CCThread*>(userdata); 62 return ccThread->runLoop(); 63 } 64 65 void* CCThread::runLoop() 66 { 67 { 68 // Wait for CCThread::start() to complete to have m_threadID 69 // established before starting the main loop. 70 MutexLocker lock(m_threadCreationMutex); 71 } 72 73 while (OwnPtr<Task> task = m_queue.waitForMessage()) 74 task->performTask(); 75 76 return 0; 41 hostImpl->setSourceFrameNumber(host->frameNumber()); 77 42 } 78 43 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommitter.h
r89836 r89837 23 23 */ 24 24 25 #include "config.h" 25 #ifndef CCLayerTreeHostCommitter_h 26 #define CCLayerTreeHostCommitter_h 26 27 27 #include "CCThread.h" 28 29 #include "LayerRendererChromium.h" 30 #include <wtf/CurrentTime.h> 28 #include <wtf/Noncopyable.h> 31 29 #include <wtf/PassOwnPtr.h> 32 #include <wtf/ThreadingPrimitives.h>33 30 34 31 namespace WebCore { 35 32 36 using namespace WTF; 33 class CCLayerTreeHost; 34 class CCLayerTreeHostImpl; 37 35 38 CCThread::CCThread() 39 { 40 MutexLocker lock(m_threadCreationMutex); 41 m_threadID = createThread(CCThread::compositorThreadStart, this, "Chromium Compositor"); 36 // FIXME: merge in TreeSynchronizer code into here 37 class CCLayerTreeHostCommitter { 38 WTF_MAKE_NONCOPYABLE(CCLayerTreeHostCommitter); 39 public: 40 static PassOwnPtr<CCLayerTreeHostCommitter> create(); 41 virtual ~CCLayerTreeHostCommitter() { } 42 43 virtual void commit(CCLayerTreeHost*, CCLayerTreeHostImpl*); 44 45 protected: 46 CCLayerTreeHostCommitter() { } 47 }; 48 42 49 } 43 50 44 CCThread::~CCThread() 45 { 46 m_queue.kill(); 47 48 // Stop thread. 49 void* exitCode; 50 waitForThreadCompletion(m_threadID, &exitCode); 51 m_threadID = 0; 52 } 53 54 void CCThread::postTask(PassOwnPtr<Task> task) 55 { 56 m_queue.append(task); 57 } 58 59 void* CCThread::compositorThreadStart(void* userdata) 60 { 61 CCThread* ccThread = static_cast<CCThread*>(userdata); 62 return ccThread->runLoop(); 63 } 64 65 void* CCThread::runLoop() 66 { 67 { 68 // Wait for CCThread::start() to complete to have m_threadID 69 // established before starting the main loop. 70 MutexLocker lock(m_threadCreationMutex); 71 } 72 73 while (OwnPtr<Task> task = m_queue.waitForMessage()) 74 task->performTask(); 75 76 return 0; 77 } 78 79 } 51 #endif -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h
r89836 r89837 23 23 */ 24 24 25 #include "config.h" 25 #ifndef CCLayerTreeHostImpl_h 26 #define CCLayerTreeHostImpl_h 26 27 27 #include "CCThread.h" 28 29 #include "LayerRendererChromium.h" 30 #include <wtf/CurrentTime.h> 31 #include <wtf/PassOwnPtr.h> 32 #include <wtf/ThreadingPrimitives.h> 28 #include "cc/CCThread.h" 29 #include <wtf/RefPtr.h> 30 #include <wtf/ThreadSafeRefCounted.h> 33 31 34 32 namespace WebCore { 35 33 36 using namespace WTF; 34 // Provides scheduling infrastructure for a CCLayerTreeHostImpl 35 class CCLayerTreeHostImplClient { 36 public: 37 virtual void postDrawLayersTaskOnCCThread() = 0; 38 virtual void requestFrameAndCommitOnCCThread(double frameBeginTime) = 0; 37 39 38 CCThread::CCThread() 39 { 40 MutexLocker lock(m_threadCreationMutex); 41 m_threadID = createThread(CCThread::compositorThreadStart, this, "Chromium Compositor"); 42 } 40 protected: 41 virtual ~CCLayerTreeHostImplClient() { } 42 }; 43 43 44 CCThread::~CCThread() 45 { 46 m_queue.kill(); 44 // CCLayerTreeHostImpl owns the CCLayerImpl tree as well as associated rendering state 45 class CCLayerTreeHostImpl { 46 WTF_MAKE_NONCOPYABLE(CCLayerTreeHostImpl); 47 public: 48 explicit CCLayerTreeHostImpl(CCLayerTreeHostImplClient*); 49 virtual ~CCLayerTreeHostImpl(); 47 50 48 // Stop thread. 49 void* exitCode; 50 waitForThreadCompletion(m_threadID, &exitCode); 51 m_threadID = 0; 52 } 51 virtual void beginCommit(); 52 virtual void commitComplete(); 53 53 54 void CCThread::postTask(PassOwnPtr<Task> task) 55 { 56 m_queue.append(task); 57 } 54 void drawLayers(); 55 virtual void drawLayersAndPresent() = 0; 58 56 59 void* CCThread::compositorThreadStart(void* userdata) 60 { 61 CCThread* ccThread = static_cast<CCThread*>(userdata); 62 return ccThread->runLoop(); 63 } 57 int frameNumber() const { return m_frameNumber; } 64 58 65 void* CCThread::runLoop() 66 { 67 { 68 // Wait for CCThread::start() to complete to have m_threadID 69 // established before starting the main loop. 70 MutexLocker lock(m_threadCreationMutex); 71 } 59 void setNeedsRedraw(); 60 void setNeedsCommitAndRedraw(); 72 61 73 while (OwnPtr<Task> task = m_queue.waitForMessage())74 task->performTask();62 int sourceFrameNumber() const { return m_sourceFrameNumber; } 63 void setSourceFrameNumber(int frameNumber) { m_sourceFrameNumber = frameNumber; } 75 64 76 return 0; 77 } 65 protected: 66 int m_sourceFrameNumber; 67 int m_frameNumber; 78 68 79 } 69 private: 70 CCLayerTreeHostImplClient* m_client; 71 bool m_commitPending; 72 bool m_redrawPending; 73 }; 74 75 }; 76 77 #endif -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCMainThreadTask.h
r89700 r89837 25 25 #define CCMainThreadTask_h 26 26 27 #include "CCMainThread.h"28 27 #include "CrossThreadCopier.h" 29 28 #include "CrossThreadTask.h" 29 #include "cc/CCMainThread.h" 30 30 #include <wtf/PassOwnPtr.h> 31 31 #include <wtf/PassRefPtr.h> -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCThread.cpp
r89700 r89837 28 28 29 29 #include "LayerRendererChromium.h" 30 #include "TraceEvent.h" 30 31 #include <wtf/CurrentTime.h> 31 32 #include <wtf/PassOwnPtr.h> … … 65 66 void* CCThread::runLoop() 66 67 { 68 TRACE_EVENT("CCThread::runLoop", this, 0); 67 69 { 68 70 // Wait for CCThread::start() to complete to have m_threadID -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadTask.h
r89700 r89837 25 25 #define CCThreadTask_h 26 26 27 #include "CCThread.h"28 27 #include "CrossThreadCopier.h" 29 28 #include "CrossThreadTask.h" 29 #include "cc/CCThread.h" 30 30 #include <wtf/PassOwnPtr.h> 31 31 #include <wtf/PassRefPtr.h> -
trunk/Source/WebKit/chromium/ChangeLog
r89792 r89837 1 2011-05-17 Nat Duca <nduca@chromium.org> 2 3 Reviewed by James Robinson. 4 5 [chromium] Implement CCLayerTreeHost and CCLayerTreeHostImpl portions of threaded compositor 6 https://bugs.webkit.org/show_bug.cgi?id=58408 7 8 Redirect invalidates and scheduling into compositor when in 9 threaded compositing mode. Add stress tests for CCLayerTreeHost. 10 11 * WebKit.gypi: 12 * public/WebWidget.h: 13 * src/WebPopupMenuImpl.cpp: 14 (WebKit::WebPopupMenuImpl::animate): 15 * src/WebPopupMenuImpl.h: 16 * src/WebViewImpl.cpp: 17 (WebKit::WebViewImpl::animate): 18 (WebKit::WebViewImpl::paint): 19 (WebKit::WebViewImpl::animateAndLayout): 20 (WebKit::WebViewImpl::updateLayers): 21 (WebKit::WebViewImpl::composite): 22 (WebKit::WebViewImpl::setRootLayerNeedsDisplay): 23 (WebKit::WebViewImpl::setIsAcceleratedCompositingActive): 24 (WebKit::WebViewImpl::doComposite): 25 (WebKit::WebViewImpl::createLayerTreeHostContext3D): 26 (WebKit::WebViewImpl::reallocateRenderer): 27 (WebKit::WebViewImpl::updateLayerRendererSettings): 28 (WebKit::WebViewImpl::updateLayerRendererViewport): 29 * src/WebViewImpl.h: 30 * tests/CCLayerTreeHostTest.cpp: Added. 31 (WTF::CCLayerTreeHostTest::CCLayerTreeHostTest): 32 (WTF::CCLayerTreeHostTest::animateAndLayout): 33 (WTF::CCLayerTreeHostTest::beginCommitOnCCThread): 34 (WTF::CCLayerTreeHostTest::beginCommitOnMainThread): 35 (WTF::CCLayerTreeHostTest::commitOnCCThread): 36 (WTF::CCLayerTreeHostTest::commitCompleteOnCCThread): 37 (WTF::CCLayerTreeHostTest::commitCompleteOnMainThread): 38 (WTF::CCLayerTreeHostTest::drawLayersAndPresentOnCCThread): 39 (WTF::CCLayerTreeHostTest::updateLayers): 40 (WTF::CCLayerTreeHostTest::onBeginTest): 41 (WTF::CCLayerTreeHostTest::doEndTest): 42 (WTF::CCLayerTreeHostTest::onEndTest): 43 (WTF::CCLayerTreeHostTest::runTest): 44 (WTF::CCLayerTreeHostTest::testTimeout): 45 (WTF::MockLayerTreeHostClient::MockLayerTreeHostClient): 46 (WTF::MockLayerTreeHostClient::createLayerTreeHostContext3D): 47 (WTF::MockLayerTreeHostClient::animateAndLayout): 48 (WTF::MockLayerTreeHostClient::updateLayers): 49 (WTF::MockLayerTreeHostCommitter::create): 50 (WTF::MockLayerTreeHostCommitter::commit): 51 (WTF::MockLayerTreeHostCommitter::MockLayerTreeHostCommitter): 52 (WTF::MockLayerTreeHostImpl::create): 53 (WTF::MockLayerTreeHostImpl::beginCommit): 54 (WTF::MockLayerTreeHostImpl::commitComplete): 55 (WTF::MockLayerTreeHostImpl::drawLayersAndPresent): 56 (WTF::MockLayerTreeHostImpl::MockLayerTreeHostImpl): 57 (WTF::MockLayerTreeHostImplProxy::create): 58 (WTF::MockLayerTreeHostImplProxy::createLayerTreeHostImpl): 59 (WTF::MockLayerTreeHostImplProxy::MockLayerTreeHostImplProxy): 60 (WTF::MockLayerTreeHost::MockLayerTreeHost): 61 (WTF::MockLayerTreeHost::createLayerTreeHostImplProxy): 62 (WTF::MockLayerTreeHost::updateLayers): 63 (WTF::MockLayerTreeHost::createLayerTreeHostCommitter): 64 (WTF::MockLayerTreeHost::beginCommit): 65 (WTF::MockLayerTreeHost::commitComplete): 66 (WTF::CCLayerTreeHostTest::doBeginTest): 67 (WTF::CCLayerTreeHostTest::endTest): 68 (WTF::CCLayerTreeHostTestShortlived1::CCLayerTreeHostTestShortlived1): 69 (WTF::CCLayerTreeHostTestShortlived1::beginTest): 70 (WTF::CCLayerTreeHostTestShortlived1::afterTest): 71 (WTF::TEST_F): 72 (WTF::CCLayerTreeHostTestShortlived2::CCLayerTreeHostTestShortlived2): 73 (WTF::CCLayerTreeHostTestShortlived2::beginTest): 74 (WTF::CCLayerTreeHostTestShortlived2::afterTest): 75 (WTF::CCLayerTreeHostTestShortlived3::CCLayerTreeHostTestShortlived3): 76 (WTF::CCLayerTreeHostTestShortlived3::beginTest): 77 (WTF::CCLayerTreeHostTestShortlived3::afterTest): 78 (WTF::CCLayerTreeHostTestCommitingWithContinuousRedraw::CCLayerTreeHostTestCommitingWithContinuousRedraw): 79 (WTF::CCLayerTreeHostTestCommitingWithContinuousRedraw::beginTest): 80 (WTF::CCLayerTreeHostTestCommitingWithContinuousRedraw::commitCompleteOnCCThread): 81 (WTF::CCLayerTreeHostTestCommitingWithContinuousRedraw::drawLayersAndPresentOnCCThread): 82 (WTF::CCLayerTreeHostTestCommitingWithContinuousRedraw::afterTest): 83 (WTF::CCLayerTreeHostTestSetNeedsCommit1::CCLayerTreeHostTestSetNeedsCommit1): 84 (WTF::CCLayerTreeHostTestSetNeedsCommit1::beginTest): 85 (WTF::CCLayerTreeHostTestSetNeedsCommit1::drawLayersAndPresentOnCCThread): 86 (WTF::CCLayerTreeHostTestSetNeedsCommit1::commitOnCCThread): 87 (WTF::CCLayerTreeHostTestSetNeedsCommit1::afterTest): 88 (WTF::CCLayerTreeHostTestSetNeedsCommit2::CCLayerTreeHostTestSetNeedsCommit2): 89 (WTF::CCLayerTreeHostTestSetNeedsCommit2::beginTest): 90 (WTF::CCLayerTreeHostTestSetNeedsCommit2::drawLayersAndPresentOnCCThread): 91 (WTF::CCLayerTreeHostTestSetNeedsCommit2::commitOnCCThread): 92 (WTF::CCLayerTreeHostTestSetNeedsCommit2::afterTest): 93 (WTF::CCLayerTreeHostTestSetNeedsRedraw::CCLayerTreeHostTestSetNeedsRedraw): 94 (WTF::CCLayerTreeHostTestSetNeedsRedraw::beginTest): 95 (WTF::CCLayerTreeHostTestSetNeedsRedraw::drawLayersAndPresentOnCCThread): 96 (WTF::CCLayerTreeHostTestSetNeedsRedraw::commitOnCCThread): 97 (WTF::CCLayerTreeHostTestSetNeedsRedraw::afterTest): 98 * tests/CCThreadTest.cpp: 99 (WebCore::TEST): 100 1 101 2011-06-27 Yuta Kitamura <yutak@chromium.org> 2 102 -
trunk/Source/WebKit/chromium/WebKit.gypi
r89700 r89837 55 55 'tests/ArenaTestHelpers.h', 56 56 'tests/AssociatedURLLoaderTest.cpp', 57 'tests/ InnerGestureRecognizerTest.cpp',57 'tests/CCLayerTreeHostTest.cpp', 58 58 'tests/CCThreadTaskTest.cpp', 59 59 'tests/CCThreadTest.cpp', … … 61 61 'tests/IDBKeyPathTest.cpp', 62 62 'tests/IDBLevelDBCodingTest.cpp', 63 'tests/InnerGestureRecognizerTest.cpp', 63 64 'tests/KeyboardTest.cpp', 64 65 'tests/KURLTest.cpp', -
trunk/Source/WebKit/chromium/public/WebWidget.h
r89700 r89837 48 48 template <typename T> class WebVector; 49 49 50 // FIXME: remove this define once render_widget has been changed to issue threaded compositor calls 51 #define WEBWIDGET_HAS_ANIMATE_CHANGES 1 52 50 53 class WebWidget { 51 54 public: … … 69 72 virtual void willEndLiveResize() { } 70 73 71 // Called to update imperative animation state. This should be called before 72 // paint, although the client can rate-limit these calls. 73 virtual void animate() { } 74 // Called to update imperative animation state. This should be called before 75 // paint, although the client can rate-limit these calls. When 76 // frameBeginTime is 0.0, the WebWidget will determine the frame begin time 77 // itself. 78 virtual void animate(double frameBeginTime) { } 74 79 75 80 // Called to layout the WebWidget. This MUST be called before Paint, … … 77 82 virtual void layout() { } 78 83 79 // Called to paint the rectangular region within the WebWidget 84 // Called to paint the rectangular region within the WebWidget 80 85 // onto the specified canvas at (viewPort.x,viewPort.y). You MUST call 81 86 // Layout before calling this method. It is okay to call paint … … 86 91 virtual void paint(WebCanvas*, const WebRect& viewPort) { } 87 92 88 // Triggers compositing of the current layers onto the screen. 89 // The finish argument controls whether the compositor will wait for the 90 // GPU to finish rendering before returning. You MUST call Layout 91 // before calling this method, for the same reasons described in 92 // the paint method above. 93 virtual void composite(bool finish) { } 93 // In non-threaded compositing mode, triggers compositing of the current 94 // layers onto the screen. You MUST call Layout before calling this method, for the same 95 // reasons described in the paint method above 96 // 97 // In threaded compositing mode, indicates that the widget should update 98 // itself, for example due to window damage. The redraw will begin 99 // asynchronously and perform layout and animation internally. Do not call 100 // animate or layout in this case. 101 virtual void composite(bool finish) = 0; 94 102 95 103 // Called to inform the WebWidget of a change in theme. -
trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp
r89700 r89837 168 168 } 169 169 170 void WebPopupMenuImpl::animate( )170 void WebPopupMenuImpl::animate(double) 171 171 { 172 172 } -
trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.h
r89700 r89837 66 66 virtual void resize(const WebSize&); 67 67 virtual void willEndLiveResize(); 68 virtual void animate( );68 virtual void animate(double frameBeginTime); 69 69 virtual void layout(); 70 70 virtual void paint(WebCanvas* canvas, const WebRect& rect); -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r89700 r89837 149 149 150 150 using namespace WebCore; 151 using namespace std; 151 152 152 153 namespace { … … 1005 1006 #if USE(ACCELERATED_COMPOSITING) 1006 1007 if (m_layerRenderer && isAcceleratedCompositingActive()) { 1007 m_layerRenderer->resizeOnscreenContent(IntSize( std::max(1, m_size.width),1008 std::max(1, m_size.height)));1008 m_layerRenderer->resizeOnscreenContent(IntSize(max(1, m_size.width), 1009 max(1, m_size.height))); 1009 1010 } 1010 1011 #endif … … 1017 1018 } 1018 1019 1019 void WebViewImpl::animate() 1020 { 1020 void WebViewImpl::animate(double frameBeginTime) 1021 { 1022 #if ENABLE(REQUEST_ANIMATION_FRAME) 1021 1023 TRACE_EVENT("WebViewImpl::animate", this, 0); 1022 #if ENABLE(REQUEST_ANIMATION_FRAME) 1024 // FIXME: remove this zero-check once render_widget has been modified to 1025 // pass in a frameBeginTime. 1026 if (!frameBeginTime) 1027 frameBeginTime = currentTime(); 1023 1028 WebFrameImpl* webframe = mainFrameImpl(); 1024 1029 if (webframe) { … … 1027 1032 if (m_layerRenderer) 1028 1033 m_layerRenderer->setIsAnimating(true); 1029 view->serviceScriptedAnimations(convertSecondsToDOMTimeStamp( currentTime()));1034 view->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(frameBeginTime)); 1030 1035 if (m_layerRenderer) 1031 1036 m_layerRenderer->setIsAnimating(false); … … 1096 1101 if (isAcceleratedCompositingActive()) { 1097 1102 #if USE(ACCELERATED_COMPOSITING) 1103 #if USE(THREADED_COMPOSITING) 1104 // FIXME: do readback in threaded compositing mode rather than returning nothing 1105 return; 1106 #endif 1098 1107 doComposite(); 1099 1108 … … 1129 1138 } 1130 1139 1131 void WebViewImpl::composite(bool finish) 1132 { 1133 #if USE(ACCELERATED_COMPOSITING) 1140 void WebViewImpl::animateAndLayout(double frameBeginTime) 1141 { 1142 animate(frameBeginTime); 1143 layout(); 1144 } 1145 1146 void WebViewImpl::updateLayers() 1147 { 1134 1148 // Update the compositing requirements for all frame in the tree before doing any painting 1135 1149 // as the compositing requirements for a RenderLayer within a subframe might change. … … 1137 1151 frame->view()->updateCompositingLayers(); 1138 1152 page()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); 1139 1153 } 1154 1155 void WebViewImpl::composite(bool finish) 1156 { 1157 #if USE(ACCELERATED_COMPOSITING) 1158 #if USE(THREADED_COMPOSITING) 1159 m_layerRenderer->setNeedsRedraw(); 1160 #else 1140 1161 TRACE_EVENT("WebViewImpl::composite", this, 0); 1162 1141 1163 if (m_recreatingGraphicsContext) { 1142 1164 // reallocateRenderer will request a repaint whether or not it succeeded … … 1147 1169 } 1148 1170 doComposite(); 1149 1150 // Finish if requested.1151 if (finish)1152 m_layerRenderer->finish();1153 1171 1154 1172 // Put result onscreen. … … 1165 1183 setRootLayerNeedsDisplay(); 1166 1184 } 1185 #endif 1167 1186 #endif 1168 1187 } … … 1779 1798 return; 1780 1799 1781 m_zoomLevel = std::max(std::min(zoomLevel, m_maximumZoomLevel), m_minimumZoomLevel);1800 m_zoomLevel = max(min(zoomLevel, m_maximumZoomLevel), m_minimumZoomLevel); 1782 1801 m_client->zoomLevelChanged(); 1783 1802 } … … 1785 1804 double WebView::zoomLevelToZoomFactor(double zoomLevel) 1786 1805 { 1787 return std::pow(textSizeMultiplierRatio, zoomLevel);1806 return pow(textSizeMultiplierRatio, zoomLevel); 1788 1807 } 1789 1808 … … 2419 2438 void WebViewImpl::setRootLayerNeedsDisplay() 2420 2439 { 2440 #if USE(THREADED_COMPOSITING) 2441 if (m_layerRenderer) 2442 m_layerRenderer->setNeedsCommitAndRedraw(); 2443 #else 2421 2444 m_client->scheduleComposite(); 2445 #endif 2422 2446 } 2423 2447 … … 2491 2515 } else if (m_layerRenderer) { 2492 2516 m_isAcceleratedCompositingActive = true; 2493 m_layerRenderer->resizeOnscreenContent(WebCore::IntSize( std::max(1, m_size.width),2494 std::max(1, m_size.height)));2517 m_layerRenderer->resizeOnscreenContent(WebCore::IntSize(max(1, m_size.width), 2518 max(1, m_size.height))); 2495 2519 2496 2520 m_client->didActivateAcceleratedCompositing(true); 2497 2521 } else { 2498 2522 TRACE_EVENT("WebViewImpl::setIsAcceleratedCompositingActive(true)", this, 0); 2499 RefPtr<GraphicsContext3D> context = m_temporaryOnscreenGraphicsContext3D.release(); 2500 if (!context) { 2501 context = GraphicsContext3D::create(getCompositorContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow); 2502 if (context) 2503 context->reshape(std::max(1, m_size.width), std::max(1, m_size.height)); 2504 } 2505 2506 2507 m_layerRenderer = LayerRendererChromium::create(context.release(), WebViewImplContentPainter::create(this), m_page->settings()->acceleratedDrawingEnabled()); 2523 2524 m_layerRenderer = LayerRendererChromium::create(this, WebViewImplContentPainter::create(this), m_page->settings()->acceleratedDrawingEnabled()); 2508 2525 if (m_layerRenderer) { 2526 updateLayerRendererSettings(); 2509 2527 m_client->didActivateAcceleratedCompositing(true); 2510 2528 m_isAcceleratedCompositingActive = true; … … 2534 2552 return; 2535 2553 2536 m_layerRenderer->setCompositeOffscreen(settings()->compositeToTextureEnabled());2537 2538 CCHeadsUpDisplay* hud = m_layerRenderer->headsUpDisplay();2539 hud->setShowFPSCounter(settings()->showFPSCounter());2540 hud->setShowPlatformLayerTree(settings()->showPlatformLayerTree());2541 2542 2554 if (m_pageOverlay) 2543 2555 m_pageOverlay->update(); 2544 2556 2545 m_layerRenderer->updateAndDrawLayers(); 2557 m_layerRenderer->updateLayers(); 2558 m_layerRenderer->drawLayers(); 2559 } 2560 2561 PassRefPtr<GraphicsContext3D> WebViewImpl::createLayerTreeHostContext3D() 2562 { 2563 RefPtr<GraphicsContext3D> context = m_temporaryOnscreenGraphicsContext3D.release(); 2564 if (!context) { 2565 context = GraphicsContext3D::create(getCompositorContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow); 2566 if (context) 2567 context->reshape(max(1, m_size.width), max(1, m_size.height)); 2568 } 2569 return context; 2546 2570 } 2547 2571 2548 2572 void WebViewImpl::reallocateRenderer() 2549 2573 { 2550 RefPtr<GraphicsContext3D> newContext = m_temporaryOnscreenGraphicsContext3D.get();2551 WebGraphicsContext3D* webContext = GraphicsContext3DInternal::extractWebGraphicsContext3D(newContext.get());2552 if (!newContext || !webContext || webContext->isContextLost())2553 newContext = GraphicsContext3D::create(2554 getCompositorContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow);2555 2574 // GraphicsContext3D::create might fail and return 0, in that case LayerRendererChromium::create will also return 0. 2556 RefPtr<LayerRendererChromium> layerRenderer = LayerRendererChromium::create( newContext, WebViewImplContentPainter::create(this), m_page->settings()->acceleratedDrawingEnabled());2575 RefPtr<LayerRendererChromium> layerRenderer = LayerRendererChromium::create(this, WebViewImplContentPainter::create(this), m_page->settings()->acceleratedDrawingEnabled()); 2557 2576 2558 2577 // Reattach the root layer. Child layers will get reattached as a side effect of updateLayersRecursive. … … 2560 2579 m_layerRenderer->transferRootLayer(layerRenderer.get()); 2561 2580 m_layerRenderer = layerRenderer; 2581 updateLayerRendererSettings(); 2582 2562 2583 // FIXME: In MacOS newContext->reshape method needs to be called to 2563 2584 // allocate IOSurfaces. All calls to create a context followed by … … 2565 2586 // immediately obvious that GraphicsContext3D object will not 2566 2587 // function properly until its reshape method is called. 2567 newContext->reshape(std::max(1, m_size.width), std::max(1, m_size.height));2588 layerRenderer->context()->reshape(max(1, m_size.width), max(1, m_size.height)); 2568 2589 setRootPlatformLayer(m_layerRenderer->rootLayer()); 2590 2569 2591 // Forces ViewHostMsg_DidActivateAcceleratedCompositing to be sent so 2570 2592 // that the browser process can reacquire surfaces. … … 2577 2599 #endif 2578 2600 2601 void WebViewImpl::updateLayerRendererSettings() 2602 { 2603 ASSERT(m_layerRenderer); 2604 m_layerRenderer->setCompositeOffscreen(settings()->compositeToTextureEnabled()); 2605 2606 CCHeadsUpDisplay* hud = m_layerRenderer->headsUpDisplay(); 2607 hud->setShowFPSCounter(settings()->showFPSCounter()); 2608 hud->setShowPlatformLayerTree(settings()->showPlatformLayerTree()); 2609 } 2610 2579 2611 void WebViewImpl::updateLayerRendererViewport() 2580 2612 { 2581 ASSERT(m_layerRenderer);2582 2583 2613 if (!page()) 2584 2614 return; … … 2608 2638 m_temporaryOnscreenGraphicsContext3D = GraphicsContext3D::create(getCompositorContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow); 2609 2639 if (m_temporaryOnscreenGraphicsContext3D) 2610 m_temporaryOnscreenGraphicsContext3D->reshape( std::max(1, m_size.width), std::max(1, m_size.height));2640 m_temporaryOnscreenGraphicsContext3D->reshape(max(1, m_size.width), max(1, m_size.height)); 2611 2641 return GraphicsContext3DInternal::extractWebGraphicsContext3D(m_temporaryOnscreenGraphicsContext3D.get()); 2612 2642 } -
trunk/Source/WebKit/chromium/src/WebViewImpl.h
r89700 r89837 57 57 class DocumentLoader; 58 58 class Frame; 59 class GraphicsContext3D; 59 60 class HistoryItem; 60 61 class HitTestResult; … … 88 89 class WebTouchEvent; 89 90 90 class WebViewImpl : public WebView, public RefCounted<WebViewImpl> {91 class WebViewImpl : public WebView, public WebCore::CCLayerTreeHostClient, public RefCounted<WebViewImpl> { 91 92 public: 92 93 // WebWidget methods: … … 96 97 virtual void resize(const WebSize&); 97 98 virtual void willEndLiveResize(); 98 virtual void animate( );99 virtual void animate(double frameBeginTime); 99 100 virtual void layout(); 100 101 virtual void paint(WebCanvas*, const WebRect&); … … 203 204 virtual void performCustomContextMenuAction(unsigned action); 204 205 206 // CCLayerTreeHostClient 207 virtual void animateAndLayout(double frameBeginTime); 208 virtual PassRefPtr<WebCore::GraphicsContext3D> createLayerTreeHostContext3D(); 209 virtual void updateLayers(); 210 205 211 // WebViewImpl 206 212 … … 357 363 void scrollRootLayerRect(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& clipRect); 358 364 void invalidateRootLayerRect(const WebCore::IntRect&); 365 void doUpdateAndComposite(); 359 366 #endif 360 367 … … 424 431 void doPixelReadbackToCanvas(WebCanvas*, const WebCore::IntRect&); 425 432 void reallocateRenderer(); 433 void updateLayerRendererSettings(); 426 434 void updateLayerRendererViewport(); 427 435 #endif -
trunk/Source/WebKit/chromium/tests/CCThreadTest.cpp
r89700 r89837 54 54 PingPongUsingCondition target; 55 55 CCCompletionEvent completion; 56 thread->postTask(createCCThreadTask(&target, &PingPongUsingCondition::ping, 56 thread->postTask(createCCThreadTask(&target, &PingPongUsingCondition::ping, 57 57 AllowCrossThreadAccess(&completion))); 58 58 completion.wait(); -
trunk/Tools/ChangeLog
r89834 r89837 1 2011-05-17 Nat Duca <nduca@chromium.org> 2 3 Reviewed by James Robinson. 4 5 [chromium] Implement CCLayerTreeHost and CCLayerTreeHostImpl portions of threaded compositor 6 https://bugs.webkit.org/show_bug.cgi?id=58408 7 8 * DumpRenderTree/chromium/WebViewHost.cpp: 9 (WebViewHost::paintInvalidatedRegion): 10 1 11 2011-06-27 Eric Seidel <eric@webkit.org> 2 12 -
trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp
r89700 r89837 1487 1487 { 1488 1488 #if ENABLE(REQUEST_ANIMATION_FRAME) 1489 webWidget()->animate( );1489 webWidget()->animate(0.0); 1490 1490 #endif 1491 1491 webWidget()->layout();
Note: See TracChangeset
for help on using the changeset viewer.