Changeset 82959 in webkit
- Timestamp:
- Apr 5, 2011 11:01:12 AM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r82952 r82959 1 2011-04-04 Adam Roben <aroben@apple.com> 2 3 Add a way for LayerTreeHost to participate in DrawingAreaImpl's normal display mechanism 4 5 When LayerTreeHost participates in display, it renders each frame into a bitmap. 6 DrawingAreaImpl sends the bitmap to the UI process in an Update message, just like in 7 non-accelerated compositing mode. The UI process never knows that accelerated compositing is 8 going on. (When LayerTreeHost does not participate in display, as on Mac, it is responsible 9 for getting bits from the web process to the UI process.) 10 11 No LayerTreeHost uses this mechanism (yet). This patch should cause no change in behavior. 12 13 Fixes <http://webkit.org/b/57792> LayerTreeHost needs a way to render frames to a bitmap 14 15 Reviewed by Anders Carlsson. 16 17 * WebProcess/WebPage/DrawingAreaImpl.cpp: 18 (WebKit::DrawingAreaImpl::forceRepaint): If the layer tree host participates in display, 19 perform a display (like in the non-accelerated case). 20 (WebKit::DrawingAreaImpl::layerHostDidFlushLayers): Don't send an 21 EnterAcceleratedCompositing message to the UI process if the layer tree host participates in 22 display. In that case, the UI process doesn't even need to know we're using accelerated 23 compositing in the web process. 24 (WebKit::DrawingAreaImpl::sendDidUpdateBackingStoreState): Go through the normal display 25 mechanism if we have a layer tree host that participates in display. 26 (WebKit::DrawingAreaImpl::didUpdate): Don't ignore DidUpdate messages when we have a layer 27 tree host that participates in display. 28 (WebKit::DrawingAreaImpl::enterAcceleratedCompositingMode): If the new layer tree host 29 participates in display, let the display timer continue to run and continue to expect 30 DidUpdate messages so that we don't interrupt the normal display mechanism. We still clear 31 out m_dirtyRegion, m_scrollRect, and m_scrollOffset, though, because the layer tree host is 32 still responsible for keeping track of those things even when it participates in display. 33 (WebKit::DrawingAreaImpl::exitAcceleratedCompositingMode): If the outgoing layer tree host 34 was participating in display, just send another Update message instead of an 35 ExitAcceleratedCompositing message, since the UI process never even knew we were using 36 accelerated compositing. 37 (WebKit::DrawingAreaImpl::displayTimerFired): If we have a layer tree host that's 38 participating in display, ask it when it next needs to display when scheduling our timer. 39 40 (WebKit::DrawingAreaImpl::scheduleDisplay): 41 (WebKit::DrawingAreaImpl::display): 42 If we have a layer tree host that's participating in display, it will keep track of its own 43 dirty region, so ask it if it needs display rather than checking our own dirty region. 44 45 (WebKit::DrawingAreaImpl::display): If we have a layer tree host that's participating in 46 display, don't bail out. Instead, tell it to display rather than asking the page to paint. 47 Moved the setting of updateInfo.viewSize earlier so that it will be set even when the layer 48 tree host is displaying. Other changes are just due to indentation. 49 50 * WebProcess/WebPage/LayerTreeHost.h: 51 (WebKit::LayerTreeHost::participatesInDisplay): 52 (WebKit::LayerTreeHost::needsDisplay): 53 (WebKit::LayerTreeHost::timeUntilNextDisplay): 54 (WebKit::LayerTreeHost::display): 55 Stubbed out these functions. Derived classes can override them to participate in display. 56 1 57 2011-04-04 MORITA Hajime <morrita@google.com> 2 58 -
trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
r82543 r82959 43 43 44 44 using namespace WebCore; 45 using namespace std; 45 46 46 47 namespace WebKit { … … 160 161 if (m_layerTreeHost) { 161 162 m_layerTreeHost->forceRepaint(); 162 return; 163 if (!m_layerTreeHost->participatesInDisplay()) 164 return; 163 165 } 164 166 … … 202 204 } 203 205 204 if (!m_layerTreeHost) 205 return; 206 if (!m_layerTreeHost || m_layerTreeHost->participatesInDisplay()) { 207 // When the layer tree host participates in display, we never tell the UI process about 208 // accelerated compositing. From the UI process's point of view, we're still just sending 209 // it a series of bitmaps in Update messages. 210 return; 211 } 206 212 207 213 #if USE(ACCELERATED_COMPOSITING) … … 302 308 UpdateInfo updateInfo; 303 309 304 if (!m_isPaintingSuspended && !m_layerTreeHost)310 if (!m_isPaintingSuspended && (!m_layerTreeHost || m_layerTreeHost->participatesInDisplay())) 305 311 display(updateInfo); 306 312 … … 308 314 LayerTreeContext layerTreeContext; 309 315 310 if (m_isPaintingSuspended || m_layerTreeHost ) {316 if (m_isPaintingSuspended || m_layerTreeHost && !m_layerTreeHost->participatesInDisplay()) { 311 317 updateInfo.viewSize = m_webPage->size(); 312 318 … … 331 337 // We might get didUpdate messages from the UI process even after we've 332 338 // entered accelerated compositing mode. Ignore them. 333 if (m_layerTreeHost )339 if (m_layerTreeHost && !m_layerTreeHost->participatesInDisplay()) 334 340 return; 335 341 … … 374 380 m_scrollRect = IntRect(); 375 381 m_scrollOffset = IntSize(); 376 m_displayTimer.stop(); 377 m_isWaitingForDidUpdate = false; 382 383 if (!m_layerTreeHost->participatesInDisplay()) { 384 m_displayTimer.stop(); 385 m_isWaitingForDidUpdate = false; 386 } 378 387 } 379 388 … … 386 395 387 396 ASSERT(m_layerTreeHost); 397 398 bool wasParticipatingInDisplay = m_layerTreeHost->participatesInDisplay(); 388 399 389 400 m_layerTreeHost->invalidate(); … … 406 417 407 418 #if USE(ACCELERATED_COMPOSITING) 408 // Send along a complete update of the page so we can paint the contents right after we exit the 409 // accelerated compositing mode, eliminiating flicker. 410 m_webPage->send(Messages::DrawingAreaProxy::ExitAcceleratedCompositingMode(m_backingStoreStateID, updateInfo)); 419 if (wasParticipatingInDisplay) { 420 // When the layer tree host participates in display, we never tell the UI process about 421 // accelerated compositing. From the UI process's point of view, we're still just sending 422 // it a series of bitmaps in Update messages. 423 m_webPage->send(Messages::DrawingAreaProxy::Update(m_backingStoreStateID, updateInfo)); 424 } else { 425 // Send along a complete update of the page so we can paint the contents right after we exit the 426 // accelerated compositing mode, eliminiating flicker. 427 m_webPage->send(Messages::DrawingAreaProxy::ExitAcceleratedCompositingMode(m_backingStoreStateID, updateInfo)); 428 } 411 429 #endif 412 430 } … … 422 440 void DrawingAreaImpl::scheduleDisplay() 423 441 { 442 ASSERT(!m_layerTreeHost || m_layerTreeHost->participatesInDisplay()); 443 424 444 if (m_isWaitingForDidUpdate) 425 445 return; … … 428 448 return; 429 449 430 if (m_dirtyRegion.isEmpty()) 431 return; 450 if (m_layerTreeHost) { 451 if (!m_layerTreeHost->needsDisplay()) 452 return; 453 } else if (m_dirtyRegion.isEmpty()) 454 return; 432 455 433 456 if (m_displayTimer.isActive()) … … 442 465 443 466 double timeSinceLastDisplay = currentTime() - m_lastDisplayTime; 444 double timeUntilNextDisplay = minimumFrameInterval - timeSinceLastDisplay; 467 double timeUntilLayerTreeHostNeedsDisplay = m_layerTreeHost && m_layerTreeHost->participatesInDisplay() ? m_layerTreeHost->timeUntilNextDisplay() : 0; 468 double timeUntilNextDisplay = max(minimumFrameInterval - timeSinceLastDisplay, timeUntilLayerTreeHostNeedsDisplay); 445 469 446 470 if (timeUntilNextDisplay > 0) { … … 454 478 void DrawingAreaImpl::display() 455 479 { 456 ASSERT(!m_layerTreeHost );480 ASSERT(!m_layerTreeHost || m_layerTreeHost->participatesInDisplay()); 457 481 ASSERT(!m_isWaitingForDidUpdate); 458 482 ASSERT(!m_inUpdateBackingStoreState); … … 461 485 return; 462 486 463 if (m_dirtyRegion.isEmpty()) 487 if (m_layerTreeHost) { 488 if (!m_layerTreeHost->needsDisplay()) 489 return; 490 } else if (m_dirtyRegion.isEmpty()) 464 491 return; 465 492 … … 472 499 display(updateInfo); 473 500 474 if (m_layerTreeHost ) {501 if (m_layerTreeHost && !m_layerTreeHost->participatesInDisplay()) { 475 502 // The call to update caused layout which turned on accelerated compositing. 476 503 // Don't send an Update message in this case. … … 506 533 { 507 534 ASSERT(!m_isPaintingSuspended); 508 ASSERT(!m_layerTreeHost );535 ASSERT(!m_layerTreeHost || m_layerTreeHost->participatesInDisplay()); 509 536 ASSERT(!m_webPage->size().isEmpty()); 510 537 … … 518 545 m_webPage->layoutIfNeeded(); 519 546 520 // The layout may have put the page into accelerated compositing mode, in which case the 521 // LayerTreeHost is now in charge of displaying. 547 // The layout may have put the page into accelerated compositing mode. If the LayerTreeHost is 548 // in charge of displaying, we have nothing more to do. 549 if (m_layerTreeHost && !m_layerTreeHost->participatesInDisplay()) 550 return; 551 552 updateInfo.viewSize = m_webPage->size(); 553 522 554 if (m_layerTreeHost) 523 return;524 525 IntRect bounds = m_dirtyRegion.bounds();526 ASSERT(m_webPage->bounds().contains(bounds));527 528 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bounds.size(), ShareableBitmap::SupportsAlpha);529 if (!bitmap->createHandle(updateInfo.bitmapHandle))530 return;531 532 Vector<IntRect> rects = m_dirtyRegion.rects();533 534 if (shouldPaintBoundsRect(bounds, rects)) {535 rects.clear();536 rects.append(bounds);537 }538 539 updateInfo.scrollRect = m_scrollRect;540 updateInfo.scrollOffset = m_scrollOffset;541 542 m_dirtyRegion = Region();543 m_scrollRect = IntRect();544 m_scrollOffset = IntSize();545 546 OwnPtr<GraphicsContext> graphicsContext = bitmap->createGraphicsContext();547 548 updateInfo.viewSize = m_webPage->size();549 updateInfo.updateRectBounds = bounds; 550 551 graphicsContext->translate(-bounds.x(), -bounds.y()); 552 553 for (size_t i = 0; i < rects.size(); ++i) {554 m_webPage->drawRect(*graphicsContext, rects[i]);555 if (m_webPage->hasPageOverlay())556 m_webPage->drawPageOverlay(*graphicsContext,rects[i]);557 updateInfo.updateRects.append(rects[i]);555 m_layerTreeHost->display(updateInfo); 556 else { 557 IntRect bounds = m_dirtyRegion.bounds(); 558 ASSERT(m_webPage->bounds().contains(bounds)); 559 560 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bounds.size(), ShareableBitmap::SupportsAlpha); 561 if (!bitmap->createHandle(updateInfo.bitmapHandle)) 562 return; 563 564 Vector<IntRect> rects = m_dirtyRegion.rects(); 565 566 if (shouldPaintBoundsRect(bounds, rects)) { 567 rects.clear(); 568 rects.append(bounds); 569 } 570 571 updateInfo.scrollRect = m_scrollRect; 572 updateInfo.scrollOffset = m_scrollOffset; 573 574 m_dirtyRegion = Region(); 575 m_scrollRect = IntRect(); 576 m_scrollOffset = IntSize(); 577 578 OwnPtr<GraphicsContext> graphicsContext = bitmap->createGraphicsContext(); 579 580 updateInfo.updateRectBounds = bounds; 581 582 graphicsContext->translate(-bounds.x(), -bounds.y()); 583 584 for (size_t i = 0; i < rects.size(); ++i) { 585 m_webPage->drawRect(*graphicsContext, rects[i]); 586 if (m_webPage->hasPageOverlay()) 587 m_webPage->drawPageOverlay(*graphicsContext, rects[i]); 588 updateInfo.updateRects.append(rects[i]); 589 } 558 590 } 559 591 -
trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
r79593 r82959 39 39 40 40 class LayerTreeContext; 41 class UpdateInfo; 41 42 class WebPage; 42 43 … … 61 62 virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&) = 0; 62 63 64 // If a derived class overrides this function to return true, the derived class must also 65 // override the functions beneath it. 66 virtual bool participatesInDisplay() { return false; } 67 virtual bool needsDisplay() { ASSERT_NOT_REACHED(); return false; } 68 virtual double timeUntilNextDisplay() { ASSERT_NOT_REACHED(); return 0; } 69 virtual void display(UpdateInfo&) { ASSERT_NOT_REACHED(); } 70 63 71 protected: 64 72 explicit LayerTreeHost(WebPage*);
Note: See TracChangeset
for help on using the changeset viewer.