OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium 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 PPAPI_CPP_IMAGE_DATA_H_ | 5 #ifndef PPAPI_CPP_IMAGE_DATA_H_ |
6 #define PPAPI_CPP_IMAGE_DATA_H_ | 6 #define PPAPI_CPP_IMAGE_DATA_H_ |
7 | 7 |
8 #include "ppapi/c/ppb_image_data.h" | 8 #include "ppapi/c/ppb_image_data.h" |
9 #include "ppapi/cpp/point.h" | 9 #include "ppapi/cpp/point.h" |
10 #include "ppapi/cpp/size.h" | 10 #include "ppapi/cpp/size.h" |
11 #include "ppapi/cpp/resource.h" | 11 #include "ppapi/cpp/resource.h" |
12 | 12 |
13 | |
14 /// @file | 13 /// @file |
15 /// This file defines the APIs for determining how a browser | 14 /// This file defines the APIs for determining how a browser |
16 /// handles image data. | 15 /// handles image data. |
17 namespace pp { | 16 namespace pp { |
18 | 17 |
19 class Instance; | 18 class InstanceHandle; |
20 | 19 |
21 class ImageData : public Resource { | 20 class ImageData : public Resource { |
22 public: | 21 public: |
23 /// Default constructor for creating an is_null() <code>ImageData</code> | 22 /// Default constructor for creating an is_null() <code>ImageData</code> |
24 /// object. | 23 /// object. |
25 ImageData(); | 24 ImageData(); |
26 | 25 |
27 /// A special structure used by the constructor that does not increment the | |
28 /// reference count of the underlying Image resource. | |
29 struct PassRef {}; | |
30 | |
31 /// A constructor used when you have received a <code>PP_Resource</code> as a | 26 /// A constructor used when you have received a <code>PP_Resource</code> as a |
32 /// return value that has already been reference counted. | 27 /// return value that has already been reference counted. |
33 /// | 28 /// |
34 /// @param[in] resource A PP_Resource corresponding to image data. | 29 /// @param[in] resource A PP_Resource corresponding to image data. |
35 ImageData(PassRef, PP_Resource resource); | 30 ImageData(PassRef, PP_Resource resource); |
36 | 31 |
37 /// The copy constructor for <code>ImageData</code>. This constructor | 32 /// The copy constructor for <code>ImageData</code>. This constructor |
38 /// produces an <code>ImageData</code> object that shares the underlying | 33 /// produces an <code>ImageData</code> object that shares the underlying |
39 /// <code>Image</code> resource with <code>other</code>. | 34 /// <code>Image</code> resource with <code>other</code>. |
40 /// | 35 /// |
41 /// @param[in] other A pointer to an image data. | 36 /// @param[in] other A pointer to an image data. |
42 ImageData(const ImageData& other); | 37 ImageData(const ImageData& other); |
43 | 38 |
44 /// A constructor that allocates a new <code>ImageData</code> in the browser | 39 /// A constructor that allocates a new <code>ImageData</code> in the browser |
45 /// with the provided parameters. The resulting object will be is_null() if | 40 /// with the provided parameters. The resulting object will be is_null() if |
46 /// the allocation failed. | 41 /// the allocation failed. |
47 /// | 42 /// |
48 /// @param[in] instance A <code>PP_Instance</code> identifying one instance | 43 /// @param[in] instance The instance with which this resource will be |
49 /// of a module. | 44 /// associated. |
50 /// | 45 /// |
51 /// @param[in] format A PP_ImageDataFormat containing desired image format. | 46 /// @param[in] format A PP_ImageDataFormat containing desired image format. |
52 /// PP_ImageDataFormat is an enumeration of the different types of | 47 /// PP_ImageDataFormat is an enumeration of the different types of |
53 /// image data formats. Refer to | 48 /// image data formats. Refer to |
54 /// <a href="../pepperc/ppb__image__data_8h.html"> | 49 /// <a href="../pepperc/ppb__image__data_8h.html"> |
55 /// <code>ppb_image_data.h</code></a> for further information. | 50 /// <code>ppb_image_data.h</code></a> for further information. |
56 /// | 51 /// |
57 /// @param[in] size A pointer to a <code>Size</code> containing the image | 52 /// @param[in] size A pointer to a <code>Size</code> containing the image |
58 /// size. | 53 /// size. |
59 /// | 54 /// |
60 /// @param[in] init_to_zero A bool used to determine transparency at | 55 /// @param[in] init_to_zero A bool used to determine transparency at |
61 /// creation. Set the <code>init_to_zero</code> flag if you want the bitmap | 56 /// creation. Set the <code>init_to_zero</code> flag if you want the bitmap |
62 /// initialized to transparent during the creation process. If this flag is | 57 /// initialized to transparent during the creation process. If this flag is |
63 /// not set, the current contents of the bitmap will be undefined, and the | 58 /// not set, the current contents of the bitmap will be undefined, and the |
64 /// module should be sure to set all the pixels. | 59 /// module should be sure to set all the pixels. |
65 ImageData(Instance* instance, | 60 ImageData(const InstanceHandle& instance, |
66 PP_ImageDataFormat format, | 61 PP_ImageDataFormat format, |
67 const Size& size, | 62 const Size& size, |
68 bool init_to_zero); | 63 bool init_to_zero); |
69 | 64 |
70 /// This function decrements the reference count of this | 65 /// This function decrements the reference count of this |
71 /// <code>ImageData</code> and increments the reference count of the | 66 /// <code>ImageData</code> and increments the reference count of the |
72 /// <code>other</code> <code>ImageData</code>. This <code>ImageData</code> | 67 /// <code>other</code> <code>ImageData</code>. This <code>ImageData</code> |
73 /// shares the underlying image resource with <code>other</code>. | 68 /// shares the underlying image resource with <code>other</code>. |
74 /// | 69 /// |
75 /// @param[in] other An other image data. | 70 /// @param[in] other An other image data. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 /// This function is used retrieve the address of the given pixel for 32-bit | 111 /// This function is used retrieve the address of the given pixel for 32-bit |
117 /// pixel formats. | 112 /// pixel formats. |
118 /// | 113 /// |
119 /// @param[in] coord A <code>Point</code> representing the x and y | 114 /// @param[in] coord A <code>Point</code> representing the x and y |
120 /// coordinates for a specific pixel. | 115 /// coordinates for a specific pixel. |
121 /// | 116 /// |
122 /// @return The address for the pixel. | 117 /// @return The address for the pixel. |
123 uint32_t* GetAddr32(const Point& coord); | 118 uint32_t* GetAddr32(const Point& coord); |
124 | 119 |
125 private: | 120 private: |
126 void PassRefAndInitData(PP_Resource resource); | 121 void InitData(); |
127 | 122 |
128 PP_ImageDataDesc desc_; | 123 PP_ImageDataDesc desc_; |
129 void* data_; | 124 void* data_; |
130 }; | 125 }; |
131 | 126 |
132 } // namespace pp | 127 } // namespace pp |
133 | 128 |
134 #endif // PPAPI_CPP_IMAGE_DATA_H_ | 129 #endif // PPAPI_CPP_IMAGE_DATA_H_ |
OLD | NEW |