| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010, 2011 Apple 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #include "core/plugins/PluginView.h" | 57 #include "core/plugins/PluginView.h" |
| 58 #include "platform/LengthFunctions.h" | 58 #include "platform/LengthFunctions.h" |
| 59 #include "platform/RuntimeEnabledFeatures.h" | 59 #include "platform/RuntimeEnabledFeatures.h" |
| 60 #include "platform/fonts/FontCache.h" | 60 #include "platform/fonts/FontCache.h" |
| 61 #include "platform/geometry/TransformState.h" | 61 #include "platform/geometry/TransformState.h" |
| 62 #include "platform/graphics/BitmapImage.h" | 62 #include "platform/graphics/BitmapImage.h" |
| 63 #include "platform/graphics/CompositorMutableProperties.h" | 63 #include "platform/graphics/CompositorMutableProperties.h" |
| 64 #include "platform/graphics/GraphicsContext.h" | 64 #include "platform/graphics/GraphicsContext.h" |
| 65 #include "platform/graphics/paint/ClipDisplayItem.h" | 65 #include "platform/graphics/paint/ClipDisplayItem.h" |
| 66 #include "platform/graphics/paint/CullRect.h" | 66 #include "platform/graphics/paint/CullRect.h" |
| 67 #include "platform/graphics/paint/DrawingRecorder.h" |
| 67 #include "platform/graphics/paint/PaintController.h" | 68 #include "platform/graphics/paint/PaintController.h" |
| 69 #include "platform/graphics/paint/SkPictureBuilder.h" |
| 68 #include "platform/graphics/paint/TransformDisplayItem.h" | 70 #include "platform/graphics/paint/TransformDisplayItem.h" |
| 69 #include "wtf/CurrentTime.h" | 71 #include "wtf/CurrentTime.h" |
| 70 #include "wtf/text/StringBuilder.h" | 72 #include "wtf/text/StringBuilder.h" |
| 71 | 73 |
| 72 namespace blink { | 74 namespace blink { |
| 73 | 75 |
| 74 using namespace HTMLNames; | 76 using namespace HTMLNames; |
| 75 | 77 |
| 76 static IntRect clipBox(LayoutBox* layoutObject); | 78 static IntRect clipBox(LayoutBox* layoutObject); |
| 77 | 79 |
| (...skipping 2227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2305 LayoutSize CompositedLayerMapping::subpixelAccumulation() const | 2307 LayoutSize CompositedLayerMapping::subpixelAccumulation() const |
| 2306 { | 2308 { |
| 2307 return m_owningLayer.subpixelAccumulation(); | 2309 return m_owningLayer.subpixelAccumulation(); |
| 2308 } | 2310 } |
| 2309 | 2311 |
| 2310 bool CompositedLayerMapping::needsRepaint() const | 2312 bool CompositedLayerMapping::needsRepaint() const |
| 2311 { | 2313 { |
| 2312 return m_owningLayer.needsRepaint(); | 2314 return m_owningLayer.needsRepaint(); |
| 2313 } | 2315 } |
| 2314 | 2316 |
| 2315 void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G
raphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase,
const IntRect& interestRect) const | 2317 void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G
raphicsContext& context, |
| 2318 GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, const IntRect& intere
stRect) const |
| 2316 { | 2319 { |
| 2317 // https://code.google.com/p/chromium/issues/detail?id=343772 | 2320 // https://code.google.com/p/chromium/issues/detail?id=343772 |
| 2318 DisableCompositingQueryAsserts disabler; | 2321 DisableCompositingQueryAsserts disabler; |
| 2319 #if ENABLE(ASSERT) | 2322 #if ENABLE(ASSERT) |
| 2320 // FIXME: once the state machine is ready, this can be removed and we can re
fer to that instead. | 2323 // FIXME: once the state machine is ready, this can be removed and we can re
fer to that instead. |
| 2321 if (Page* page = layoutObject()->frame()->page()) | 2324 if (Page* page = layoutObject()->frame()->page()) |
| 2322 page->setIsPainting(true); | 2325 page->setIsPainting(true); |
| 2323 #endif | 2326 #endif |
| 2324 | 2327 |
| 2325 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data
(m_owningLayer.layoutObject(), LayoutRect(interestRect), graphicsLayer)); | 2328 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data
(m_owningLayer.layoutObject(), LayoutRect(interestRect), graphicsLayer)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2353 GraphicsLayerPaintInfo paintInfo; | 2356 GraphicsLayerPaintInfo paintInfo; |
| 2354 paintInfo.paintLayer = &m_owningLayer; | 2357 paintInfo.paintLayer = &m_owningLayer; |
| 2355 paintInfo.compositedBounds = compositedBounds(); | 2358 paintInfo.compositedBounds = compositedBounds(); |
| 2356 paintInfo.offsetFromLayoutObject = graphicsLayer->offsetFromLayoutObject
(); | 2359 paintInfo.offsetFromLayoutObject = graphicsLayer->offsetFromLayoutObject
(); |
| 2357 | 2360 |
| 2358 // We have to use the same root as for hit testing, because both methods
can compute and cache clipRects. | 2361 // We have to use the same root as for hit testing, because both methods
can compute and cache clipRects. |
| 2359 doPaintTask(paintInfo, *graphicsLayer, paintLayerFlags, context, interes
tRect); | 2362 doPaintTask(paintInfo, *graphicsLayer, paintLayerFlags, context, interes
tRect); |
| 2360 } else if (graphicsLayer == m_squashingLayer.get()) { | 2363 } else if (graphicsLayer == m_squashingLayer.get()) { |
| 2361 for (size_t i = 0; i < m_squashedLayers.size(); ++i) | 2364 for (size_t i = 0; i < m_squashedLayers.size(); ++i) |
| 2362 doPaintTask(m_squashedLayers[i], *graphicsLayer, paintLayerFlags, co
ntext, interestRect); | 2365 doPaintTask(m_squashedLayers[i], *graphicsLayer, paintLayerFlags, co
ntext, interestRect); |
| 2363 } else if (graphicsLayer == layerForHorizontalScrollbar()) { | 2366 } else if (isScrollableAreaLayer(graphicsLayer)) { |
| 2364 paintScrollbar(m_owningLayer.getScrollableArea()->horizontalScrollbar(),
context, interestRect); | 2367 paintScrollableArea(graphicsLayer, context, interestRect); |
| 2365 } else if (graphicsLayer == layerForVerticalScrollbar()) { | |
| 2366 paintScrollbar(m_owningLayer.getScrollableArea()->verticalScrollbar(), c
ontext, interestRect); | |
| 2367 } else if (graphicsLayer == layerForScrollCorner()) { | |
| 2368 IntPoint scrollCornerAndResizerLocation = m_owningLayer.getScrollableAre
a()->scrollCornerAndResizerRect().location(); | |
| 2369 CullRect cullRect(enclosingIntRect(interestRect)); | |
| 2370 ScrollableAreaPainter(*m_owningLayer.getScrollableArea()).paintScrollCor
ner(context, -scrollCornerAndResizerLocation, cullRect); | |
| 2371 ScrollableAreaPainter(*m_owningLayer.getScrollableArea()).paintResizer(c
ontext, -scrollCornerAndResizerLocation, cullRect); | |
| 2372 } | 2368 } |
| 2373 InspectorInstrumentation::didPaint(m_owningLayer.layoutObject(), graphicsLay
er, context, LayoutRect(interestRect)); | 2369 InspectorInstrumentation::didPaint(m_owningLayer.layoutObject(), graphicsLay
er, context, LayoutRect(interestRect)); |
| 2374 #if ENABLE(ASSERT) | 2370 #if ENABLE(ASSERT) |
| 2375 if (Page* page = layoutObject()->frame()->page()) | 2371 if (Page* page = layoutObject()->frame()->page()) |
| 2376 page->setIsPainting(false); | 2372 page->setIsPainting(false); |
| 2377 #endif | 2373 #endif |
| 2378 } | 2374 } |
| 2379 | 2375 |
| 2376 void CompositedLayerMapping::paintScrollableArea(const GraphicsLayer* graphicsLa
yer, |
| 2377 GraphicsContext& context, const IntRect& interestRect) const |
| 2378 { |
| 2379 // Note the composited scrollable area painted here is never associated with
a frame. For |
| 2380 // painting frame ScrollableAreas, see PaintLayerCompositor::paintContents. |
| 2381 |
| 2382 FloatRect layerBounds(FloatPoint(), graphicsLayer->size()); |
| 2383 SkPictureBuilder pictureBuilder(layerBounds, nullptr, &context); |
| 2384 |
| 2385 PaintLayerScrollableArea* scrollableArea = m_owningLayer.getScrollableArea()
; |
| 2386 if (graphicsLayer == layerForHorizontalScrollbar()) { |
| 2387 paintScrollbar(scrollableArea->horizontalScrollbar(), pictureBuilder.con
text(), interestRect); |
| 2388 } else if (graphicsLayer == layerForVerticalScrollbar()) { |
| 2389 paintScrollbar(scrollableArea->verticalScrollbar(), pictureBuilder.conte
xt(), interestRect); |
| 2390 } else if (graphicsLayer == layerForScrollCorner()) { |
| 2391 // Note that scroll corners always paint into local space, whereas scrol
lbars paint in the space of their containing frame. |
| 2392 IntPoint scrollCornerAndResizerLocation = scrollableArea->scrollCornerAn
dResizerRect().location(); |
| 2393 CullRect cullRect(enclosingIntRect(interestRect)); |
| 2394 ScrollableAreaPainter(*scrollableArea).paintScrollCorner(pictureBuilder.
context(), -scrollCornerAndResizerLocation, cullRect); |
| 2395 ScrollableAreaPainter(*scrollableArea).paintResizer(pictureBuilder.conte
xt(), -scrollCornerAndResizerLocation, cullRect); |
| 2396 } |
| 2397 |
| 2398 // Replay the painted scrollbar content with the GraphicsLayer backing as th
e DisplayItemClient |
| 2399 // in order for the resulting DrawingDisplayItem to produce the correct visu
alRect (i.e., the |
| 2400 // bounds of the involved GraphicsLayer). |
| 2401 DrawingRecorder drawingRecorder(context, *graphicsLayer, DisplayItem::Scroll
barCompositedScrollbar, layerBounds); |
| 2402 pictureBuilder.endRecording()->playback(context.canvas()); |
| 2403 } |
| 2404 |
| 2405 bool CompositedLayerMapping::isScrollableAreaLayer(const GraphicsLayer* graphics
Layer) const |
| 2406 { |
| 2407 return graphicsLayer == layerForHorizontalScrollbar() |
| 2408 || graphicsLayer == layerForVerticalScrollbar() |
| 2409 || graphicsLayer == layerForScrollCorner(); |
| 2410 } |
| 2411 |
| 2380 bool CompositedLayerMapping::isTrackingPaintInvalidations() const | 2412 bool CompositedLayerMapping::isTrackingPaintInvalidations() const |
| 2381 { | 2413 { |
| 2382 GraphicsLayerClient* client = compositor(); | 2414 GraphicsLayerClient* client = compositor(); |
| 2383 return client ? client->isTrackingPaintInvalidations() : false; | 2415 return client ? client->isTrackingPaintInvalidations() : false; |
| 2384 } | 2416 } |
| 2385 | 2417 |
| 2386 #if ENABLE(ASSERT) | 2418 #if ENABLE(ASSERT) |
| 2387 void CompositedLayerMapping::verifyNotPainting() | 2419 void CompositedLayerMapping::verifyNotPainting() |
| 2388 { | 2420 { |
| 2389 ASSERT(!layoutObject()->frame()->page() || !layoutObject()->frame()->page()-
>isPainting()); | 2421 ASSERT(!layoutObject()->frame()->page() || !layoutObject()->frame()->page()-
>isPainting()); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2543 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2575 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
| 2544 name = "Scrolling Contents Layer"; | 2576 name = "Scrolling Contents Layer"; |
| 2545 } else { | 2577 } else { |
| 2546 ASSERT_NOT_REACHED(); | 2578 ASSERT_NOT_REACHED(); |
| 2547 } | 2579 } |
| 2548 | 2580 |
| 2549 return name; | 2581 return name; |
| 2550 } | 2582 } |
| 2551 | 2583 |
| 2552 } // namespace blink | 2584 } // namespace blink |
| OLD | NEW |