2 * Copyright (C) 2010 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 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.
28 #if USE(ACCELERATED_COMPOSITING)
30 #import "PlatformCALayer.h"
32 #import "BlockExceptions.h"
33 #import "FloatConversion.h"
34 #import "GraphicsContext.h"
35 #import "GraphicsLayerCA.h"
37 #import "WebTiledLayer.h"
38 #import <objc/objc-auto.h>
39 #import <objc/objc-runtime.h>
40 #import <QuartzCore/QuartzCore.h>
41 #import <wtf/CurrentTime.h>
42 #import <wtf/UnusedParam.h>
44 #define HAVE_MODERN_QUARTZCORE (!defined(BUILDING_ON_LEOPARD))
46 using namespace WebCore;
48 // This value must be the same as in PlatformCAAnimationMac.mm
49 static NSString * const WKNonZeroBeginTimeFlag = @"WKPlatformCAAnimationNonZeroBeginTimeFlag";
51 static double mediaTimeToCurrentTime(CFTimeInterval t)
53 return WTF::currentTime() + t - CACurrentMediaTime();
56 // Delegate for animationDidStart callback
57 @interface WebAnimationDelegate : NSObject {
58 PlatformCALayer* m_owner;
61 - (void)animationDidStart:(CAAnimation *)anim;
62 - (void)setOwner:(PlatformCALayer*)owner;
66 @implementation WebAnimationDelegate
68 - (void)animationDidStart:(CAAnimation *)animation
70 // hasNonZeroBeginTime is stored in a key in the animation
71 bool hasNonZeroBeginTime = [[animation valueForKey:WKNonZeroBeginTimeFlag] boolValue];
72 CFTimeInterval startTime;
74 if (hasNonZeroBeginTime) {
75 // We don't know what time CA used to commit the animation, so just use the current time
76 // (even though this will be slightly off).
77 startTime = mediaTimeToCurrentTime(CACurrentMediaTime());
79 startTime = mediaTimeToCurrentTime([animation beginTime]);
82 m_owner->animationStarted(startTime);
85 - (void)setOwner:(PlatformCALayer*)owner
92 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
93 @interface CATiledLayer(GraphicsLayerCAPrivate)
94 - (void)displayInRect:(CGRect)r levelOfDetail:(int)lod options:(NSDictionary *)dict;
95 - (BOOL)canDrawConcurrently;
96 - (void)setCanDrawConcurrently:(BOOL)flag;
100 @interface CALayer(Private)
101 - (void)setContentsChanged;
102 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
103 - (void)setAcceleratesDrawing:(BOOL)flag;
104 - (BOOL)acceleratesDrawing;
108 static NSString * const platformCALayerPointer = @"WKPlatformCALayer";
110 bool PlatformCALayer::isValueFunctionSupported()
112 static bool sHaveValueFunction = [CAPropertyAnimation instancesRespondToSelector:@selector(setValueFunction:)];
113 return sHaveValueFunction;
116 void PlatformCALayer::setOwner(PlatformCALayerClient* owner)
120 // Change the delegate's owner if needed
122 [static_cast<WebAnimationDelegate*>(m_delegate.get()) setOwner:this];
125 static NSDictionary* nullActionsDictionary()
127 NSNull* nullValue = [NSNull null];
128 NSDictionary* actions = [NSDictionary dictionaryWithObjectsAndKeys:
129 nullValue, @"anchorPoint",
130 nullValue, @"anchorPointZ",
131 nullValue, @"bounds",
132 nullValue, @"contents",
133 nullValue, @"contentsRect",
134 nullValue, @"opacity",
135 nullValue, @"position",
136 nullValue, @"shadowColor",
137 nullValue, @"sublayerTransform",
138 nullValue, @"sublayers",
139 nullValue, @"transform",
140 nullValue, @"zPosition",
145 #if HAVE_MODERN_QUARTZCORE
146 static NSString* toCAFilterType(PlatformCALayer::FilterType type)
149 case PlatformCALayer::Linear: return kCAFilterLinear;
150 case PlatformCALayer::Nearest: return kCAFilterNearest;
151 case PlatformCALayer::Trilinear: return kCAFilterTrilinear;
157 PassRefPtr<PlatformCALayer> PlatformCALayer::create(LayerType layerType, PlatformCALayerClient* owner)
159 return adoptRef(new PlatformCALayer(layerType, 0, owner));
162 PassRefPtr<PlatformCALayer> PlatformCALayer::create(void* platformLayer, PlatformCALayerClient* owner)
164 return adoptRef(new PlatformCALayer(LayerTypeCustom, static_cast<PlatformLayer*>(platformLayer), owner));
167 PlatformCALayer::PlatformCALayer(LayerType layerType, PlatformLayer* layer, PlatformCALayerClient* owner)
170 BEGIN_BLOCK_OBJC_EXCEPTIONS
172 m_layerType = LayerTypeCustom;
175 m_layerType = layerType;
177 Class layerClass = Nil;
180 case LayerTypeRootLayer:
181 layerClass = [CALayer class];
183 case LayerTypeWebLayer:
184 layerClass = [WebLayer class];
186 case LayerTypeTransformLayer:
187 layerClass = NSClassFromString(@"CATransformLayer");
189 case LayerTypeWebTiledLayer:
190 layerClass = [WebTiledLayer class];
192 case LayerTypeCustom:
197 m_layer.adoptNS([[layerClass alloc] init]);
200 // Save a pointer to 'this' in the CALayer
201 [m_layer.get() setValue:[NSValue valueWithPointer:this] forKey:platformCALayerPointer];
203 // Clear all the implicit animations on the CALayer
204 [m_layer.get() setStyle:[NSDictionary dictionaryWithObject:nullActionsDictionary() forKey:@"actions"]];
206 // If this is a TiledLayer, set some initial values
207 if (m_layerType == LayerTypeWebTiledLayer) {
208 WebTiledLayer* tiledLayer = static_cast<WebTiledLayer*>(m_layer.get());
209 [tiledLayer setTileSize:CGSizeMake(GraphicsLayerCA::kTiledLayerTileSize, GraphicsLayerCA::kTiledLayerTileSize)];
210 [tiledLayer setLevelsOfDetail:1];
211 [tiledLayer setLevelsOfDetailBias:0];
212 [tiledLayer setContentsGravity:@"bottomLeft"];
215 END_BLOCK_OBJC_EXCEPTIONS
218 PlatformCALayer::~PlatformCALayer()
220 [m_layer.get() setValue:nil forKey:platformCALayerPointer];
222 // Clear the owner, which also clears it in the delegate to prevent attempts
223 // to use the GraphicsLayerCA after it has been destroyed.
226 // Remove the owner pointer from the delegate in case there is a pending animationStarted event.
227 [static_cast<WebAnimationDelegate*>(m_delegate.get()) setOwner:nil];
230 PlatformCALayer* PlatformCALayer::platformCALayer(void* platformLayer)
235 // Pointer to PlatformCALayer is kept in a key of the CALayer
236 PlatformCALayer* platformCALayer = nil;
237 BEGIN_BLOCK_OBJC_EXCEPTIONS
238 platformCALayer = static_cast<PlatformCALayer*>([[static_cast<CALayer*>(platformLayer) valueForKey:platformCALayerPointer] pointerValue]);
239 END_BLOCK_OBJC_EXCEPTIONS
240 return platformCALayer;
243 PlatformLayer* PlatformCALayer::platformLayer() const
245 return m_layer.get();
248 void PlatformCALayer::animationStarted(CFTimeInterval beginTime)
251 m_owner->platformCALayerAnimationStarted(beginTime);
254 void PlatformCALayer::setNeedsDisplay(const FloatRect* dirtyRect)
256 BEGIN_BLOCK_OBJC_EXCEPTIONS
258 [m_layer.get() setNeedsDisplayInRect:*dirtyRect];
260 [m_layer.get() setNeedsDisplay];
261 END_BLOCK_OBJC_EXCEPTIONS
264 void PlatformCALayer::setContentsChanged()
266 BEGIN_BLOCK_OBJC_EXCEPTIONS
267 [m_layer.get() setContentsChanged];
268 END_BLOCK_OBJC_EXCEPTIONS
271 PlatformCALayer* PlatformCALayer::superlayer() const
273 return platformCALayer([m_layer.get() superlayer]);
276 void PlatformCALayer::removeFromSuperlayer()
278 BEGIN_BLOCK_OBJC_EXCEPTIONS
279 [m_layer.get() removeFromSuperlayer];
280 END_BLOCK_OBJC_EXCEPTIONS
283 void PlatformCALayer::setSublayers(const PlatformCALayerList& list)
285 // Short circuiting here not only avoids the allocation of sublayers, but avoids <rdar://problem/7390716> (see below)
286 if (list.size() == 0) {
287 removeAllSublayers();
291 BEGIN_BLOCK_OBJC_EXCEPTIONS
292 NSMutableArray* sublayers = [[NSMutableArray alloc] init];
293 for (size_t i = 0; i < list.size(); ++i)
294 [sublayers addObject:list[i]->m_layer.get()];
296 [m_layer.get() setSublayers:sublayers];
298 END_BLOCK_OBJC_EXCEPTIONS
301 void PlatformCALayer::removeAllSublayers()
303 // Workaround for <rdar://problem/7390716>: -[CALayer setSublayers:] crashes if sublayers is an empty array, or nil, under GC.
304 BEGIN_BLOCK_OBJC_EXCEPTIONS
305 if (objc_collectingEnabled())
306 while ([[m_layer.get() sublayers] count])
307 [[[m_layer.get() sublayers] objectAtIndex:0] removeFromSuperlayer];
309 [m_layer.get() setSublayers:nil];
310 END_BLOCK_OBJC_EXCEPTIONS
313 void PlatformCALayer::appendSublayer(PlatformCALayer* layer)
315 BEGIN_BLOCK_OBJC_EXCEPTIONS
316 [m_layer.get() addSublayer:layer->m_layer.get()];
317 END_BLOCK_OBJC_EXCEPTIONS
320 void PlatformCALayer::insertSublayer(PlatformCALayer* layer, size_t index)
322 BEGIN_BLOCK_OBJC_EXCEPTIONS
323 [m_layer.get() insertSublayer:layer->m_layer.get() atIndex:index];
324 END_BLOCK_OBJC_EXCEPTIONS
327 void PlatformCALayer::replaceSublayer(PlatformCALayer* reference, PlatformCALayer* layer)
329 BEGIN_BLOCK_OBJC_EXCEPTIONS
330 [m_layer.get() replaceSublayer:reference->m_layer.get() with:layer->m_layer.get()];
331 END_BLOCK_OBJC_EXCEPTIONS
334 size_t PlatformCALayer::sublayerCount() const
336 return [[m_layer.get() sublayers] count];
339 void PlatformCALayer::adoptSublayers(PlatformCALayer* source)
341 // Workaround for <rdar://problem/7390716>: -[CALayer setSublayers:] crashes if sublayers is an empty array, or nil, under GC.
342 NSArray* sublayers = [source->m_layer.get() sublayers];
344 if (objc_collectingEnabled() && ![sublayers count]) {
345 BEGIN_BLOCK_OBJC_EXCEPTIONS
346 while ([[m_layer.get() sublayers] count])
347 [[[m_layer.get() sublayers] objectAtIndex:0] removeFromSuperlayer];
348 END_BLOCK_OBJC_EXCEPTIONS
352 BEGIN_BLOCK_OBJC_EXCEPTIONS
353 [m_layer.get() setSublayers:sublayers];
354 END_BLOCK_OBJC_EXCEPTIONS
357 void PlatformCALayer::addAnimationForKey(const String& key, PlatformCAAnimation* animation)
361 WebAnimationDelegate* webAnimationDelegate = [[WebAnimationDelegate alloc] init];
362 m_delegate.adoptNS(webAnimationDelegate);
363 [webAnimationDelegate setOwner:this];
366 CAPropertyAnimation* propertyAnimation = static_cast<CAPropertyAnimation*>(animation->platformAnimation());
368 if (![propertyAnimation delegate])
369 [propertyAnimation setDelegate:static_cast<id>(m_delegate.get())];
371 BEGIN_BLOCK_OBJC_EXCEPTIONS
372 [m_layer.get() addAnimation:animation->m_animation.get() forKey:key];
373 END_BLOCK_OBJC_EXCEPTIONS
376 void PlatformCALayer::removeAnimationForKey(const String& key)
378 BEGIN_BLOCK_OBJC_EXCEPTIONS
379 [m_layer.get() removeAnimationForKey:key];
380 END_BLOCK_OBJC_EXCEPTIONS
383 PassRefPtr<PlatformCAAnimation> PlatformCALayer::animationForKey(const String& key)
385 CAPropertyAnimation* propertyAnimation = static_cast<CAPropertyAnimation*>([m_layer.get() animationForKey:key]);
386 if (!propertyAnimation)
388 return PlatformCAAnimation::create(propertyAnimation);
391 PlatformCALayer* PlatformCALayer::mask() const
393 return platformCALayer([m_layer.get() mask]);
396 void PlatformCALayer::setMask(PlatformCALayer* layer)
398 BEGIN_BLOCK_OBJC_EXCEPTIONS
399 [m_layer.get() setMask:layer ? layer->platformLayer() : 0];
400 END_BLOCK_OBJC_EXCEPTIONS
403 bool PlatformCALayer::isOpaque() const
405 return [m_layer.get() isOpaque];
408 void PlatformCALayer::setOpaque(bool value)
410 BEGIN_BLOCK_OBJC_EXCEPTIONS
411 [m_layer.get() setOpaque:value];
412 END_BLOCK_OBJC_EXCEPTIONS
415 FloatRect PlatformCALayer::bounds() const
417 return [m_layer.get() bounds];
420 void PlatformCALayer::setBounds(const FloatRect& value)
422 BEGIN_BLOCK_OBJC_EXCEPTIONS
423 [m_layer.get() setBounds:value];
424 END_BLOCK_OBJC_EXCEPTIONS
427 FloatPoint3D PlatformCALayer::position() const
429 CGPoint point = [m_layer.get() position];
430 return FloatPoint3D(point.x, point.y, [m_layer.get() zPosition]);
433 void PlatformCALayer::setPosition(const FloatPoint3D& value)
435 BEGIN_BLOCK_OBJC_EXCEPTIONS
436 [m_layer.get() setPosition:CGPointMake(value.x(), value.y())];
437 [m_layer.get() setZPosition:value.z()];
438 END_BLOCK_OBJC_EXCEPTIONS
441 FloatPoint3D PlatformCALayer::anchorPoint() const
443 CGPoint point = [m_layer.get() anchorPoint];
445 #if HAVE_MODERN_QUARTZCORE
446 z = [m_layer.get() anchorPointZ];
448 return FloatPoint3D(point.x, point.y, z);
451 void PlatformCALayer::setAnchorPoint(const FloatPoint3D& value)
453 BEGIN_BLOCK_OBJC_EXCEPTIONS
454 [m_layer.get() setAnchorPoint:CGPointMake(value.x(), value.y())];
455 #if HAVE_MODERN_QUARTZCORE
456 [m_layer.get() setAnchorPointZ:value.z()];
458 END_BLOCK_OBJC_EXCEPTIONS
461 TransformationMatrix PlatformCALayer::transform() const
463 return [m_layer.get() transform];
466 void PlatformCALayer::setTransform(const TransformationMatrix& value)
468 BEGIN_BLOCK_OBJC_EXCEPTIONS
469 [m_layer.get() setTransform:value];
470 END_BLOCK_OBJC_EXCEPTIONS
473 TransformationMatrix PlatformCALayer::sublayerTransform() const
475 return [m_layer.get() sublayerTransform];
478 void PlatformCALayer::setSublayerTransform(const TransformationMatrix& value)
480 BEGIN_BLOCK_OBJC_EXCEPTIONS
481 [m_layer.get() setSublayerTransform:value];
482 END_BLOCK_OBJC_EXCEPTIONS
485 TransformationMatrix PlatformCALayer::contentsTransform() const
487 #if !HAVE_MODERN_QUARTZCORE
488 if (m_layerType != LayerTypeWebLayer)
489 return TransformationMatrix();
491 return [static_cast<WebLayer*>(m_layer.get()) contentsTransform];
493 return TransformationMatrix();
497 void PlatformCALayer::setContentsTransform(const TransformationMatrix& value)
499 #if !HAVE_MODERN_QUARTZCORE
500 if (m_layerType != LayerTypeWebLayer)
503 BEGIN_BLOCK_OBJC_EXCEPTIONS
504 [m_layer.get() setContentsTransform:value];
505 END_BLOCK_OBJC_EXCEPTIONS
511 bool PlatformCALayer::isHidden() const
513 return [m_layer.get() isHidden];
516 void PlatformCALayer::setHidden(bool value)
518 BEGIN_BLOCK_OBJC_EXCEPTIONS
519 [m_layer.get() setHidden:value];
520 END_BLOCK_OBJC_EXCEPTIONS
523 bool PlatformCALayer::isGeometryFlipped() const
525 #if HAVE_MODERN_QUARTZCORE
526 return [m_layer.get() isGeometryFlipped];
532 void PlatformCALayer::setGeometryFlipped(bool value)
534 #if HAVE_MODERN_QUARTZCORE
535 BEGIN_BLOCK_OBJC_EXCEPTIONS
536 [m_layer.get() setGeometryFlipped:value];
537 END_BLOCK_OBJC_EXCEPTIONS
543 bool PlatformCALayer::isDoubleSided() const
545 return [m_layer.get() isDoubleSided];
548 void PlatformCALayer::setDoubleSided(bool value)
550 BEGIN_BLOCK_OBJC_EXCEPTIONS
551 [m_layer.get() setDoubleSided:value];
552 END_BLOCK_OBJC_EXCEPTIONS
555 bool PlatformCALayer::masksToBounds() const
557 return [m_layer.get() masksToBounds];
560 void PlatformCALayer::setMasksToBounds(bool value)
562 BEGIN_BLOCK_OBJC_EXCEPTIONS
563 [m_layer.get() setMasksToBounds:value];
564 END_BLOCK_OBJC_EXCEPTIONS
567 bool PlatformCALayer::acceleratesDrawing() const
569 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
570 return [m_layer.get() acceleratesDrawing];
576 void PlatformCALayer::setAcceleratesDrawing(bool acceleratesDrawing)
578 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
579 BEGIN_BLOCK_OBJC_EXCEPTIONS
580 [m_layer.get() setAcceleratesDrawing:acceleratesDrawing];
581 END_BLOCK_OBJC_EXCEPTIONS
583 UNUSED_PARAM(acceleratesDrawing);
587 CFTypeRef PlatformCALayer::contents() const
589 return [m_layer.get() contents];
592 void PlatformCALayer::setContents(CFTypeRef value)
594 BEGIN_BLOCK_OBJC_EXCEPTIONS
595 [m_layer.get() setContents:static_cast<id>(const_cast<void*>(value))];
596 END_BLOCK_OBJC_EXCEPTIONS
599 FloatRect PlatformCALayer::contentsRect() const
601 return [m_layer.get() contentsRect];
604 void PlatformCALayer::setContentsRect(const FloatRect& value)
606 BEGIN_BLOCK_OBJC_EXCEPTIONS
607 [m_layer.get() setContentsRect:value];
608 END_BLOCK_OBJC_EXCEPTIONS
611 void PlatformCALayer::setMinificationFilter(FilterType value)
613 #if HAVE_MODERN_QUARTZCORE
614 BEGIN_BLOCK_OBJC_EXCEPTIONS
615 [m_layer.get() setMinificationFilter:toCAFilterType(value)];
616 END_BLOCK_OBJC_EXCEPTIONS
622 void PlatformCALayer::setMagnificationFilter(FilterType value)
624 #if HAVE_MODERN_QUARTZCORE
625 BEGIN_BLOCK_OBJC_EXCEPTIONS
626 [m_layer.get() setMagnificationFilter:toCAFilterType(value)];
627 END_BLOCK_OBJC_EXCEPTIONS
633 Color PlatformCALayer::backgroundColor() const
635 return [m_layer.get() backgroundColor];
638 void PlatformCALayer::setBackgroundColor(const Color& value)
640 CGFloat components[4];
641 value.getRGBA(components[0], components[1], components[2], components[3]);
643 RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
644 RetainPtr<CGColorRef> color(AdoptCF, CGColorCreate(colorSpace.get(), components));
646 BEGIN_BLOCK_OBJC_EXCEPTIONS
647 [m_layer.get() setBackgroundColor:color.get()];
648 END_BLOCK_OBJC_EXCEPTIONS
651 float PlatformCALayer::borderWidth() const
653 return [m_layer.get() borderWidth];
656 void PlatformCALayer::setBorderWidth(float value)
658 BEGIN_BLOCK_OBJC_EXCEPTIONS
659 [m_layer.get() setBorderWidth:value];
660 END_BLOCK_OBJC_EXCEPTIONS
663 Color PlatformCALayer::borderColor() const
665 return [m_layer.get() borderColor];
668 void PlatformCALayer::setBorderColor(const Color& value)
670 CGFloat components[4];
671 value.getRGBA(components[0], components[1], components[2], components[3]);
673 RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
674 RetainPtr<CGColorRef> color(AdoptCF, CGColorCreate(colorSpace.get(), components));
676 BEGIN_BLOCK_OBJC_EXCEPTIONS
677 [m_layer.get() setBorderColor:color.get()];
678 END_BLOCK_OBJC_EXCEPTIONS
681 float PlatformCALayer::opacity() const
683 return [m_layer.get() opacity];
686 void PlatformCALayer::setOpacity(float value)
688 BEGIN_BLOCK_OBJC_EXCEPTIONS
689 [m_layer.get() setOpacity:value];
690 END_BLOCK_OBJC_EXCEPTIONS
693 String PlatformCALayer::name() const
695 return [m_layer.get() name];
698 void PlatformCALayer::setName(const String& value)
700 BEGIN_BLOCK_OBJC_EXCEPTIONS
701 [m_layer.get() setName:value];
702 END_BLOCK_OBJC_EXCEPTIONS
705 FloatRect PlatformCALayer::frame() const
707 return [m_layer.get() frame];
710 void PlatformCALayer::setFrame(const FloatRect& value)
712 BEGIN_BLOCK_OBJC_EXCEPTIONS
713 [m_layer.get() setFrame:value];
714 END_BLOCK_OBJC_EXCEPTIONS
717 float PlatformCALayer::speed() const
719 return [m_layer.get() speed];
722 void PlatformCALayer::setSpeed(float value)
724 BEGIN_BLOCK_OBJC_EXCEPTIONS
725 [m_layer.get() setSpeed:value];
726 END_BLOCK_OBJC_EXCEPTIONS
729 CFTimeInterval PlatformCALayer::timeOffset() const
731 return [m_layer.get() timeOffset];
734 void PlatformCALayer::setTimeOffset(CFTimeInterval value)
736 BEGIN_BLOCK_OBJC_EXCEPTIONS
737 [m_layer.get() setTimeOffset:value];
738 END_BLOCK_OBJC_EXCEPTIONS
741 float PlatformCALayer::contentsScale() const
743 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
744 return [m_layer.get() contentsScale];
750 void PlatformCALayer::setContentsScale(float value)
752 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
753 BEGIN_BLOCK_OBJC_EXCEPTIONS
754 [m_layer.get() setContentsScale:value];
755 END_BLOCK_OBJC_EXCEPTIONS
761 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
762 void PlatformCALayer::synchronouslyDisplayTilesInRect(const FloatRect& rect)
764 if (m_layerType != LayerTypeWebTiledLayer)
767 WebTiledLayer *tiledLayer = static_cast<WebTiledLayer*>(m_layer.get());
769 BEGIN_BLOCK_OBJC_EXCEPTIONS
770 BOOL oldCanDrawConcurrently = [tiledLayer canDrawConcurrently];
771 [tiledLayer setCanDrawConcurrently:NO];
772 [tiledLayer displayInRect:rect levelOfDetail:0 options:nil];
773 [tiledLayer setCanDrawConcurrently:oldCanDrawConcurrently];
774 END_BLOCK_OBJC_EXCEPTIONS
778 #endif // USE(ACCELERATED_COMPOSITING)