[WTF] Add makeUnique<T>, which ensures T is fast-allocated, makeUnique / makeUniqueWi...
[WebKit-https.git] / Source / WebKit / WebProcess / WebPage / RemoteLayerTree / PlatformCALayerRemoteTiledBacking.cpp
1 /*
2  * Copyright (C) 2013 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 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 #include "config.h"
27 #import "PlatformCALayerRemoteTiledBacking.h"
28
29 #import "RemoteLayerTreeContext.h"
30 #import <WebCore/GraphicsLayerCA.h>
31 #import <WebCore/PlatformCALayerCocoa.h>
32 #import <wtf/RetainPtr.h>
33
34 namespace WebKit {
35 using namespace WebCore;
36
37 PlatformCALayerRemoteTiledBacking::PlatformCALayerRemoteTiledBacking(LayerType layerType, PlatformCALayerClient* owner, RemoteLayerTreeContext& context)
38     : PlatformCALayerRemote(layerType, owner, context)
39     , m_tileController(makeUnique<TileController>(this))
40 {
41 }
42
43 PlatformCALayerRemoteTiledBacking::~PlatformCALayerRemoteTiledBacking()
44 {
45 }
46
47 void PlatformCALayerRemoteTiledBacking::setNeedsDisplayInRect(const FloatRect& dirtyRect)
48 {
49     m_tileController->setNeedsDisplayInRect(enclosingIntRect(dirtyRect));
50 }
51
52 void PlatformCALayerRemoteTiledBacking::setNeedsDisplay()
53 {
54     m_tileController->setNeedsDisplay();
55 }
56
57 const WebCore::PlatformCALayerList* PlatformCALayerRemoteTiledBacking::customSublayers() const
58 {
59     m_customSublayers = m_tileController->containerLayers();
60     return &m_customSublayers;
61 }
62
63 void PlatformCALayerRemoteTiledBacking::setBounds(const WebCore::FloatRect& bounds)
64 {
65     PlatformCALayerRemote::setBounds(bounds);
66     m_tileController->tileCacheLayerBoundsChanged();
67 }
68
69 bool PlatformCALayerRemoteTiledBacking::isOpaque() const
70 {
71     return m_tileController->tilesAreOpaque();
72 }
73
74 void PlatformCALayerRemoteTiledBacking::setOpaque(bool opaque)
75 {
76     m_tileController->setTilesOpaque(opaque);
77 }
78
79 bool PlatformCALayerRemoteTiledBacking::acceleratesDrawing() const
80 {
81     return m_tileController->acceleratesDrawing();
82 }
83
84 void PlatformCALayerRemoteTiledBacking::setAcceleratesDrawing(bool acceleratesDrawing)
85 {
86     m_tileController->setAcceleratesDrawing(acceleratesDrawing);
87 }
88
89 bool PlatformCALayerRemoteTiledBacking::wantsDeepColorBackingStore() const
90 {
91     return m_tileController->wantsDeepColorBackingStore();
92 }
93
94 void PlatformCALayerRemoteTiledBacking::setWantsDeepColorBackingStore(bool wantsDeepColorBackingStore)
95 {
96     m_tileController->setWantsDeepColorBackingStore(wantsDeepColorBackingStore);
97 }
98
99 bool PlatformCALayerRemoteTiledBacking::supportsSubpixelAntialiasedText() const
100 {
101     return m_tileController->supportsSubpixelAntialiasedText();
102 }
103
104 void PlatformCALayerRemoteTiledBacking::setSupportsSubpixelAntialiasedText(bool supportsSubpixelAntialiasedText)
105 {
106     m_tileController->setSupportsSubpixelAntialiasedText(supportsSubpixelAntialiasedText);
107 }
108
109 float PlatformCALayerRemoteTiledBacking::contentsScale() const
110 {
111     return m_tileController->contentsScale();
112 }
113
114 void PlatformCALayerRemoteTiledBacking::setContentsScale(float scale)
115 {
116     m_tileController->setContentsScale(scale);
117 }
118
119 void PlatformCALayerRemoteTiledBacking::setBorderWidth(float borderWidth)
120 {
121     m_tileController->setTileDebugBorderWidth(borderWidth / 2);
122 }
123
124 void PlatformCALayerRemoteTiledBacking::setBorderColor(const WebCore::Color& color)
125 {
126     m_tileController->setTileDebugBorderColor(color);
127 }
128
129 } // namespace WebKit