1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * Copyright (C) 2010 Apple Inc. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include "PluginObject.h"
33 #include <QuartzCore/QuartzCore.h>
35 @interface TestPluginLayer : CALayer
38 @implementation TestPluginLayer
40 - (void)drawInContext:(CGContextRef)context
42 CGRect bounds = [self bounds];
43 const char* text = "Test Plug-in";
44 CGContextSelectFont(context, "Helvetica", 24, kCGEncodingMacRoman);
45 CGContextShowTextAtPoint(context,
46 bounds.origin.x + 3.0f,
47 bounds.origin.y + bounds.size.height - 30.0f,
54 void* createCoreAnimationLayer()
56 CALayer *caLayer = [[TestPluginLayer alloc] init];
58 NSNull *nullValue = [NSNull null];
59 NSDictionary *actions = [NSDictionary dictionaryWithObjectsAndKeys:
60 nullValue, @"anchorPoint",
62 nullValue, @"contents",
63 nullValue, @"contentsRect",
64 nullValue, @"opacity",
65 nullValue, @"position",
66 nullValue, @"shadowColor",
67 nullValue, @"sublayerTransform",
68 nullValue, @"sublayers",
69 nullValue, @"transform",
70 nullValue, @"zPosition",
72 // Turn off default animations.
74 setStyle:[NSDictionary dictionaryWithObject:actions forKey:@"actions"]];
75 [caLayer setNeedsDisplayOnBoundsChange:YES];
77 [caLayer setBounds:CGRectMake(0, 0, 200, 100)];
78 [caLayer setAnchorPoint:CGPointZero];
80 CGColorRef color = CGColorCreateGenericRGB(0.5, 0.5, 1, 1);
81 [caLayer setBackgroundColor:color];
82 CGColorRelease(color);
84 [caLayer setLayoutManager:[CAConstraintLayoutManager layoutManager]];
86 CALayer *sublayer = [CALayer layer];
87 // Turn off default animations.
89 setStyle:[NSDictionary dictionaryWithObject:actions forKey:@"actions"]];
91 color = CGColorCreateGenericRGB(0, 0, 0, 0.75);
92 [sublayer setBackgroundColor:color];
93 CGColorRelease(color);
94 [sublayer setBounds:CGRectMake(0, 0, 180, 20)];
97 addConstraint:[CAConstraint constraintWithAttribute:kCAConstraintMinY
98 relativeTo:@"superlayer"
99 attribute:kCAConstraintMinY]];
101 addConstraint:[CAConstraint constraintWithAttribute:kCAConstraintMinX
102 relativeTo:@"superlayer"
103 attribute:kCAConstraintMinX]];
105 addConstraint:[CAConstraint constraintWithAttribute:kCAConstraintMaxX
106 relativeTo:@"superlayer"
107 attribute:kCAConstraintMaxX]];
109 [caLayer addSublayer:sublayer];