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

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

Issue 6255003: O2D:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 9 years, 11 months 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
« no previous file with comments | « no previous file | core/cross/cairo/layer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 namespace o3d { 43 namespace o3d {
44 44
45 class IClassManager; 45 class IClassManager;
46 46
47 namespace o2d { 47 namespace o2d {
48 48
49 class Layer : public ObjectBase { 49 class Layer : public ObjectBase {
50 public: 50 public:
51 typedef SmartPointer<Layer> Ref; 51 typedef SmartPointer<Layer> Ref;
52 52
53 enum PaintOperator {
54 BLEND,
55 BLEND_WITH_TRANSPARENCY,
56 COPY,
57 COPY_WITH_FADING,
58 };
59
53 virtual ~Layer(); 60 virtual ~Layer();
54 61
62 // Methods exposed to JS.
63
55 Pattern* pattern() const { 64 Pattern* pattern() const {
56 return pattern_; 65 return pattern_;
57 } 66 }
58 67
59 void set_pattern(Pattern* pattern) { 68 void set_pattern(Pattern* pattern) {
60 pattern_ = Pattern::Ref(pattern); 69 pattern_ = Pattern::Ref(pattern);
61 } 70 }
62 71
72 bool visible() const {
73 return visible_;
74 }
75
76 void set_visible(bool visible) {
77 visible_ = visible;
78 }
79
63 double alpha() const { 80 double alpha() const {
64 return alpha_; 81 return alpha_;
65 } 82 }
66 83
67 void set_alpha(double alpha) { 84 void set_alpha(double alpha) {
68 alpha_ = alpha; 85 alpha_ = alpha;
69 } 86 }
70 87
71 double x() const { 88 double x() const {
72 return x_; 89 return x_;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 134 }
118 135
119 double scale_y() const { 136 double scale_y() const {
120 return scale_y_; 137 return scale_y_;
121 } 138 }
122 139
123 void set_scale_y(double scale_y) { 140 void set_scale_y(double scale_y) {
124 scale_y_ = scale_y; 141 scale_y_ = scale_y;
125 } 142 }
126 143
144 PaintOperator paint_operator() const {
145 return paint_operator_;
146 }
147
148 void set_paint_operator(PaintOperator paint_operator) {
149 paint_operator_ = paint_operator;
150 }
151
152 // Methods not exposed to JS.
153
154 // Whether we should currently paint this layer.
155 bool ShouldPaint() const {
156 return visible() && pattern() != NULL;
157 }
158
159 // Whether this layer should currently clip content behind it (i.e.,
160 // prevent it from being drawn in the first place).
161 bool ShouldClip() const {
162 // When alpha blending is used we cannot clip the background because our
163 // content will be blended with it.
164 return ShouldPaint() &&
165 (paint_operator() == COPY || paint_operator() == COPY_WITH_FADING);
166 }
167
127 private: 168 private:
128 explicit Layer(ServiceLocator* service_locator); 169 explicit Layer(ServiceLocator* service_locator);
129 170
130 friend class o3d::IClassManager; 171 friend class o3d::IClassManager;
131 static ObjectBase::Ref Create(ServiceLocator* service_locator); 172 static ObjectBase::Ref Create(ServiceLocator* service_locator);
132 173
133 // The pattern used to paint this Layer. 174 // The pattern used to paint this Layer.
134 Pattern::Ref pattern_; 175 Pattern::Ref pattern_;
135 176
136 // Transparancy of this layer. 177 // Whether this layer should be visible or not.
178 bool visible_;
179
180 // The transparency for the BLEND_WITH_TRANSPARENCY operator or the fading for
181 // the COPY_WITH_FADING operator.
137 double alpha_; 182 double alpha_;
138 183
139 // The x coordinate of the top-left corner of this layer. 184 // The x coordinate of the top-left corner of this layer.
140 double x_; 185 double x_;
141 186
142 // The y coordinate of the top-left corner of this layer. 187 // The y coordinate of the top-left corner of this layer.
143 double y_; 188 double y_;
144 189
145 // The z coordinate of the layer (used only to determine stacking order). 190 // The z coordinate of the layer (used only to determine stacking order).
146 double z_; 191 double z_;
147 192
148 // The width of this layer. 193 // The width of this layer.
149 double width_; 194 double width_;
150 195
151 // The height of this layer. 196 // The height of this layer.
152 double height_; 197 double height_;
153 198
154 // A scaling factor to apply to the pattern's x-axis. 199 // A scaling factor to apply to the pattern's x-axis.
155 double scale_x_; 200 double scale_x_;
156 201
157 // A scaling factor to apply to the pattern's y-axis. 202 // A scaling factor to apply to the pattern's y-axis.
158 double scale_y_; 203 double scale_y_;
159 204
205 // The paint operator to use for painting this Layer.
206 PaintOperator paint_operator_;
207
160 O3D_DECL_CLASS(Layer, ObjectBase) 208 O3D_DECL_CLASS(Layer, ObjectBase)
161 }; // Layer 209 }; // Layer
162 210
163 } // namespace o2d 211 } // namespace o2d
164 212
165 } // namespace o3d 213 } // namespace o3d
166 214
167 #endif // O3D_CORE_CROSS_CAIRO_LAYER_H_ 215 #endif // O3D_CORE_CROSS_CAIRO_LAYER_H_
OLDNEW
« no previous file with comments | « no previous file | core/cross/cairo/layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698