OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_GRAPHICS_2D_H_ | 5 #ifndef PPAPI_CPP_GRAPHICS_2D_H_ |
6 #define PPAPI_CPP_GRAPHICS_2D_H_ | 6 #define PPAPI_CPP_GRAPHICS_2D_H_ |
7 | 7 |
8 #include "ppapi/c/pp_stdint.h" | 8 #include "ppapi/c/pp_stdint.h" |
9 #include "ppapi/cpp/resource.h" | 9 #include "ppapi/cpp/resource.h" |
10 #include "ppapi/cpp/size.h" | 10 #include "ppapi/cpp/size.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 Graphics2D(const Graphics2D& other); | 34 Graphics2D(const Graphics2D& other); |
35 | 35 |
36 /// A constructor allocating a new 2D graphics context with the given size | 36 /// A constructor allocating a new 2D graphics context with the given size |
37 /// in the browser, resulting object will be is_null() if the allocation | 37 /// in the browser, resulting object will be is_null() if the allocation |
38 /// failed. | 38 /// failed. |
39 /// | 39 /// |
40 /// @param[in] instance The instance with which this resource will be | 40 /// @param[in] instance The instance with which this resource will be |
41 /// associated. | 41 /// associated. |
42 /// | 42 /// |
43 /// @param[in] size The size of the 2D graphics context in the browser, | 43 /// @param[in] size The size of the 2D graphics context in the browser, |
44 /// measured in device pixels. | 44 /// measured in device pixels. |
Josh Horwich
2013/03/29 20:54:23
I just noticed the use of "device pixels" here (an
dmichael (off chromium)
2013/04/04 17:16:00
Yes, that would probably be better. You might refe
Josh Horwich
2013/04/08 21:08:15
Done.
| |
45 /// | 45 /// |
46 /// @param[in] is_always_opaque Set the <code>is_always_opaque</code> flag | 46 /// @param[in] is_always_opaque Set the <code>is_always_opaque</code> flag |
47 /// to true if you know that you will be painting only opaque data to this | 47 /// to true if you know that you will be painting only opaque data to this |
48 /// context. This option will disable blending when compositing the module | 48 /// context. This option will disable blending when compositing the module |
49 /// with the web page, which might give higher performance on some computers. | 49 /// with the web page, which might give higher performance on some computers. |
50 /// | 50 /// |
51 /// If you set <code>is_always_opaque</code>, your alpha channel should | 51 /// If you set <code>is_always_opaque</code>, your alpha channel should |
52 /// always be set to 0xFF or there may be painting artifacts. The alpha values | 52 /// always be set to 0xFF or there may be painting artifacts. The alpha values |
53 /// overwrite the destination alpha values without blending when | 53 /// overwrite the destination alpha values without blending when |
54 /// <code>is_always_opaque</code> is true. | 54 /// <code>is_always_opaque</code> is true. |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 /// not issued its callback yet. In the failure case, nothing will be | 253 /// not issued its callback yet. In the failure case, nothing will be |
254 /// updated and no callback will be scheduled. | 254 /// updated and no callback will be scheduled. |
255 | 255 |
256 // TODO(darin): We should ensure that the completion callback always runs, so | 256 // TODO(darin): We should ensure that the completion callback always runs, so |
257 // that it is easier for consumers to manage memory referenced by a callback. | 257 // that it is easier for consumers to manage memory referenced by a callback. |
258 | 258 |
259 // TODO(): Add back in the synchronous mode description once we have support | 259 // TODO(): Add back in the synchronous mode description once we have support |
260 // for it. | 260 // for it. |
261 int32_t Flush(const CompletionCallback& cc); | 261 int32_t Flush(const CompletionCallback& cc); |
262 | 262 |
263 /// Returns true if SetScale and GetScale are supported. False if not. | |
264 static bool SupportsScale(); | |
dmichael (off chromium)
2013/03/28 21:38:29
Hmm, I don't think we usually have this kind of fu
Josh Horwich
2013/03/29 20:54:23
I originally was worried about cases where view di
| |
265 | |
266 /// SetScale() sets the scale factor that will be applied when painting the | |
267 /// graphics context onto the output device. Typically, if rendering at device | |
268 /// resolution is desired, the context would be created with the width and | |
269 /// height scaled up by the view's GetDeviceScale and SetScale called with a | |
270 /// scale of 1.0 / GetDeviceScale(). For example, if the view resource passed | |
271 /// to DidChangeView has a rectangle of (w=200, h=100) and a device scale of | |
272 /// 2.0, one would call Create with a size of (w=400, h=200) and then call | |
273 /// SetScale with 0.5. One would then treat each pixel in the context as a | |
274 /// single device pixel. | |
275 /// | |
276 /// @param[in] scale The scale to apply when painting. | |
277 /// | |
278 /// @return Returns <code>true</code> on success or <code>false</code> | |
279 /// if the resource is invalid or the scale factor is 0 or less. | |
280 bool SetScale(float scale); | |
281 | |
282 /// GetScale() gets the scale factor that will be applied when painting the | |
283 /// graphics context onto the output device. | |
284 /// | |
285 /// @return Returns the scale factor for the graphics context. If the resource | |
286 /// is invalid, 0.0 will be returned. | |
287 float GetScale(); | |
dmichael (off chromium)
2013/03/28 21:38:29
It would be good to mention somewhere that the def
Josh Horwich
2013/03/29 20:54:23
Done.
| |
288 | |
263 private: | 289 private: |
264 Size size_; | 290 Size size_; |
265 }; | 291 }; |
266 | 292 |
267 } // namespace pp | 293 } // namespace pp |
268 | 294 |
269 #endif // PPAPI_CPP_GRAPHICS_2D_H_ | 295 #endif // PPAPI_CPP_GRAPHICS_2D_H_ |
OLD | NEW |