2 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
27 #include "DrawingAreaImpl.h"
29 #include "DrawingAreaProxyMessages.h"
30 #include "LayerTreeContext.h"
31 #include "ShareableBitmap.h"
32 #include "UpdateInfo.h"
34 #include "WebPageCreationParameters.h"
35 #include "WebProcess.h"
36 #include <WebCore/GraphicsContext.h>
37 #include <WebCore/Page.h>
38 #include <WebCore/Settings.h>
40 using namespace WebCore;
45 PassOwnPtr<DrawingAreaImpl> DrawingAreaImpl::create(WebPage* webPage, const WebPageCreationParameters& parameters)
47 return adoptPtr(new DrawingAreaImpl(webPage, parameters));
50 DrawingAreaImpl::~DrawingAreaImpl()
53 m_layerTreeHost->invalidate();
56 DrawingAreaImpl::DrawingAreaImpl(WebPage* webPage, const WebPageCreationParameters& parameters)
57 : DrawingArea(DrawingAreaTypeImpl, webPage)
58 , m_backingStoreStateID(0)
59 , m_isPaintingEnabled(true)
60 , m_inUpdateBackingStoreState(false)
61 , m_shouldSendDidUpdateBackingStoreState(false)
62 , m_isWaitingForDidUpdate(false)
63 , m_compositingAccordingToProxyMessages(false)
64 , m_layerTreeStateIsFrozen(false)
65 , m_wantsToExitAcceleratedCompositingMode(false)
66 , m_isPaintingSuspended(!parameters.isVisible)
67 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
68 ,m_paintingSuspendCount(0)
70 , m_alwaysUseCompositing(false)
71 , m_displayTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::displayTimerFired)
72 , m_exitCompositingTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::exitAcceleratedCompositingMode)
74 if (webPage->corePage()->settings()->acceleratedDrawingEnabled() || webPage->corePage()->settings()->forceCompositingMode())
75 m_alwaysUseCompositing = true;
77 if (m_alwaysUseCompositing)
78 enterAcceleratedCompositingMode(0);
81 void DrawingAreaImpl::setNeedsDisplay(const IntRect& rect)
83 if (!m_isPaintingEnabled)
86 IntRect dirtyRect = rect;
87 dirtyRect.intersect(m_webPage->bounds());
89 if (dirtyRect.isEmpty())
93 m_webPage->didChangeContents(dirtyRect);
96 if (m_layerTreeHost) {
97 ASSERT(m_dirtyRegion.isEmpty());
99 m_layerTreeHost->setNonCompositedContentsNeedDisplay(dirtyRect);
103 if (m_webPage->mainFrameHasCustomRepresentation())
106 m_dirtyRegion.unite(dirtyRect);
110 void DrawingAreaImpl::scroll(const IntRect& scrollRect, const IntSize& scrollOffset)
112 if (!m_isPaintingEnabled)
116 m_webPage->didChangeContents(scrollRect);
119 if (m_layerTreeHost) {
120 ASSERT(m_scrollRect.isEmpty());
121 ASSERT(m_scrollOffset.isEmpty());
122 ASSERT(m_dirtyRegion.isEmpty());
124 m_layerTreeHost->scrollNonCompositedContents(scrollRect, scrollOffset);
128 if (m_webPage->mainFrameHasCustomRepresentation())
131 if (!m_scrollRect.isEmpty() && scrollRect != m_scrollRect) {
132 unsigned scrollArea = scrollRect.width() * scrollRect.height();
133 unsigned currentScrollArea = m_scrollRect.width() * m_scrollRect.height();
135 if (currentScrollArea >= scrollArea) {
136 // The rect being scrolled is at least as large as the rect we'd like to scroll.
137 // Go ahead and just invalidate the scroll rect.
138 setNeedsDisplay(scrollRect);
142 // Just repaint the entire current scroll rect, we'll scroll the new rect instead.
143 setNeedsDisplay(m_scrollRect);
144 m_scrollRect = IntRect();
145 m_scrollOffset = IntSize();
148 // Get the part of the dirty region that is in the scroll rect.
149 Region dirtyRegionInScrollRect = intersect(scrollRect, m_dirtyRegion);
150 if (!dirtyRegionInScrollRect.isEmpty()) {
151 // There are parts of the dirty region that are inside the scroll rect.
152 // We need to subtract them from the region, move them and re-add them.
153 m_dirtyRegion.subtract(scrollRect);
155 // Move the dirty parts.
156 Region movedDirtyRegionInScrollRect = intersect(translate(dirtyRegionInScrollRect, scrollOffset), scrollRect);
158 // And add them back.
159 m_dirtyRegion.unite(movedDirtyRegionInScrollRect);
162 // Compute the scroll repaint region.
163 Region scrollRepaintRegion = subtract(scrollRect, translate(scrollRect, scrollOffset));
165 m_dirtyRegion.unite(scrollRepaintRegion);
168 m_scrollRect = scrollRect;
169 m_scrollOffset += scrollOffset;
172 void DrawingAreaImpl::setLayerTreeStateIsFrozen(bool isFrozen)
174 if (m_layerTreeStateIsFrozen == isFrozen)
177 m_layerTreeStateIsFrozen = isFrozen;
180 m_layerTreeHost->setLayerFlushSchedulingEnabled(!isFrozen);
183 m_exitCompositingTimer.stop();
184 else if (m_wantsToExitAcceleratedCompositingMode)
185 exitAcceleratedCompositingModeSoon();
188 void DrawingAreaImpl::forceRepaint()
190 setNeedsDisplay(m_webPage->bounds());
192 m_webPage->layoutIfNeeded();
194 if (m_layerTreeHost) {
195 // FIXME: We need to do the same work as the layerHostDidFlushLayers function here,
196 // but clearly it doesn't make sense to call the function with that name.
197 // Consider refactoring and renaming it.
198 if (m_compositingAccordingToProxyMessages)
199 m_layerTreeHost->forceRepaint();
201 // Call setShouldNotifyAfterNextScheduledLayerFlush(false) here to
202 // prevent layerHostDidFlushLayers() from being called a second time.
203 m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(false);
204 layerHostDidFlushLayers();
209 m_isWaitingForDidUpdate = false;
213 void DrawingAreaImpl::didInstallPageOverlay()
216 m_layerTreeHost->didInstallPageOverlay();
219 void DrawingAreaImpl::didUninstallPageOverlay()
222 m_layerTreeHost->didUninstallPageOverlay();
224 setNeedsDisplay(m_webPage->bounds());
227 void DrawingAreaImpl::setPageOverlayNeedsDisplay(const IntRect& rect)
229 if (m_layerTreeHost) {
230 m_layerTreeHost->setPageOverlayNeedsDisplay(rect);
234 setNeedsDisplay(rect);
237 void DrawingAreaImpl::setPageOverlayOpacity(float value)
240 m_layerTreeHost->setPageOverlayOpacity(value);
243 bool DrawingAreaImpl::pageOverlayShouldApplyFadeWhenPainting() const
245 if (m_layerTreeHost && !m_layerTreeHost->pageOverlayShouldApplyFadeWhenPainting())
251 void DrawingAreaImpl::pageCustomRepresentationChanged()
253 if (!m_alwaysUseCompositing)
256 if (m_webPage->mainFrameHasCustomRepresentation()) {
258 exitAcceleratedCompositingMode();
259 } else if (!m_layerTreeHost)
260 enterAcceleratedCompositingMode(0);
263 void DrawingAreaImpl::setPaintingEnabled(bool paintingEnabled)
265 m_isPaintingEnabled = paintingEnabled;
268 void DrawingAreaImpl::layerHostDidFlushLayers()
270 ASSERT(m_layerTreeHost);
272 m_layerTreeHost->forceRepaint();
274 if (m_shouldSendDidUpdateBackingStoreState && !exitAcceleratedCompositingModePending()) {
275 sendDidUpdateBackingStoreState();
279 if (!m_layerTreeHost)
282 #if USE(ACCELERATED_COMPOSITING)
283 ASSERT(!m_compositingAccordingToProxyMessages);
284 if (!exitAcceleratedCompositingModePending()) {
285 m_webPage->send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(m_backingStoreStateID, m_layerTreeHost->layerTreeContext()));
286 m_compositingAccordingToProxyMessages = true;
291 void DrawingAreaImpl::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
293 // FIXME: Instead of using nested if statements, we should keep a compositing state
294 // enum in the DrawingAreaImpl object and have a changeAcceleratedCompositingState function
295 // that takes the new state.
298 if (!m_layerTreeHost) {
299 // We're actually entering accelerated compositing mode.
300 enterAcceleratedCompositingMode(graphicsLayer);
302 // We're already in accelerated compositing mode, but the root compositing layer changed.
304 m_exitCompositingTimer.stop();
305 m_wantsToExitAcceleratedCompositingMode = false;
307 // If we haven't sent the EnterAcceleratedCompositingMode message, make sure that the
308 // layer tree host calls us back after the next layer flush so we can send it then.
309 if (!m_compositingAccordingToProxyMessages)
310 m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true);
312 m_layerTreeHost->setRootCompositingLayer(graphicsLayer);
315 if (m_layerTreeHost) {
316 m_layerTreeHost->setRootCompositingLayer(0);
317 if (!m_alwaysUseCompositing) {
318 // We'll exit accelerated compositing mode on a timer, to avoid re-entering
319 // compositing code via display() and layout.
320 // If we're leaving compositing mode because of a setSize, it is safe to
321 // exit accelerated compositing mode right away.
322 if (m_inUpdateBackingStoreState)
323 exitAcceleratedCompositingMode();
325 exitAcceleratedCompositingModeSoon();
331 void DrawingAreaImpl::scheduleCompositingLayerSync()
333 if (!m_layerTreeHost)
335 m_layerTreeHost->scheduleLayerFlush();
338 #if ENABLE(TIZEN_ONESHOT_DRAWING_SYNCHRONIZATION)
339 void DrawingAreaImpl::setNeedsOneShotDrawingSynchronization()
341 if (!m_layerTreeHost)
343 m_layerTreeHost->setNeedsOneShotDrawingSynchronization();
347 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
348 void DrawingAreaImpl::addOrUpdateScrollingLayer(WebCore::GraphicsLayer* scrollingLayer, WebCore::GraphicsLayer* contentsLayer, const WebCore::IntSize& scrollSize)
350 if (!m_layerTreeHost)
352 m_layerTreeHost->addOrUpdateScrollingLayer(scrollingLayer, contentsLayer, scrollSize);
355 void DrawingAreaImpl::removeScrollingLayer(WebCore::GraphicsLayer* scrollingLayer, WebCore::GraphicsLayer* contentsLayer)
357 if (!m_layerTreeHost)
359 m_layerTreeHost->removeScrollingLayer(scrollingLayer, contentsLayer);
363 void DrawingAreaImpl::updateBackingStoreState(uint64_t stateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize& size, const WebCore::IntSize& scrollOffset)
365 ASSERT(!m_inUpdateBackingStoreState);
366 m_inUpdateBackingStoreState = true;
368 ASSERT_ARG(stateID, stateID >= m_backingStoreStateID);
369 if (stateID != m_backingStoreStateID) {
370 m_backingStoreStateID = stateID;
371 m_shouldSendDidUpdateBackingStoreState = true;
373 m_webPage->setDeviceScaleFactor(deviceScaleFactor);
374 m_webPage->setSize(size);
375 m_webPage->layoutIfNeeded();
376 m_webPage->scrollMainFrameIfNotAtMaxScrollPosition(scrollOffset);
378 if (m_layerTreeHost) {
379 m_layerTreeHost->deviceScaleFactorDidChange();
380 // Use the previously set page size instead of the argument.
381 // It gets adjusted properly when using the fixed layout mode.
382 m_layerTreeHost->sizeDidChange(m_webPage->size());
384 m_dirtyRegion = m_webPage->bounds();
386 ASSERT(size == m_webPage->size());
387 if (!m_shouldSendDidUpdateBackingStoreState) {
388 // We've already sent a DidUpdateBackingStoreState message for this state. We have nothing more to do.
389 m_inUpdateBackingStoreState = false;
394 // The UI process has updated to a new backing store state. Any Update messages we sent before
395 // this point will be ignored. We wait to set this to false until after updating the page's
396 // size so that any displays triggered by the relayout will be ignored. If we're supposed to
397 // respond to the UpdateBackingStoreState message immediately, we'll do a display anyway in
398 // sendDidUpdateBackingStoreState; otherwise we shouldn't do one right now.
399 m_isWaitingForDidUpdate = false;
401 if (respondImmediately) {
402 // Make sure to resume painting if we're supposed to respond immediately, otherwise we'll just
403 // send back an empty UpdateInfo struct.
404 if (m_isPaintingSuspended)
407 sendDidUpdateBackingStoreState();
410 m_inUpdateBackingStoreState = false;
413 void DrawingAreaImpl::sendDidUpdateBackingStoreState()
415 ASSERT(!m_isWaitingForDidUpdate);
416 ASSERT(m_shouldSendDidUpdateBackingStoreState);
418 m_shouldSendDidUpdateBackingStoreState = false;
420 UpdateInfo updateInfo;
422 if (!m_isPaintingSuspended && !m_layerTreeHost)
425 LayerTreeContext layerTreeContext;
427 if (m_isPaintingSuspended || m_layerTreeHost) {
428 updateInfo.viewSize = m_webPage->size();
429 updateInfo.deviceScaleFactor = m_webPage->corePage()->deviceScaleFactor();
431 if (m_layerTreeHost) {
432 layerTreeContext = m_layerTreeHost->layerTreeContext();
434 // We don't want the layer tree host to notify after the next scheduled
435 // layer flush because that might end up sending an EnterAcceleratedCompositingMode
436 // message back to the UI process, but the updated layer tree context
437 // will be sent back in the DidUpdateBackingStoreState message.
438 m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(false);
439 m_layerTreeHost->forceRepaint();
443 m_webPage->send(Messages::DrawingAreaProxy::DidUpdateBackingStoreState(m_backingStoreStateID, updateInfo, layerTreeContext));
444 m_compositingAccordingToProxyMessages = !layerTreeContext.isEmpty();
447 void DrawingAreaImpl::didUpdate()
449 // We might get didUpdate messages from the UI process even after we've
450 // entered accelerated compositing mode. Ignore them.
454 m_isWaitingForDidUpdate = false;
456 // Display if needed. We call displayTimerFired here since it will throttle updates to 60fps.
460 void DrawingAreaImpl::suspendPainting()
462 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
463 m_paintingSuspendCount++;
464 if (m_isPaintingSuspended)
467 ASSERT(!m_isPaintingSuspended);
470 m_layerTreeHost->pauseRendering();
472 m_isPaintingSuspended = true;
473 m_displayTimer.stop();
475 m_webPage->corePage()->suspendScriptedAnimations();
476 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
477 m_webPage->send(Messages::DrawingAreaProxy::DidSuspendPainting());
481 void DrawingAreaImpl::resumePainting()
483 if (!m_isPaintingSuspended) {
484 // FIXME: We can get a call to resumePainting when painting is not suspended.
485 // This happens when sending a synchronous message to create a new page. See <rdar://problem/8976531>.
489 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
490 if (--m_paintingSuspendCount > 0)
495 m_layerTreeHost->resumeRendering();
497 m_isPaintingSuspended = false;
499 // FIXME: We shouldn't always repaint everything here.
500 setNeedsDisplay(m_webPage->bounds());
503 if (m_webPage->windowIsVisible())
504 m_webPage->corePage()->resumeScriptedAnimations();
506 m_webPage->corePage()->resumeScriptedAnimations();
510 void DrawingAreaImpl::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLayer)
512 m_exitCompositingTimer.stop();
513 m_wantsToExitAcceleratedCompositingMode = false;
515 ASSERT(!m_layerTreeHost);
517 m_layerTreeHost = LayerTreeHost::create(m_webPage);
518 if (!m_inUpdateBackingStoreState)
519 m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true);
521 m_layerTreeHost->setRootCompositingLayer(graphicsLayer);
523 // Non-composited content will now be handled exclusively by the layer tree host.
524 m_dirtyRegion = Region();
525 m_scrollRect = IntRect();
526 m_scrollOffset = IntSize();
527 m_displayTimer.stop();
528 m_isWaitingForDidUpdate = false;
531 void DrawingAreaImpl::exitAcceleratedCompositingMode()
533 if (m_alwaysUseCompositing && !m_webPage->mainFrameHasCustomRepresentation())
536 ASSERT(!m_layerTreeStateIsFrozen);
538 m_exitCompositingTimer.stop();
539 m_wantsToExitAcceleratedCompositingMode = false;
541 ASSERT(m_layerTreeHost);
543 m_layerTreeHost->invalidate();
544 m_layerTreeHost = nullptr;
545 m_dirtyRegion = m_webPage->bounds();
547 if (m_inUpdateBackingStoreState)
550 if (m_shouldSendDidUpdateBackingStoreState) {
551 sendDidUpdateBackingStoreState();
555 UpdateInfo updateInfo;
556 if (m_isPaintingSuspended) {
557 updateInfo.viewSize = m_webPage->size();
558 updateInfo.deviceScaleFactor = m_webPage->corePage()->deviceScaleFactor();
562 #if USE(ACCELERATED_COMPOSITING)
563 // Send along a complete update of the page so we can paint the contents right after we exit the
564 // accelerated compositing mode, eliminiating flicker.
565 if (m_compositingAccordingToProxyMessages) {
566 m_webPage->send(Messages::DrawingAreaProxy::ExitAcceleratedCompositingMode(m_backingStoreStateID, updateInfo));
567 m_compositingAccordingToProxyMessages = false;
569 // If we left accelerated compositing mode before we sent an EnterAcceleratedCompositingMode message to the
570 // UI process, we still need to let it know about the new contents, so send an Update message.
571 m_webPage->send(Messages::DrawingAreaProxy::Update(m_backingStoreStateID, updateInfo));
576 void DrawingAreaImpl::exitAcceleratedCompositingModeSoon()
578 if (m_layerTreeStateIsFrozen) {
579 m_wantsToExitAcceleratedCompositingMode = true;
583 if (exitAcceleratedCompositingModePending())
586 m_exitCompositingTimer.startOneShot(0);
589 void DrawingAreaImpl::scheduleDisplay()
591 ASSERT(!m_layerTreeHost);
593 if (m_isWaitingForDidUpdate)
596 if (m_isPaintingSuspended)
599 if (m_dirtyRegion.isEmpty())
602 if (m_displayTimer.isActive())
605 m_displayTimer.startOneShot(0);
608 void DrawingAreaImpl::displayTimerFired()
613 void DrawingAreaImpl::display()
615 ASSERT(!m_layerTreeHost);
616 ASSERT(!m_isWaitingForDidUpdate);
617 ASSERT(!m_inUpdateBackingStoreState);
619 if (m_isPaintingSuspended)
622 if (m_dirtyRegion.isEmpty())
625 if (m_shouldSendDidUpdateBackingStoreState) {
626 sendDidUpdateBackingStoreState();
630 UpdateInfo updateInfo;
633 if (m_layerTreeHost) {
634 // The call to update caused layout which turned on accelerated compositing.
635 // Don't send an Update message in this case.
639 m_webPage->send(Messages::DrawingAreaProxy::Update(m_backingStoreStateID, updateInfo));
640 m_isWaitingForDidUpdate = true;
643 static bool shouldPaintBoundsRect(const IntRect& bounds, const Vector<IntRect>& rects)
645 const size_t rectThreshold = 10;
646 const double wastedSpaceThreshold = 0.75;
648 if (rects.size() <= 1 || rects.size() > rectThreshold)
651 // Attempt to guess whether or not we should use the region bounds rect or the individual rects.
652 // We do this by computing the percentage of "wasted space" in the bounds. If that wasted space
653 // is too large, then we will do individual rect painting instead.
654 unsigned boundsArea = bounds.width() * bounds.height();
655 unsigned rectsArea = 0;
656 for (size_t i = 0; i < rects.size(); ++i)
657 rectsArea += rects[i].width() * rects[i].height();
659 double wastedSpace = 1 - (static_cast<double>(rectsArea) / boundsArea);
661 return wastedSpace <= wastedSpaceThreshold;
665 PassOwnPtr<GraphicsContext> DrawingAreaImpl::createGraphicsContext(ShareableBitmap* bitmap)
667 return bitmap->createGraphicsContext();
671 void DrawingAreaImpl::display(UpdateInfo& updateInfo)
673 ASSERT(!m_isPaintingSuspended);
674 ASSERT(!m_layerTreeHost);
675 ASSERT(!m_webPage->size().isEmpty());
677 // FIXME: It would be better if we could avoid painting altogether when there is a custom representation.
678 if (m_webPage->mainFrameHasCustomRepresentation()) {
679 // ASSUMPTION: the custom representation will be painting the dirty region for us.
680 m_dirtyRegion = Region();
684 m_webPage->layoutIfNeeded();
686 // The layout may have put the page into accelerated compositing mode. If the LayerTreeHost is
687 // in charge of displaying, we have nothing more to do.
691 updateInfo.viewSize = m_webPage->size();
692 updateInfo.deviceScaleFactor = m_webPage->corePage()->deviceScaleFactor();
694 IntRect bounds = m_dirtyRegion.bounds();
695 ASSERT(m_webPage->bounds().contains(bounds));
697 IntSize bitmapSize = bounds.size();
698 float deviceScaleFactor = m_webPage->corePage()->deviceScaleFactor();
699 bitmapSize.scale(deviceScaleFactor);
700 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bitmapSize, ShareableBitmap::SupportsAlpha);
704 if (!bitmap->createHandle(updateInfo.bitmapHandle))
707 Vector<IntRect> rects = m_dirtyRegion.rects();
709 if (shouldPaintBoundsRect(bounds, rects)) {
711 rects.append(bounds);
714 updateInfo.scrollRect = m_scrollRect;
715 updateInfo.scrollOffset = m_scrollOffset;
717 m_dirtyRegion = Region();
718 m_scrollRect = IntRect();
719 m_scrollOffset = IntSize();
721 OwnPtr<GraphicsContext> graphicsContext = createGraphicsContext(bitmap.get());
722 graphicsContext->applyDeviceScaleFactor(deviceScaleFactor);
724 updateInfo.updateRectBounds = bounds;
726 graphicsContext->translate(-bounds.x(), -bounds.y());
728 for (size_t i = 0; i < rects.size(); ++i) {
729 m_webPage->drawRect(*graphicsContext, rects[i]);
730 if (m_webPage->hasPageOverlay())
731 m_webPage->drawPageOverlay(*graphicsContext, rects[i]);
732 updateInfo.updateRects.append(rects[i]);
735 // Layout can trigger more calls to setNeedsDisplay and we don't want to process them
736 // until the UI process has painted the update, so we stop the timer here.
737 m_displayTimer.stop();
740 #if USE(UI_SIDE_COMPOSITING)
741 void DrawingAreaImpl::didReceiveLayerTreeCoordinatorMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
744 m_layerTreeHost->didReceiveLayerTreeCoordinatorMessage(connection, messageID, arguments);
749 void DrawingAreaImpl::setLayerHostingMode(uint32_t opaqueLayerHostingMode)
751 LayerHostingMode layerHostingMode = static_cast<LayerHostingMode>(opaqueLayerHostingMode);
752 m_webPage->setLayerHostingMode(layerHostingMode);
754 if (!m_layerTreeHost)
757 LayerTreeContext oldLayerTreeContext = m_layerTreeHost->layerTreeContext();
758 m_layerTreeHost->setLayerHostingMode(layerHostingMode);
760 if (m_layerTreeHost->layerTreeContext() != oldLayerTreeContext)
761 m_webPage->send(Messages::DrawingAreaProxy::UpdateAcceleratedCompositingMode(m_backingStoreStateID, m_layerTreeHost->layerTreeContext()));
765 #if ENABLE(TIZEN_LAYER_FLUSH_THROTTLING)
766 void DrawingAreaImpl::didStartProgress()
768 if (!m_layerTreeHost)
771 m_layerTreeHost->setDeferLayerFlush(true);
774 void DrawingAreaImpl::didFinishProgress()
776 if (!m_layerTreeHost)
779 m_layerTreeHost->setDeferLayerFlush(false);
783 } // namespace WebKit