WebCore/ChangeLog

22
33 Reviewed by NOBODY (OOPS!).
44
 5 https://bugs.webkit.org/show_bug.cgi?id=23360
 6
 7 When using accelerated compositing, make repaints use the correct
 8 repaint container. Hook up the RenderLayerCompositor in RenderView,
 9 and add to RenderView a method that repaints both the view
 10 contents, and any intersecting composited layers.
 11
 12 * rendering/RenderBox.cpp:
 13 (WebCore::RenderBox::computeRectForRepaint):
 14 * rendering/RenderInline.cpp:
 15 (WebCore::RenderInline::clippedOverflowRectForRepaint):
 16 * rendering/RenderObject.cpp:
 17 (WebCore::RenderObject::containingBlockWidth):
 18 (WebCore::RenderObject::containingBlockHeight):
 19 (WebCore::RenderObject::containerForRepaint):
 20 (WebCore::RenderObject::repaintUsingContainer):
 21 * rendering/RenderView.cpp:
 22 (WebCore::RenderView::RenderView):
 23 (WebCore::RenderView::~RenderView):
 24 (WebCore::RenderView::shouldRepaint):
 25 (WebCore::RenderView::repaintViewRectangle):
 26 (WebCore::RenderView::repaintRectangleInViewAndCompositedLayers):
 27 (WebCore::RenderView::setMaximalOutlineSize):
 28 (WebCore::RenderView::setSelection):
 29 (WebCore::RenderView::updateWidgetPositions):
 30 (WebCore::RenderView::usesCompositing):
 31 (WebCore::RenderView::compositor):
 32 (WebCore::RenderView::didMoveOnscreen):
 33 (WebCore::RenderView::willMoveOffscreen):
 34 * rendering/RenderView.h:
 35
 362009-02-02 Simon Fraser <simon.fraser@apple.com>
 37
 38 Reviewed by NOBODY (OOPS!).
 39
540 https://bugs.webkit.org/show_bug.cgi?id=23358
641
742 Hook accelerated compositing into RenderLayer.

WebCore/rendering/RenderBox.cpp

