2 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
27 #import "WebTiledBackingLayer.h"
30 #import "TileController.h"
31 #import <wtf/MainThread.h>
33 using namespace WebCore;
35 @implementation WebTiledBackingLayer
44 [self setName:@"WebTiledBackingLayer"];
51 ASSERT(!_tileController);
56 - (id)initWithLayer:(id)layer
64 - (TileController*)createTileController:(PlatformCALayer*)rootLayer
66 ASSERT(!_tileController);
67 _tileController = TileController::create(rootLayer);
68 return _tileController.get();
71 - (id<CAAction>)actionForKey:(NSString *)key
75 // Disable all animations.
79 - (void)setBounds:(CGRect)bounds
81 [super setBounds:bounds];
83 _tileController->tileCacheLayerBoundsChanged();
86 - (void)setOpaque:(BOOL)opaque
88 _tileController->setTilesOpaque(opaque);
93 return _tileController->tilesAreOpaque();
96 - (void)setNeedsDisplay
98 _tileController->setNeedsDisplay();
101 - (void)setNeedsDisplayInRect:(CGRect)rect
103 _tileController->setNeedsDisplayInRect(enclosingIntRect(rect));
106 - (void)setAcceleratesDrawing:(BOOL)acceleratesDrawing
108 _tileController->setAcceleratesDrawing(acceleratesDrawing);
111 - (BOOL)acceleratesDrawing
113 return _tileController->acceleratesDrawing();
116 - (void)setContentsScale:(CGFloat)contentsScale
118 _tileController->setContentsScale(contentsScale);
121 - (CGFloat)contentsScale
123 return _tileController->contentsScale();
126 - (WebCore::TiledBacking*)tiledBacking
128 return _tileController.get();
133 ASSERT(isMainThread());
134 ASSERT(_tileController);
135 _tileController = nullptr;
138 - (void)setBorderColor:(CGColorRef)borderColor
140 _tileController->setTileDebugBorderColor(Color(borderColor));
143 - (void)setBorderWidth:(CGFloat)borderWidth
145 // Tiles adjoin, so halve the border width.
146 _tileController->setTileDebugBorderWidth(borderWidth / 2);