Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

Issue 10690121: Merge 121076 - [chromium] LayerRendererChromium is not getting visibility messages in single thread… (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1180/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 return nullptr; 65 return nullptr;
66 return layerTreeHost.release(); 66 return layerTreeHost.release();
67 } 67 }
68 68
69 CCLayerTreeHost::CCLayerTreeHost(CCLayerTreeHostClient* client, const CCLayerTre eSettings& settings) 69 CCLayerTreeHost::CCLayerTreeHost(CCLayerTreeHostClient* client, const CCLayerTre eSettings& settings)
70 : m_compositorIdentifier(-1) 70 : m_compositorIdentifier(-1)
71 , m_animating(false) 71 , m_animating(false)
72 , m_needsAnimateLayers(false) 72 , m_needsAnimateLayers(false)
73 , m_client(client) 73 , m_client(client)
74 , m_frameNumber(0) 74 , m_frameNumber(0)
75 , m_frameIsForDisplay(false)
76 , m_layerRendererInitialized(false) 75 , m_layerRendererInitialized(false)
77 , m_contextLost(false) 76 , m_contextLost(false)
78 , m_numTimesRecreateShouldFail(0) 77 , m_numTimesRecreateShouldFail(0)
79 , m_numFailedRecreateAttempts(0) 78 , m_numFailedRecreateAttempts(0)
80 , m_settings(settings) 79 , m_settings(settings)
81 , m_deviceScaleFactor(1) 80 , m_deviceScaleFactor(1)
82 , m_visible(true) 81 , m_visible(true)
83 , m_memoryAllocationBytes(0)
84 , m_memoryAllocationIsForDisplay(false)
85 , m_pageScaleFactor(1) 82 , m_pageScaleFactor(1)
86 , m_minPageScaleFactor(1) 83 , m_minPageScaleFactor(1)
87 , m_maxPageScaleFactor(1) 84 , m_maxPageScaleFactor(1)
88 , m_triggerIdlePaints(true) 85 , m_triggerIdlePaints(true)
89 , m_backgroundColor(Color::white) 86 , m_backgroundColor(Color::white)
90 , m_hasTransparentBackground(false) 87 , m_hasTransparentBackground(false)
91 , m_partialTextureUpdateRequests(0) 88 , m_partialTextureUpdateRequests(0)
92 { 89 {
93 ASSERT(CCProxy::isMainThread()); 90 ASSERT(CCProxy::isMainThread());
94 numLayerTreeInstances++; 91 numLayerTreeInstances++;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 141 }
145 142
146 // Update m_settings based on capabilities that we got back from the rendere r. 143 // Update m_settings based on capabilities that we got back from the rendere r.
147 m_settings.acceleratePainting = m_proxy->layerRendererCapabilities().usingAc celeratedPainting; 144 m_settings.acceleratePainting = m_proxy->layerRendererCapabilities().usingAc celeratedPainting;
148 145
149 // Update m_settings based on partial update capability. 146 // Update m_settings based on partial update capability.
150 m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdate s, m_proxy->maxPartialTextureUpdates()); 147 m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdate s, m_proxy->maxPartialTextureUpdates());
151 148
152 m_contentsTextureManager = TextureManager::create(0, 0, m_proxy->layerRender erCapabilities().maxTextureSize); 149 m_contentsTextureManager = TextureManager::create(0, 0, m_proxy->layerRender erCapabilities().maxTextureSize);
153 150
154 // FIXME: This is the same as setContentsMemoryAllocationLimitBytes, but
155 // we're in the middle of a commit here and don't want to force another.
156 m_memoryAllocationBytes = TextureManager::highLimitBytes(deviceViewportSize( ));
157 m_memoryAllocationIsForDisplay = true;
158
159 m_layerRendererInitialized = true; 151 m_layerRendererInitialized = true;
160 152
161 m_settings.defaultTileSize = IntSize(min(m_settings.defaultTileSize.width(), m_proxy->layerRendererCapabilities().maxTextureSize), 153 m_settings.defaultTileSize = IntSize(min(m_settings.defaultTileSize.width(), m_proxy->layerRendererCapabilities().maxTextureSize),
162 min(m_settings.defaultTileSize.height() , m_proxy->layerRendererCapabilities().maxTextureSize)); 154 min(m_settings.defaultTileSize.height() , m_proxy->layerRendererCapabilities().maxTextureSize));
163 m_settings.maxUntiledLayerSize = IntSize(min(m_settings.maxUntiledLayerSize. width(), m_proxy->layerRendererCapabilities().maxTextureSize), 155 m_settings.maxUntiledLayerSize = IntSize(min(m_settings.maxUntiledLayerSize. width(), m_proxy->layerRendererCapabilities().maxTextureSize),
164 min(m_settings.maxUntiledLayerSize. height(), m_proxy->layerRendererCapabilities().maxTextureSize)); 156 min(m_settings.maxUntiledLayerSize. height(), m_proxy->layerRendererCapabilities().maxTextureSize));
165 } 157 }
166 158
167 CCLayerTreeHost::RecreateResult CCLayerTreeHost::recreateContext() 159 CCLayerTreeHost::RecreateResult CCLayerTreeHost::recreateContext()
168 { 160 {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // to visit their controllers. 241 // to visit their controllers.
250 if (rootLayer() && m_needsAnimateLayers) 242 if (rootLayer() && m_needsAnimateLayers)
251 hostImpl->setNeedsAnimateLayers(); 243 hostImpl->setNeedsAnimateLayers();
252 244
253 hostImpl->setSourceFrameNumber(frameNumber()); 245 hostImpl->setSourceFrameNumber(frameNumber());
254 hostImpl->setViewportSize(viewportSize()); 246 hostImpl->setViewportSize(viewportSize());
255 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); 247 hostImpl->setDeviceScaleFactor(deviceScaleFactor());
256 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto r, m_maxPageScaleFactor); 248 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto r, m_maxPageScaleFactor);
257 hostImpl->setBackgroundColor(m_backgroundColor); 249 hostImpl->setBackgroundColor(m_backgroundColor);
258 hostImpl->setHasTransparentBackground(m_hasTransparentBackground); 250 hostImpl->setHasTransparentBackground(m_hasTransparentBackground);
259 hostImpl->setVisible(m_visible);
260 hostImpl->setSourceFrameCanBeDrawn(m_frameIsForDisplay);
261 251
262 m_frameNumber++; 252 m_frameNumber++;
263 } 253 }
264 254
265 void CCLayerTreeHost::commitComplete() 255 void CCLayerTreeHost::commitComplete()
266 { 256 {
267 m_deleteTextureAfterCommitList.clear(); 257 m_deleteTextureAfterCommitList.clear();
268 m_contentsTextureManager->unprotectAllTextures(); 258 m_contentsTextureManager->unprotectAllTextures();
269 m_client->didCommit(); 259 m_client->didCommit();
270 } 260 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 { 311 {
322 ASSERT(CCProxy::hasImplThread()); 312 ASSERT(CCProxy::hasImplThread());
323 m_proxy->setNeedsAnimate(); 313 m_proxy->setNeedsAnimate();
324 } 314 }
325 315
326 void CCLayerTreeHost::setNeedsCommit() 316 void CCLayerTreeHost::setNeedsCommit()
327 { 317 {
328 m_proxy->setNeedsCommit(); 318 m_proxy->setNeedsCommit();
329 } 319 }
330 320
331 void CCLayerTreeHost::setNeedsForcedCommit()
332 {
333 m_proxy->setNeedsForcedCommit();
334 }
335
336 void CCLayerTreeHost::setNeedsRedraw() 321 void CCLayerTreeHost::setNeedsRedraw()
337 { 322 {
338 m_proxy->setNeedsRedraw(); 323 m_proxy->setNeedsRedraw();
339 if (!CCThreadProxy::implThread()) 324 if (!CCThreadProxy::implThread())
340 m_client->scheduleComposite(); 325 m_client->scheduleComposite();
341 } 326 }
342 327
343 bool CCLayerTreeHost::commitRequested() const 328 bool CCLayerTreeHost::commitRequested() const
344 { 329 {
345 return m_proxy->commitRequested(); 330 return m_proxy->commitRequested();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 m_pageScaleFactor = pageScaleFactor; 376 m_pageScaleFactor = pageScaleFactor;
392 m_minPageScaleFactor = minPageScaleFactor; 377 m_minPageScaleFactor = minPageScaleFactor;
393 m_maxPageScaleFactor = maxPageScaleFactor; 378 m_maxPageScaleFactor = maxPageScaleFactor;
394 setNeedsCommit(); 379 setNeedsCommit();
395 } 380 }
396 381
397 void CCLayerTreeHost::setVisible(bool visible) 382 void CCLayerTreeHost::setVisible(bool visible)
398 { 383 {
399 if (m_visible == visible) 384 if (m_visible == visible)
400 return; 385 return;
401
402 m_visible = visible; 386 m_visible = visible;
403 387 m_proxy->setVisible(visible);
404 // FIXME: Remove this stuff, it is here just for the m20 merge.
405 if (!m_visible && m_layerRendererInitialized) {
406 if (m_proxy->layerRendererCapabilities().contextHasCachedFrontBuffer)
407 setContentsMemoryAllocationLimitBytes(0);
408 else
409 setContentsMemoryAllocationLimitBytes(m_contentsTextureManager->pref erredMemoryLimitBytes());
410 }
411
412 setNeedsForcedCommit();
413 } 388 }
414 389
415 void CCLayerTreeHost::setContentsMemoryAllocationLimitBytes(size_t bytes) 390 void CCLayerTreeHost::evictAllContentTextures()
416 { 391 {
417 ASSERT(CCProxy::isMainThread()); 392 ASSERT(CCProxy::isMainThread());
418 if (m_memoryAllocationBytes == bytes) 393 ASSERT(m_contentsTextureManager.get());
419 return; 394 m_contentsTextureManager->evictAndRemoveAllDeletedTextures();
420
421 m_memoryAllocationBytes = bytes;
422 m_memoryAllocationIsForDisplay = bytes;
423
424 // When not visible, force a commit so that we change our memory allocation
425 // and evict/delete any textures if we are being requested to.
426 if (!m_visible)
427 setNeedsForcedCommit();
428 else
429 setNeedsCommit();
430 } 395 }
431 396
432 void CCLayerTreeHost::startPageScaleAnimation(const IntSize& targetPosition, boo l useAnchor, float scale, double durationSec) 397 void CCLayerTreeHost::startPageScaleAnimation(const IntSize& targetPosition, boo l useAnchor, float scale, double durationSec)
433 { 398 {
434 m_proxy->startPageScaleAnimation(targetPosition, useAnchor, scale, durationS ec); 399 m_proxy->startPageScaleAnimation(targetPosition, useAnchor, scale, durationS ec);
435 } 400 }
436 401
437 void CCLayerTreeHost::loseContext(int numTimes) 402 void CCLayerTreeHost::loseContext(int numTimes)
438 { 403 {
439 TRACE_EVENT1("cc", "CCLayerTreeHost::loseCompositorContext", "numTimes", num Times); 404 TRACE_EVENT1("cc", "CCLayerTreeHost::loseCompositorContext", "numTimes", num Times);
(...skipping 26 matching lines...) Expand all
466 return false; 431 return false;
467 } 432 }
468 if (m_contextLost) { 433 if (m_contextLost) {
469 if (recreateContext() != RecreateSucceeded) 434 if (recreateContext() != RecreateSucceeded)
470 return false; 435 return false;
471 } 436 }
472 return true; 437 return true;
473 } 438 }
474 439
475 440
476 void CCLayerTreeHost::updateLayers(CCTextureUpdater& updater) 441 void CCLayerTreeHost::updateLayers(CCTextureUpdater& updater, size_t contentsMem oryLimitBytes)
477 { 442 {
478 ASSERT(m_layerRendererInitialized); 443 ASSERT(m_layerRendererInitialized);
479 // The visible state and memory allocation are set independently and in 444 ASSERT(contentsMemoryLimitBytes);
480 // arbitrary order, so do not change the memory allocation used for the
481 // current commit until both values match intentions.
482 // FIXME: These two states should be combined into a single action so we
483 // need a single commit to change visible state, and this can be removed.
484 bool memoryAllocationStateMatchesVisibility = m_visible == m_memoryAllocatio nIsForDisplay;
485 if (memoryAllocationStateMatchesVisibility) {
486 m_contentsTextureManager->setMemoryAllocationLimitBytes(m_memoryAllocati onBytes);
487 m_frameIsForDisplay = m_memoryAllocationIsForDisplay;
488 }
489 445
490 if (!rootLayer()) 446 if (!rootLayer())
491 return; 447 return;
492 448
493 if (viewportSize().isEmpty()) 449 if (viewportSize().isEmpty())
494 return; 450 return;
495 451
452 m_contentsTextureManager->setMemoryAllocationLimitBytes(contentsMemoryLimitB ytes);
453
496 updateLayers(rootLayer(), updater); 454 updateLayers(rootLayer(), updater);
497 } 455 }
498 456
499 void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdater& u pdater) 457 void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdater& u pdater)
500 { 458 {
501 TRACE_EVENT("CCLayerTreeHost::updateLayers", this, 0); 459 TRACE_EVENT("CCLayerTreeHost::updateLayers", this, 0);
502 460
503 if (!rootLayer->renderSurface()) 461 if (!rootLayer->renderSurface())
504 rootLayer->createRenderSurface(); 462 rootLayer->createRenderSurface();
505 rootLayer->renderSurface()->setContentRect(IntRect(IntPoint(0, 0), deviceVie wportSize())); 463 rootLayer->renderSurface()->setContentRect(IntRect(IntPoint(0, 0), deviceVie wportSize()));
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 else 716 else
759 layer->notifyAnimationFinished(wallClockTime); 717 layer->notifyAnimationFinished(wallClockTime);
760 } 718 }
761 } 719 }
762 720
763 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex) 721 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex)
764 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); 722 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime);
765 } 723 }
766 724
767 } // namespace WebCore 725 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698