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#include "config.h" 27 28#if USE(ACCELERATED_COMPOSITING) 29 30#import "WebTiledLayer.h" 31 32#import "GraphicsContext.h" 33#import "GraphicsLayerCA.h" 34#import "PlatformCALayer.h" 35#import <wtf/UnusedParam.h> 36 37using namespace WebCore; 38 39@implementation WebTiledLayer 40 41// Set a zero duration for the fade in of tiles 42+ (CFTimeInterval)fadeDuration 43{ 44 return 0; 45} 46 47// Make sure that tiles are drawn on the main thread 48+ (BOOL)shouldDrawOnMainThread 49{ 50 return YES; 51} 52 53// Disable default animations 54- (id<CAAction>)actionForKey:(NSString *)key 55{ 56 UNUSED_PARAM(key); 57 return nil; 58} 59 60- (void)setNeedsDisplay 61{ 62 PlatformCALayer* layer = PlatformCALayer::platformCALayer(self); 63 if (layer && layer->owner() && layer->owner()->platformCALayerDrawsContent()) 64 [super setNeedsDisplay]; 65} 66 67- (void)setNeedsDisplayInRect:(CGRect)dirtyRect 68{ 69 PlatformCALayer* layer = PlatformCALayer::platformCALayer(self); 70 if (layer) 71 setLayerNeedsDisplayInRect(self, layer->owner(), dirtyRect); 72} 73 74- (void)display 75{ 76 [super display]; 77 PlatformCALayer* layer = PlatformCALayer::platformCALayer(self); 78 if (layer && layer->owner()) 79 layer->owner()->platformCALayerLayerDidDisplay(self); 80} 81 82- (void)drawInContext:(CGContextRef)context 83{ 84 PlatformCALayer* layer = PlatformCALayer::platformCALayer(self); 85 if (layer) 86 drawLayerContents(context, self, layer); 87} 88 89@end // implementation WebTiledLayer 90 91#endif // USE(ACCELERATED_COMPOSITING) 92