@@void RenderBox::computeRectForRepaint(RenderBox* repaintContainer, IntRect& rect
15691569 // in the parent's coordinate space that encloses us.
15701570 if (m_layer && m_layer->transform()) {
15711571 fixed = false;
1572  rect = m_layer->transform()->mapRect(rect);
 1572#if USE(ACCELERATED_COMPOSITING)
 1573 // Ideally, repaints would never cross compositing boundaries, but there are cases
 1574 // where they still do (e.g. for selection). When computing repaint rects across
 1575 // compositing boundaries, we just ignore transforms applied to compositing layers.
 1576 if (!m_layer->isComposited())
 1577 rect = enclosingIntRect(m_layer->transform()->mapRect(FloatRect(rect)));
 1578#else
 1579 rect = enclosingIntRect(m_layer->transform()->mapRect(FloatRect(rect)));
 1580#endif
15731581 // FIXME: this clobbers topLeft adjustment done for multicol above
15741582 topLeft = rect.location();
15751583 topLeft.move(x(), y());

WebCore/rendering/RenderInline.cpp

@@IntRect RenderInline::clippedOverflowRectForRepaint(RenderBox* repaintContainer)
558558 IntRect repaintRect(x, y, r.width(), r.height());
559559 r = intersection(repaintRect, boxRect);
560560 }
561  ASSERT(repaintContainer != this);
562  cb->computeRectForRepaint(repaintContainer, r);
 561 // Don't allow computeRectForRepaint to go above the repaint container.
 562 if (repaintContainer != this)
 563 cb->computeRectForRepaint(repaintContainer, r);
563564
564565 if (ow) {
565566 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) {

WebCore/rendering/RenderObject.cpp

4848#include <stdio.h>
4949#include <wtf/RefCountedLeakCounter.h>
5050
 51#if USE(ACCELERATED_COMPOSITING)
 52#include "RenderLayerCompositor.h"
 53#endif
 54
5155#if ENABLE(WML)
5256#include "WMLNames.h"
5357#endif

@@RenderBlock* RenderObject::containingBlock() const
578582
579583int RenderObject::containingBlockWidth() const
580584{
581  // FIXME ?
582  return containingBlock()->availableWidth();
 585 RenderBlock* container = containingBlock();
 586 return container ? container->availableWidth() : 0;
583587}
584588
585589int RenderObject::containingBlockHeight() const
586590{
587  // FIXME ?
588  return containingBlock()->contentHeight();
 591 RenderBlock* container = containingBlock();
 592 return container ? container->contentHeight() : 0;
589593}
590594
591595static bool mustRepaintFillLayers(const RenderObject* renderer, const FillLayer* layer)

@@void RenderObject::paint(PaintInfo& /*paintInfo*/, int /*tx*/, int /*ty*/)
15521556
15531557RenderBox* RenderObject::containerForRepaint() const
15541558{
1555  // For now, all repaints are root-relative.
 1559#if USE(ACCELERATED_COMPOSITING)
 1560 if (RenderView* v = view()) {
 1561 if (v->usesCompositing()) {
 1562 RenderLayer* compLayer = v->compositor()->enclosingCompositingLayer(enclosingLayer());
 1563 return compLayer ? compLayer->renderer() : 0;
 1564 }
 1565 }
 1566#endif
 1567 // Do root-relative repaint.
15561568 return 0;
15571569}
15581570

@@void RenderObject::repaintUsingContainer(RenderBox* repaintContainer, const IntR
15621574 RenderView* v = repaintContainer ? toRenderView(repaintContainer) : view();
15631575 v->repaintViewRectangle(r, immediate);
15641576 } else {
1565  // Handle container-relative repaints eventually.
 1577#if USE(ACCELERATED_COMPOSITING)
 1578 RenderView* v = view();
 1579 if (v->usesCompositing()) {
 1580 ASSERT(repaintContainer->hasLayer() && repaintContainer->layer()->isComposited());
 1581 repaintContainer->layer()->setBackingNeedsRepaintInRect(r);
 1582 }
 1583#else
15661584 ASSERT_NOT_REACHED();
 1585#endif
15671586 }
15681587}
15691588

WebCore/rendering/RenderView.cpp

3030#include "HitTestResult.h"
3131#include "RenderLayer.h"
3232
 33#if USE(ACCELERATED_COMPOSITING)
 34#include "RenderLayerCompositor.h"
 35#endif
 36
3337namespace WebCore {
3438
3539RenderView::RenderView(Node* node, FrameView* view)

@@RenderView::RenderView(Node* node, FrameView* view)
4347 , m_maximalOutlineSize(0)
4448 , m_layoutState(0)
4549 , m_layoutStateDisableCount(0)
 50#if USE(ACCELERATED_COMPOSITING)
 51 , m_compositor(0)
 52#endif
4653{
4754 // Clear our anonymous bit, set because RenderObject assumes
4855 // any renderer with document as the node is anonymous.

@@RenderView::RenderView(Node* node, FrameView* view)
6572
6673RenderView::~RenderView()
6774{
 75#if USE(ACCELERATED_COMPOSITING)
 76 delete m_compositor;
 77#endif
6878}
6979
7080void RenderView::calcHeight()

@@void RenderView::paintBoxDecorations(PaintInfo& paintInfo, int, int)
213223 }
214224}
215225
216 void RenderView::repaintViewRectangle(const IntRect& ur, bool immediate)
 226bool RenderView::shouldRepaint(const IntRect& r) const
217227{
218  if (printing() || ur.width() == 0 || ur.height() == 0)
219  return;
 228 if (printing() || r.width() == 0 || r.height() == 0)
 229 return false;
220230
221231 if (!m_frameView)
 232 return false;
 233
 234 return true;
 235}
 236
 237void RenderView::repaintViewRectangle(const IntRect& ur, bool immediate)
 238{
 239 if (!shouldRepaint(ur))
222240 return;
223241
224242 // We always just invalidate the root view, since we could be an iframe that is clipped out

@@void RenderView::repaintViewRectangle(const IntRect& ur, bool immediate)
241259 }
242260}
243261
 262void RenderView::repaintRectangleInViewAndCompositedLayers(const IntRect& ur, bool immediate)
 263{
 264 if (!shouldRepaint(ur))
 265 return;
 266
 267 repaintViewRectangle(ur, immediate);
 268
 269#if USE(ACCELERATED_COMPOSITING)
 270 // If we're a frame, repaintViewRectangle will have repainted via a RenderObject in the
 271 // parent document.
 272 if (document()->ownerElement())
 273 return;
 274
 275 if (compositor()->inCompositingMode())
 276 compositor()->repaintCompositedLayersAbsoluteRect(ur);
 277#endif
 278}
 279
