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_IMAGE_CONTAINER_H_ | 5 #ifndef WINDOW_MANAGER_IMAGE_CONTAINER_H_ |
6 #define WINDOW_MANAGER_IMAGE_CONTAINER_H_ | 6 #define WINDOW_MANAGER_IMAGE_CONTAINER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "window_manager/geometry.h" | |
13 #include "window_manager/image_enums.h" | 14 #include "window_manager/image_enums.h" |
14 | 15 |
15 namespace window_manager { | 16 namespace window_manager { |
16 | 17 |
17 // This base class contains image data. Given a filename, it's able to | 18 // This base class contains image data. Given a filename, it's able to |
18 // infer its type and construct an appropriate container object. | 19 // infer its type and construct an appropriate container object. |
19 class ImageContainer { | 20 class ImageContainer { |
20 public: | 21 public: |
21 enum Result { | 22 enum Result { |
22 IMAGE_LOAD_SUCCESS = 0, | 23 IMAGE_LOAD_SUCCESS = 0, |
(...skipping 10 matching lines...) Expand all Loading... | |
33 | 34 |
34 ImageContainer(); | 35 ImageContainer(); |
35 virtual ~ImageContainer() { SetData(NULL, false); } | 36 virtual ~ImageContainer() { SetData(NULL, false); } |
36 | 37 |
37 // Loads the image, and returns a result code. | 38 // Loads the image, and returns a result code. |
38 virtual Result LoadImage() = 0; | 39 virtual Result LoadImage() = 0; |
39 | 40 |
40 uint8_t* data() const { return data_; } | 41 uint8_t* data() const { return data_; } |
41 size_t width() const { return width_; } | 42 size_t width() const { return width_; } |
42 size_t height() const { return height_; } | 43 size_t height() const { return height_; } |
44 Size GetSize() const { return Size(width_,height_); } | |
Daniel Erat
2011/04/04 21:16:35
nit: just name this size() (some of the other code
marcheu
2011/04/05 00:23:40
Done.
| |
43 | 45 |
44 // Return stride in bytes of a row of pixels in the image data. | 46 // Return stride in bytes of a row of pixels in the image data. |
45 size_t stride() const { | 47 size_t stride() const { |
46 return bits_per_pixel() * width() / 8; | 48 return bits_per_pixel() * width() / 8; |
47 } | 49 } |
48 | 50 |
49 // The number of bits per pixel in the image. | 51 // The number of bits per pixel in the image. |
50 int bits_per_pixel() const { return GetBitsPerPixelInImageFormat(format_); } | 52 int bits_per_pixel() const { return GetBitsPerPixelInImageFormat(format_); } |
51 | 53 |
52 // Currently, this class only supports 32-bit formats as well as 16-bit RGB. | 54 // Currently, this class only supports 32-bit formats as well as 16-bit RGB. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 // This doesn't need to be called. | 121 // This doesn't need to be called. |
120 virtual Result LoadImage() { return IMAGE_LOAD_SUCCESS; } | 122 virtual Result LoadImage() { return IMAGE_LOAD_SUCCESS; } |
121 | 123 |
122 private: | 124 private: |
123 DISALLOW_COPY_AND_ASSIGN(InMemoryImageContainer); | 125 DISALLOW_COPY_AND_ASSIGN(InMemoryImageContainer); |
124 }; | 126 }; |
125 | 127 |
126 } // namespace window_manager | 128 } // namespace window_manager |
127 | 129 |
128 #endif // WINDOW_MANAGER_IMAGE_CONTAINER_H_ | 130 #endif // WINDOW_MANAGER_IMAGE_CONTAINER_H_ |
OLD | NEW |