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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "core/paint/PaintLayerStackingNodeIterator.h" | 53 #include "core/paint/PaintLayerStackingNodeIterator.h" |
54 #include "core/paint/PaintTiming.h" | 54 #include "core/paint/PaintTiming.h" |
55 #include "core/paint/ScrollableAreaPainter.h" | 55 #include "core/paint/ScrollableAreaPainter.h" |
56 #include "core/paint/TransformRecorder.h" | 56 #include "core/paint/TransformRecorder.h" |
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/ColorSpaceFilter.h" |
63 #include "platform/graphics/GraphicsContext.h" | 64 #include "platform/graphics/GraphicsContext.h" |
| 65 #include "platform/graphics/GraphicsScreen.h" |
64 #include "platform/graphics/paint/ClipDisplayItem.h" | 66 #include "platform/graphics/paint/ClipDisplayItem.h" |
65 #include "platform/graphics/paint/CullRect.h" | 67 #include "platform/graphics/paint/CullRect.h" |
66 #include "platform/graphics/paint/PaintController.h" | 68 #include "platform/graphics/paint/PaintController.h" |
67 #include "platform/graphics/paint/TransformDisplayItem.h" | 69 #include "platform/graphics/paint/TransformDisplayItem.h" |
68 #include "public/platform/WebCompositorMutableProperties.h" | 70 #include "public/platform/WebCompositorMutableProperties.h" |
| 71 #include "third_party/skia/include/core/SkColorFilter.h" |
69 #include "wtf/CurrentTime.h" | 72 #include "wtf/CurrentTime.h" |
70 #include "wtf/text/StringBuilder.h" | 73 #include "wtf/text/StringBuilder.h" |
71 | 74 |
72 namespace blink { | 75 namespace blink { |
73 | 76 |
74 using namespace HTMLNames; | 77 using namespace HTMLNames; |
75 | 78 |
76 static IntRect clipBox(LayoutBox* layoutObject); | 79 static IntRect clipBox(LayoutBox* layoutObject); |
77 | 80 |
78 static IntRect contentsRect(const LayoutObject* layoutObject) | 81 static IntRect contentsRect(const LayoutObject* layoutObject) |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 updateCompositedBounds(); | 402 updateCompositedBounds(); |
400 | 403 |
401 if (PaintLayerReflectionInfo* reflection = m_owningLayer.reflectionInfo()) { | 404 if (PaintLayerReflectionInfo* reflection = m_owningLayer.reflectionInfo()) { |
402 if (reflection->reflectionLayer()->hasCompositedLayerMapping()) | 405 if (reflection->reflectionLayer()->hasCompositedLayerMapping()) |
403 reflection->reflectionLayer()->compositedLayerMapping()->updateCompo
sitedBounds(); | 406 reflection->reflectionLayer()->compositedLayerMapping()->updateCompo
sitedBounds(); |
404 } | 407 } |
405 | 408 |
406 PaintLayerCompositor* compositor = this->compositor(); | 409 PaintLayerCompositor* compositor = this->compositor(); |
407 LayoutObject* layoutObject = this->layoutObject(); | 410 LayoutObject* layoutObject = this->layoutObject(); |
408 | 411 |
| 412 WillPaintForDevice device(Page::screenId(layoutObject->frame()->page())); |
| 413 |
409 bool layerConfigChanged = false; | 414 bool layerConfigChanged = false; |
410 setBackgroundLayerPaintsFixedRootBackground(compositor->needsFixedRootBackgr
oundLayer(&m_owningLayer)); | 415 setBackgroundLayerPaintsFixedRootBackground(compositor->needsFixedRootBackgr
oundLayer(&m_owningLayer)); |
411 | 416 |
412 // The background layer is currently only used for fixed root backgrounds. | 417 // The background layer is currently only used for fixed root backgrounds. |
413 if (updateBackgroundLayer(m_backgroundLayerPaintsFixedRootBackground)) | 418 if (updateBackgroundLayer(m_backgroundLayerPaintsFixedRootBackground)) |
414 layerConfigChanged = true; | 419 layerConfigChanged = true; |
415 | 420 |
416 if (updateForegroundLayer(compositor->needsContentsCompositingLayer(&m_ownin
gLayer))) | 421 if (updateForegroundLayer(compositor->needsContentsCompositingLayer(&m_ownin
gLayer))) |
417 layerConfigChanged = true; | 422 layerConfigChanged = true; |
418 | 423 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 updateBackgroundColor(); | 529 updateBackgroundColor(); |
525 | 530 |
526 if (layoutObject->isImage()) { | 531 if (layoutObject->isImage()) { |
527 if (isDirectlyCompositedImage()) { | 532 if (isDirectlyCompositedImage()) { |
528 updateImageContents(); | 533 updateImageContents(); |
529 } else if (m_graphicsLayer->hasContentsLayer()) { | 534 } else if (m_graphicsLayer->hasContentsLayer()) { |
530 m_graphicsLayer->setContentsToImage(nullptr); | 535 m_graphicsLayer->setContentsToImage(nullptr); |
531 } | 536 } |
532 } | 537 } |
533 | 538 |
| 539 RefPtr<SkColorFilter> transform; |
| 540 |
534 if (WebLayer* layer = platformLayerForPlugin(layoutObject)) { | 541 if (WebLayer* layer = platformLayerForPlugin(layoutObject)) { |
535 m_graphicsLayer->setContentsToPlatformLayer(layer); | 542 m_graphicsLayer->setContentsToPlatformLayer(layer); |
| 543 if (imageColorProfilesEnabled()) { |
| 544 transform = createColorSpaceFilter(screenColorProfile(ScreenDevice::
sRGB).get(), screenColorProfile(currentScreenId()).get()); |
| 545 m_graphicsLayer->setContentsLayerColorTransform(colorSpaceFlattenabl
eFilter(transform.get())); |
| 546 fprintf(stderr, "drawing plugin layer\n"); |
| 547 fflush(stderr); |
| 548 } |
536 } else if (layoutObject->node() && layoutObject->node()->isFrameOwnerElement
() && toHTMLFrameOwnerElement(layoutObject->node())->contentFrame()) { | 549 } else if (layoutObject->node() && layoutObject->node()->isFrameOwnerElement
() && toHTMLFrameOwnerElement(layoutObject->node())->contentFrame()) { |
537 Frame* frame = toHTMLFrameOwnerElement(layoutObject->node())->contentFra
me(); | 550 Frame* frame = toHTMLFrameOwnerElement(layoutObject->node())->contentFra
me(); |
538 if (frame->isRemoteFrame()) { | 551 if (frame->isRemoteFrame()) { |
539 WebLayer* layer = toRemoteFrame(frame)->remotePlatformLayer(); | 552 WebLayer* layer = toRemoteFrame(frame)->remotePlatformLayer(); |
540 m_graphicsLayer->setContentsToPlatformLayer(layer); | 553 m_graphicsLayer->setContentsToPlatformLayer(layer); |
541 } | 554 } |
542 } else if (layoutObject->isVideo()) { | 555 } else if (layoutObject->isVideo()) { |
543 HTMLMediaElement* mediaElement = toHTMLMediaElement(layoutObject->node()
); | 556 HTMLMediaElement* mediaElement = toHTMLMediaElement(layoutObject->node()
); |
544 m_graphicsLayer->setContentsToPlatformLayer(mediaElement->platformLayer(
)); | 557 m_graphicsLayer->setContentsToPlatformLayer(mediaElement->platformLayer(
)); |
| 558 // FIXME: correctly handle the video element source color space rather t
han assuming sRGB as is done here. |
| 559 if (imageColorProfilesEnabled()) { |
| 560 transform = createColorSpaceFilter(screenColorProfile(ScreenDevice::
sRGB).get(), screenColorProfile(currentScreenId()).get()); |
| 561 m_graphicsLayer->setContentsLayerColorTransform(colorSpaceFlattenabl
eFilter(transform.get())); |
| 562 fprintf(stderr, "drawing video layer\n"); |
| 563 fflush(stderr); |
| 564 } |
545 } else if (isAcceleratedCanvas(layoutObject)) { | 565 } else if (isAcceleratedCanvas(layoutObject)) { |
546 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject->node()); | 566 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject->node()); |
547 if (CanvasRenderingContext* context = canvas->renderingContext()) | 567 if (CanvasRenderingContext* context = canvas->renderingContext()) { |
548 m_graphicsLayer->setContentsToPlatformLayer(context->platformLayer()
); | 568 m_graphicsLayer->setContentsToPlatformLayer(context->platformLayer()
); |
| 569 if (imageColorProfilesEnabled()) { |
| 570 transform = createColorSpaceFilter(screenColorProfile(ScreenDevi
ce::sRGB).get(), screenColorProfile(currentScreenId()).get()); |
| 571 m_graphicsLayer->setContentsLayerColorTransform(colorSpaceFlatte
nableFilter(transform.get())); |
| 572 fprintf(stderr, "drawing canvas layer\n"); |
| 573 fflush(stderr); |
| 574 } |
| 575 } |
549 layerConfigChanged = true; | 576 layerConfigChanged = true; |
550 } | 577 } |
551 if (layoutObject->isLayoutPart()) { | 578 if (layoutObject->isLayoutPart()) { |
552 if (PaintLayerCompositor::attachFrameContentLayersToIframeLayer(toLayout
Part(layoutObject))) | 579 if (PaintLayerCompositor::attachFrameContentLayersToIframeLayer(toLayout
Part(layoutObject))) |
553 layerConfigChanged = true; | 580 layerConfigChanged = true; |
554 } | 581 } |
555 | 582 |
556 // Changes to either the internal hierarchy or the mask layer have an impact | 583 // Changes to either the internal hierarchy or the mask layer have an impact |
557 // on painting phases, so we need to update when either are updated. | 584 // on painting phases, so we need to update when either are updated. |
558 if (layerConfigChanged || maskLayerChanged) | 585 if (layerConfigChanged || maskLayerChanged) |
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1948 LayoutImage* imageLayoutObject = toLayoutImage(layoutObject()); | 1975 LayoutImage* imageLayoutObject = toLayoutImage(layoutObject()); |
1949 | 1976 |
1950 ImageResource* cachedImage = imageLayoutObject->cachedImage(); | 1977 ImageResource* cachedImage = imageLayoutObject->cachedImage(); |
1951 if (!cachedImage) | 1978 if (!cachedImage) |
1952 return; | 1979 return; |
1953 | 1980 |
1954 Image* image = cachedImage->image(); | 1981 Image* image = cachedImage->image(); |
1955 if (!image) | 1982 if (!image) |
1956 return; | 1983 return; |
1957 | 1984 |
| 1985 WillPaintForDevice device(Page::screenId(layoutObject()->frame()->page())); |
| 1986 |
1958 // This is a no-op if the layer doesn't have an inner layer for the image. | 1987 // This is a no-op if the layer doesn't have an inner layer for the image. |
1959 m_graphicsLayer->setContentsToImage(image, LayoutObject::shouldRespectImageO
rientation(imageLayoutObject)); | 1988 m_graphicsLayer->setContentsToImage(image, LayoutObject::shouldRespectImageO
rientation(imageLayoutObject)); |
1960 | 1989 |
1961 m_graphicsLayer->setFilterQuality(layoutObject()->style()->imageRendering()
== ImageRenderingPixelated ? kNone_SkFilterQuality : kLow_SkFilterQuality); | 1990 m_graphicsLayer->setFilterQuality(layoutObject()->style()->imageRendering()
== ImageRenderingPixelated ? kNone_SkFilterQuality : kLow_SkFilterQuality); |
1962 | 1991 |
1963 // Prevent double-drawing: https://bugs.webkit.org/show_bug.cgi?id=58632 | 1992 // Prevent double-drawing: https://bugs.webkit.org/show_bug.cgi?id=58632 |
1964 updateDrawsContent(); | 1993 updateDrawsContent(); |
1965 | 1994 |
1966 // Image animation is "lazy", in that it automatically stops unless someone
is drawing | 1995 // Image animation is "lazy", in that it automatically stops unless someone
is drawing |
1967 // the image. So we have to kick the animation each time; this has the downs
ide that the | 1996 // the image. So we have to kick the animation each time; this has the downs
ide that the |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2335 | 2364 |
2336 bool CompositedLayerMapping::needsRepaint() const | 2365 bool CompositedLayerMapping::needsRepaint() const |
2337 { | 2366 { |
2338 return m_owningLayer.needsRepaint(); | 2367 return m_owningLayer.needsRepaint(); |
2339 } | 2368 } |
2340 | 2369 |
2341 void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G
raphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase,
const IntRect& interestRect) const | 2370 void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G
raphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase,
const IntRect& interestRect) const |
2342 { | 2371 { |
2343 // https://code.google.com/p/chromium/issues/detail?id=343772 | 2372 // https://code.google.com/p/chromium/issues/detail?id=343772 |
2344 DisableCompositingQueryAsserts disabler; | 2373 DisableCompositingQueryAsserts disabler; |
| 2374 |
| 2375 WillPaintForDevice device(Page::screenId(layoutObject()->frame()->page())); |
| 2376 |
2345 #if ENABLE(ASSERT) | 2377 #if ENABLE(ASSERT) |
2346 // FIXME: once the state machine is ready, this can be removed and we can re
fer to that instead. | 2378 // FIXME: once the state machine is ready, this can be removed and we can re
fer to that instead. |
2347 if (Page* page = layoutObject()->frame()->page()) | 2379 if (Page* page = layoutObject()->frame()->page()) |
2348 page->setIsPainting(true); | 2380 page->setIsPainting(true); |
2349 #endif | 2381 #endif |
2350 | 2382 |
2351 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data
(m_owningLayer.layoutObject(), LayoutRect(interestRect), graphicsLayer)); | 2383 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data
(m_owningLayer.layoutObject(), LayoutRect(interestRect), graphicsLayer)); |
2352 | 2384 |
2353 PaintLayerFlags paintLayerFlags = 0; | 2385 PaintLayerFlags paintLayerFlags = 0; |
2354 if (graphicsLayerPaintingPhase & GraphicsLayerPaintBackground) | 2386 if (graphicsLayerPaintingPhase & GraphicsLayerPaintBackground) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2390 } else if (graphicsLayer == layerForHorizontalScrollbar()) { | 2422 } else if (graphicsLayer == layerForHorizontalScrollbar()) { |
2391 paintScrollbar(m_owningLayer.scrollableArea()->horizontalScrollbar(), co
ntext, interestRect); | 2423 paintScrollbar(m_owningLayer.scrollableArea()->horizontalScrollbar(), co
ntext, interestRect); |
2392 } else if (graphicsLayer == layerForVerticalScrollbar()) { | 2424 } else if (graphicsLayer == layerForVerticalScrollbar()) { |
2393 paintScrollbar(m_owningLayer.scrollableArea()->verticalScrollbar(), cont
ext, interestRect); | 2425 paintScrollbar(m_owningLayer.scrollableArea()->verticalScrollbar(), cont
ext, interestRect); |
2394 } else if (graphicsLayer == layerForScrollCorner()) { | 2426 } else if (graphicsLayer == layerForScrollCorner()) { |
2395 IntPoint scrollCornerAndResizerLocation = m_owningLayer.scrollableArea()
->scrollCornerAndResizerRect().location(); | 2427 IntPoint scrollCornerAndResizerLocation = m_owningLayer.scrollableArea()
->scrollCornerAndResizerRect().location(); |
2396 CullRect cullRect(enclosingIntRect(interestRect)); | 2428 CullRect cullRect(enclosingIntRect(interestRect)); |
2397 ScrollableAreaPainter(*m_owningLayer.scrollableArea()).paintScrollCorner
(context, -scrollCornerAndResizerLocation, cullRect); | 2429 ScrollableAreaPainter(*m_owningLayer.scrollableArea()).paintScrollCorner
(context, -scrollCornerAndResizerLocation, cullRect); |
2398 ScrollableAreaPainter(*m_owningLayer.scrollableArea()).paintResizer(cont
ext, -scrollCornerAndResizerLocation, cullRect); | 2430 ScrollableAreaPainter(*m_owningLayer.scrollableArea()).paintResizer(cont
ext, -scrollCornerAndResizerLocation, cullRect); |
2399 } | 2431 } |
| 2432 |
2400 InspectorInstrumentation::didPaint(m_owningLayer.layoutObject(), graphicsLay
er, context, LayoutRect(interestRect)); | 2433 InspectorInstrumentation::didPaint(m_owningLayer.layoutObject(), graphicsLay
er, context, LayoutRect(interestRect)); |
| 2434 |
2401 #if ENABLE(ASSERT) | 2435 #if ENABLE(ASSERT) |
2402 if (Page* page = layoutObject()->frame()->page()) | 2436 if (Page* page = layoutObject()->frame()->page()) |
2403 page->setIsPainting(false); | 2437 page->setIsPainting(false); |
2404 #endif | 2438 #endif |
2405 } | 2439 } |
2406 | 2440 |
2407 bool CompositedLayerMapping::isTrackingPaintInvalidations() const | 2441 bool CompositedLayerMapping::isTrackingPaintInvalidations() const |
2408 { | 2442 { |
2409 GraphicsLayerClient* client = compositor(); | 2443 GraphicsLayerClient* client = compositor(); |
2410 return client ? client->isTrackingPaintInvalidations() : false; | 2444 return client ? client->isTrackingPaintInvalidations() : false; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2582 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { | 2616 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { |
2583 name = "Scrolling Block Selection Layer"; | 2617 name = "Scrolling Block Selection Layer"; |
2584 } else { | 2618 } else { |
2585 ASSERT_NOT_REACHED(); | 2619 ASSERT_NOT_REACHED(); |
2586 } | 2620 } |
2587 | 2621 |
2588 return name; | 2622 return name; |
2589 } | 2623 } |
2590 | 2624 |
2591 } // namespace blink | 2625 } // namespace blink |
OLD | NEW |