| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WINDOW_MANAGER_UTIL_H_ | 5 #ifndef WINDOW_MANAGER_UTIL_H_ |
| 6 #define WINDOW_MANAGER_UTIL_H_ | 6 #define WINDOW_MANAGER_UTIL_H_ |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <ctime> | 9 #include <ctime> |
| 10 #include <list> | 10 #include <list> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/hash_tables.h" | 15 #include "base/hash_tables.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/time.h" | 17 #include "base/time.h" |
| 18 #include "window_manager/geometry.h" |
| 18 | 19 |
| 19 namespace window_manager { | 20 namespace window_manager { |
| 20 | 21 |
| 21 // Stacker maintains an ordering of objects (e.g. windows) in which changes | 22 // Stacker maintains an ordering of objects (e.g. windows) in which changes |
| 22 // can be made in faster-than-linear time. | 23 // can be made in faster-than-linear time. |
| 23 template<class T> | 24 template<class T> |
| 24 class Stacker { | 25 class Stacker { |
| 25 public: | 26 public: |
| 26 Stacker() {} | 27 Stacker() {} |
| 27 | 28 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // Index into |items_|. | 145 // Index into |items_|. |
| 145 IteratorMap index_; | 146 IteratorMap index_; |
| 146 | 147 |
| 147 DISALLOW_COPY_AND_ASSIGN(Stacker); | 148 DISALLOW_COPY_AND_ASSIGN(Stacker); |
| 148 }; | 149 }; |
| 149 | 150 |
| 150 | 151 |
| 151 // ByteMap unions rectangles into a 2-D array of bytes. That's it. :-P | 152 // ByteMap unions rectangles into a 2-D array of bytes. That's it. :-P |
| 152 class ByteMap { | 153 class ByteMap { |
| 153 public: | 154 public: |
| 154 ByteMap(int width, int height); | 155 ByteMap(const Size& size); |
| 155 ~ByteMap(); | 156 ~ByteMap(); |
| 156 | 157 |
| 157 int width() const { return width_; } | 158 const Size& size() const { return size_; } |
| 158 int height() const { return height_; } | |
| 159 const unsigned char* bytes() const { return bytes_; } | 159 const unsigned char* bytes() const { return bytes_; } |
| 160 | 160 |
| 161 // Copy the bytes from |other|, which must have the same dimensions as | 161 // Copy the bytes from |other|, which must have the same dimensions as |
| 162 // this map. | 162 // this map. |
| 163 void Copy(const ByteMap& other); | 163 void Copy(const ByteMap& other); |
| 164 | 164 |
| 165 // Set every byte to |value|. | 165 // Set every byte to |value|. |
| 166 void Clear(unsigned char value); | 166 void Clear(unsigned char value); |
| 167 | 167 |
| 168 // Set the bytes covered by the passed-in rectangle. | 168 // Set the bytes covered by the passed-in rectangle. |
| 169 void SetRectangle(int rect_x, int rect_y, | 169 void SetRectangle(const Rect& rect, unsigned char value); |
| 170 int rect_width, int rect_height, | |
| 171 unsigned char value); | |
| 172 | 170 |
| 173 // Check if the bytes from |other| match the bytes from this. | 171 // Check if the bytes from |other| match the bytes from this. |
| 174 bool operator==(const ByteMap& other); | 172 bool operator==(const ByteMap& other); |
| 175 | 173 |
| 176 private: | 174 private: |
| 177 int width_; | 175 Size size_; |
| 178 int height_; | |
| 179 unsigned char* bytes_; | 176 unsigned char* bytes_; |
| 180 | 177 |
| 181 DISALLOW_COPY_AND_ASSIGN(ByteMap); | 178 DISALLOW_COPY_AND_ASSIGN(ByteMap); |
| 182 }; | 179 }; |
| 183 | 180 |
| 184 | 181 |
| 185 // Sets a variable to a value within a particular scope and resets it when | 182 // Sets a variable to a value within a particular scope and resets it when |
| 186 // the scope is exited. | 183 // the scope is exited. |
| 187 // TODO: This is just a templatized version of Chrome's base/auto_reset.h. | 184 // TODO: This is just a templatized version of Chrome's base/auto_reset.h. |
| 188 // Use that instead when/if it's templatized. | 185 // Use that instead when/if it's templatized. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 // | 286 // |
| 290 // The argument is not a reference because the callback code that we're | 287 // The argument is not a reference because the callback code that we're |
| 291 // using from protobuf has trouble with references. | 288 // using from protobuf has trouble with references. |
| 292 void RunCommandInBackground(std::string command); | 289 void RunCommandInBackground(std::string command); |
| 293 | 290 |
| 294 } // namespace util | 291 } // namespace util |
| 295 | 292 |
| 296 } // namespace window_manager | 293 } // namespace window_manager |
| 297 | 294 |
| 298 #endif // WINDOW_MANAGER_UTIL_H_ | 295 #endif // WINDOW_MANAGER_UTIL_H_ |
| OLD | NEW |