Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: core/cross/cairo/layer.h

Issue 5276006: O2D:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2010, Google Inc. 2 * Copyright 2010, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 11 matching lines...) Expand all
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32 // An alternative class of Transform for 2d Image Rendering Mode. 32 // A Layer is a rectangular region of the O2D canvas to be filled with a
33 // particular Pattern, with automatic clipping based on stacking order.
33 34
34 #ifndef O3D_CORE_CROSS_CAIRO_LAYER_H_ 35 #ifndef O3D_CORE_CROSS_CAIRO_LAYER_H_
35 #define O3D_CORE_CROSS_CAIRO_LAYER_H_ 36 #define O3D_CORE_CROSS_CAIRO_LAYER_H_
36 37
37 #include <vector> 38 #include <vector>
38 #include "core/cross/bounding_box.h" 39
39 #include "core/cross/param.h" 40 #include "core/cross/object_base.h"
40 #include "core/cross/param_cache.h" 41 #include "core/cross/cairo/pattern.h"
41 #include "core/cross/param_object.h"
42 #include "core/cross/types.h"
43 #include "core/cross/cairo/texture_cairo.h"
44 42
45 namespace o3d { 43 namespace o3d {
46 44
45 class IClassManager;
46
47 namespace o2d { 47 namespace o2d {
48 48
49 class Layer : public ParamObject { 49 class Layer : public ObjectBase {
50 friend class Client;
51 public: 50 public:
52 typedef SmartPointer<Layer> Ref; 51 typedef SmartPointer<Layer> Ref;
53 52
54 // Set the corresponding texture for this Layer instance. 53 Pattern* pattern() const {
55 void SetTexture(Texture* texture) { 54 return pattern_;
56 texture_ = TextureCairo::Ref(down_cast<TextureCairo*>(texture));
57 } 55 }
58 56
59 TextureCairo* GetTexture() { 57 void set_pattern(Pattern* pattern) {
60 return texture_; 58 pattern_ = Pattern::Ref(pattern);
61 } 59 }
62 60
63 float GetAlpha() { 61 double alpha() const {
64 return alpha_; 62 return alpha_;
65 } 63 }
66 64
67 float GetScaleX() { 65 void set_alpha(double alpha) {
66 alpha_ = alpha;
67 }
68
69 double x() const {
70 return x_;
71 }
72
73 void set_x(double x) {
74 x_ = x;
75 }
76
77 double y() const {
78 return y_;
79 }
80
81 void set_y(double y) {
82 y_ = y;
83 }
84
85 double width() const {
86 return width_;
87 }
88
89 void set_width(double width) {
90 width_ = width;
91 }
92
93 double height() const {
94 return height_;
95 }
96
97 void set_height(double height) {
98 height_ = height;
99 }
100
101 double scale_x() const {
68 return scale_x_; 102 return scale_x_;
69 } 103 }
70 104
71 float GetScaleY() { 105 void set_scale_x(double scale_x) {
106 scale_x_ = scale_x;
107 }
108
109 double scale_y() const {
72 return scale_y_; 110 return scale_y_;
73 } 111 }
74 112
75 int GetTranslateX() { 113 void set_scale_y(double scale_y) {
76 return translate_x_; 114 scale_y_ = scale_y;
zhurunz 2010/11/24 01:11:38 Consider using some macro here for those get/set f
Tristan Schmelcher 2 2010/11/24 20:00:55 I expect several of them to diverge in the future,
77 }
78
79 int GetTranslateY() {
80 return translate_y_;
81 }
82
83 // Set the transparency of the Layer.
84 void SetAlpha(float alpha) { alpha_ = alpha; }
85
86 // Translate the given x,y from its origin.
87 void Translate(float x, float y) {
88 translate_x_ = x;
89 translate_y_ = y;
90 }
91
92 // Scale the image to the given x,y.
93 void Scale(float x, float y) {
94 scale_x_ = x;
95 scale_y_ = y;
96 } 115 }
97 116
98 private: 117 private:
99 explicit Layer(ServiceLocator* service_locator); 118 explicit Layer(ServiceLocator* service_locator);
100 119
101 friend class o3d::IClassManager; 120 friend class o3d::IClassManager;
102 static ObjectBase::Ref Create(ServiceLocator* service_locator); 121 static ObjectBase::Ref Create(ServiceLocator* service_locator);
103 122
104 // Texture Container. 123 // The pattern used to paint this Layer.
105 TextureCairo::Ref texture_; 124 Pattern::Ref pattern_;
106 125
107 // Transparancy of the scene. 126 // Transparancy of this layer.
108 float alpha_; 127 double alpha_;
109 128
110 // The end-x-size of which the current size needs to scale. 129 // The x coordinate of the top-left corner of this layer.
111 float scale_x_; 130 double x_;
112 131
113 // The end-y-size of which the current size needs to scale. 132 // The y coordinate of the top-left corner of this layer.
114 float scale_y_; 133 double y_;
115 134
116 // Size of x to translate. 135 // The width of this layer.
117 float translate_x_; 136 double width_;
118 137
119 // Size of y to translate. 138 // The height of this layer.
120 float translate_y_; 139 double height_;
121 140
122 O3D_DECL_CLASS(Layer, ParamObject) 141 // A scaling factor to apply to the pattern's x-axis.
142 double scale_x_;
143
144 // A scaling factor to apply to the pattern's y-axis.
145 double scale_y_;
146
147 O3D_DECL_CLASS(Layer, ObjectBase)
123 }; // Layer 148 }; // Layer
124 149
125 } // namespace o2d 150 } // namespace o2d
126 151
127 } // namespace o3d 152 } // namespace o3d
128 153
129 #endif // O3D_CORE_CROSS_CAIRO_LAYER_H_ 154 #endif // O3D_CORE_CROSS_CAIRO_LAYER_H_
OLDNEW
« no previous file with comments | « core/core.gyp ('k') | core/cross/cairo/layer.cc » ('j') | core/cross/cairo/pattern.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698