244280void RenderView::computeRectForRepaint(RenderBox* repaintContainer, IntRect& rect, bool fixed)
245281{
246282 // If a container was specified, and was not 0 or the RenderView,

@@IntRect RenderView::selectionBounds(bool clipToVisibleContent) const
324360 return selRect;
325361}
326362
 363#if USE(ACCELERATED_COMPOSITING)
 364// Compositing layer dimensions take outline size into account, so we have to recompute layer
 365// bounds when it changes.
 366// FIXME: This is ugly; it would be nice to have a better way to do this.
 367void RenderView::setMaximalOutlineSize(int o)
 368{
 369 if (o != m_maximalOutlineSize) {
 370 m_maximalOutlineSize = o;
 371
 372 if (m_frameView)
 373 m_frameView->updateCompositingLayers(FrameView::ForcedUpdate);
 374 }
 375}
 376#endif
 377
327378void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* end, int endPos)
328379{
329380 // Make sure both our start and end objects are defined.

@@void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* e
439490 if (!newInfo || oldInfo->rect() != newInfo->rect() || oldInfo->state() != newInfo->state() ||
440491 (m_selectionStart == obj && oldStartPos != m_selectionStartPos) ||
441492 (m_selectionEnd == obj && oldEndPos != m_selectionEndPos)) {
442  repaintViewRectangle(oldInfo->rect());
 493 repaintRectangleInViewAndCompositedLayers(oldInfo->rect());
443494 if (newInfo) {
444  repaintViewRectangle(newInfo->rect());
 495 repaintRectangleInViewAndCompositedLayers(newInfo->rect());
445496 newSelectedObjects.remove(obj);
446497 delete newInfo;
447498 }

@@void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* e
453504 SelectedObjectMap::iterator newObjectsEnd = newSelectedObjects.end();
454505 for (SelectedObjectMap::iterator i = newSelectedObjects.begin(); i != newObjectsEnd; ++i) {
455506 SelectionInfo* newInfo = i->second;
456  repaintViewRectangle(newInfo->rect());
 507 repaintRectangleInViewAndCompositedLayers(newInfo->rect());
457508 delete newInfo;
458509 }
459510

@@void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* e
464515 BlockSelectionInfo* newInfo = newSelectedBlocks.get(block);
465516 BlockSelectionInfo* oldInfo = i->second;
466517 if (!newInfo || oldInfo->rects() != newInfo->rects() || oldInfo->state() != newInfo->state()) {
467  repaintViewRectangle(oldInfo->rects());
 518 repaintRectangleInViewAndCompositedLayers(oldInfo->rects());
468519 if (newInfo) {
469  repaintViewRectangle(newInfo->rects());
 520 repaintRectangleInViewAndCompositedLayers(newInfo->rects());
470521 newSelectedBlocks.remove(block);
471522 delete newInfo;
472523 }

@@void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* e
478529 SelectedBlockMap::iterator newBlocksEnd = newSelectedBlocks.end();
479530 for (SelectedBlockMap::iterator i = newSelectedBlocks.begin(); i != newBlocksEnd; ++i) {
480531 BlockSelectionInfo* newInfo = i->second;
481  repaintViewRectangle(newInfo->rects());
 532 repaintRectangleInViewAndCompositedLayers(newInfo->rects());
482533 delete newInfo;
483534 }
484535}

@@bool RenderView::printing() const
501552
502553void RenderView::updateWidgetPositions()
503554{
 555#if USE(ACCELERATED_COMPOSITING)
 556 if (m_compositor)
 557 m_compositor->updateRootLayerPosition();
 558#endif
 559
504560 RenderObjectSet::iterator end = m_widgets.end();
505561 for (RenderObjectSet::iterator it = m_widgets.begin(); it != end; ++it)
506562 (*it)->updateWidgetPosition();

@@void RenderView::updateHitTestResult(HitTestResult& result, const IntPoint& poin
626682 }
627683}
628684
 685#if USE(ACCELERATED_COMPOSITING)
 686bool RenderView::usesCompositing() const
 687{
 688 return m_compositor && m_compositor->inCompositingMode();
 689}
 690
 691RenderLayerCompositor* RenderView::compositor()
 692{
 693 if (!m_compositor)
 694 m_compositor = new RenderLayerCompositor(this);
 695
 696 return m_compositor;
 697}
 698#endif
 699
629700void RenderView::didMoveOnscreen()
630701{
631  // FIXME: will call into RenderLayerCompositor
 702#if USE(ACCELERATED_COMPOSITING)
 703 if (m_compositor)
 704 m_compositor->didMoveOnscreen();
 705#endif
632706}
633707
634708void RenderView::willMoveOffscreen()
635709{
636  // FIXME: will call into RenderLayerCompositor
 710#if USE(ACCELERATED_COMPOSITING)
 711 if (m_compositor)
 712 m_compositor->willMoveOffscreen();
 713#endif
637714}
638715
639716} // namespace WebCore

WebCore/rendering/RenderView.h

3030#include "RenderBlock.h"
3131
3232namespace WebCore {
 33
 34#if USE(ACCELERATED_COMPOSITING)
 35class GraphicsLayer;
 36class RenderLayerCompositor;
 37#endif
3338
3439class RenderView : public RenderBlock {
3540public:

@@public:
6166 virtual bool hasOverhangingFloats() { return false; }
6267
6368 virtual void computeRectForRepaint(RenderBox* repaintContainer, IntRect&, bool fixed = false);
 69
6470 virtual void repaintViewRectangle(const IntRect&, bool immediate = false);
 71 // Repaint the view, and all composited layers that intersect the given absolute rectangle.
 72 // FIXME: ideally we'd never have to do this, if all repaints are container-relative.
 73 virtual void repaintRectangleInViewAndCompositedLayers(const IntRect&, bool immediate = false);
6574
6675 virtual void paint(PaintInfo&, int tx, int ty);
6776 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);

@@public:
8594
8695 IntRect selectionBounds(bool clipToVisibleContent = true) const;
8796
 97#if USE(ACCELERATED_COMPOSITING)
 98 void setMaximalOutlineSize(int o);
 99#else
88100 void setMaximalOutlineSize(int o) { m_maximalOutlineSize = o; }
 101#endif
89102 int maximalOutlineSize() const { return m_maximalOutlineSize; }
90103
91104 virtual IntRect viewRect() const;

@@public:
146159
147160 virtual void updateHitTestResult(HitTestResult&, const IntPoint&);
148161
 162#if USE(ACCELERATED_COMPOSITING)
 163 RenderLayerCompositor* compositor();
 164 bool usesCompositing() const;
 165#endif
 166
 167 // Notifications that this view became visible in a window, or will be
 168 // removed from the window.
149169 void didMoveOnscreen();
150170 void willMoveOffscreen();
151171

@@private:
156176 // selectionRect should never be called on a RenderView
157177 virtual IntRect selectionRect(bool);
158178
 179 bool shouldRepaint(const IntRect& r) const;
 180
159181protected:
160182 FrameView* m_frameView;
161183

@@private:
181203 bool m_forcedPageBreak;
182204 LayoutState* m_layoutState;
183205 unsigned m_layoutStateDisableCount;
 206#if USE(ACCELERATED_COMPOSITING)
 207 RenderLayerCompositor* m_compositor;
 208#endif
184209};
185210
186211inline RenderView* toRenderView(RenderObject* o)