1 /* 2 * Copyright (C) 2009 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 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. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_GRAPHICS_LAYER_CLIENT_H_ 27 #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_GRAPHICS_LAYER_CLIENT_H_ 28 29 #include "third_party/blink/renderer/platform/geometry/layout_size.h" 30 #include "third_party/blink/renderer/platform/platform_export.h" 31 #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" 32 33 namespace blink { 34 35 class GraphicsContext; 36 class GraphicsLayer; 37 class IntRect; 38 class ScrollableArea; 39 40 enum GraphicsLayerPaintingPhaseFlags { 41 kGraphicsLayerPaintBackground = (1 << 0), 42 kGraphicsLayerPaintForeground = (1 << 1), 43 kGraphicsLayerPaintMask = (1 << 2), 44 kGraphicsLayerPaintOverflowContents = (1 << 3), 45 kGraphicsLayerPaintCompositedScroll = (1 << 4), 46 kGraphicsLayerPaintDecoration = (1 << 5), 47 kGraphicsLayerPaintAllWithOverflowClip = 48 (kGraphicsLayerPaintBackground | kGraphicsLayerPaintForeground | 49 kGraphicsLayerPaintMask | kGraphicsLayerPaintDecoration) 50 }; 51 typedef unsigned GraphicsLayerPaintingPhase; 52 53 enum class DisplayLockContextLifecycleTarget { kSelf, kChildren }; 54 55 class PLATFORM_EXPORT GraphicsLayerClient { 56 public: 57 virtual ~GraphicsLayerClient() = default; 58 59 virtual IntRect ComputeInterestRect( 60 const GraphicsLayer*, 61 const IntRect& previous_interest_rect) const = 0; SubpixelAccumulation()62 virtual LayoutSize SubpixelAccumulation() const { return LayoutSize(); } 63 // Returns whether the client needs to be repainted with respect to the given 64 // graphics layer. 65 virtual bool NeedsRepaint(const GraphicsLayer&) const = 0; 66 virtual void PaintContents(const GraphicsLayer*, 67 GraphicsContext&, 68 GraphicsLayerPaintingPhase, 69 const IntRect& interest_rect) const = 0; 70 71 // Returns true if the GraphicsLayer is under a frame that should not render 72 // (see LocalFrameView::ShouldThrottleRendering()). ShouldThrottleRendering()73 virtual bool ShouldThrottleRendering() const { return false; } 74 75 // Content under a LayoutSVGHiddenContainer is an auxiliary resource for 76 // painting and hit testing. IsUnderSVGHiddenContainer()77 virtual bool IsUnderSVGHiddenContainer() const { return false; } 78 IsTrackingRasterInvalidations()79 virtual bool IsTrackingRasterInvalidations() const { return false; } 80 GraphicsLayersDidChange()81 virtual void GraphicsLayersDidChange() {} 82 83 virtual String DebugName(const GraphicsLayer*) const = 0; 84 GetScrollableAreaForTesting(const GraphicsLayer *)85 virtual const ScrollableArea* GetScrollableAreaForTesting( 86 const GraphicsLayer*) const { 87 return nullptr; 88 } 89 90 // Returns true if this client is prevented from painting by its own 91 // display-lock (in case of target = kSelf) or by any of its ancestors (in 92 // case of target = kSelf or kChildren). PaintBlockedByDisplayLockIncludingAncestors(DisplayLockContextLifecycleTarget)93 virtual bool PaintBlockedByDisplayLockIncludingAncestors( 94 DisplayLockContextLifecycleTarget) const { 95 return false; 96 } NotifyDisplayLockNeedsGraphicsLayerCollection()97 virtual void NotifyDisplayLockNeedsGraphicsLayerCollection() {} 98 99 #if DCHECK_IS_ON() 100 // CompositedLayerMapping overrides this to verify that it is not 101 // currently painting contents. An ASSERT fails, if it is. 102 // This is executed in GraphicsLayer construction and destruction 103 // to verify that we don't create or destroy GraphicsLayers 104 // while painting. VerifyNotPainting()105 virtual void VerifyNotPainting() {} 106 #endif 107 }; 108 109 } // namespace blink 110 111 #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_GRAPHICS_LAYER_CLIENT_H_ 112