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 242 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 /// SetScale() sets the scale factor that will be applied when painting the |
| 264 /// graphics context onto the output device. Typically, if rendering at device |
| 265 /// resolution is desired, the context would be created with the width and |
| 266 /// height scaled up by the view's GetDeviceScale and SetScale called with a |
| 267 /// scale of 1.0 / GetDeviceScale(). For example, if the view resource passed |
| 268 /// to DidChangeView has a rectangle of (w=200, h=100) and a device scale of |
| 269 /// 2.0, one would call Create with a size of (w=400, h=200) and then call |
| 270 /// SetScale with 0.5. One would then treat each pixel in the context as a |
| 271 /// single device pixel. |
| 272 /// |
| 273 /// @param[in] scale The scale to apply when painting. |
| 274 /// |
| 275 /// @return Returns <code>true</code> on success or <code>false</code> |
| 276 /// if the resource is invalid or the scale factor is 0 or less. |
| 277 bool SetScale(float scale); |
| 278 |
| 279 /// GetScale() gets the scale factor that will be applied when painting the |
| 280 /// graphics context onto the output device. |
| 281 /// |
| 282 /// @return Returns the scale factor for the graphics context. If the resource |
| 283 /// is invalid, 0.0 will be returned. The default scale for a graphics context |
| 284 /// is 1.0. |
| 285 float GetScale(); |
| 286 |
263 private: | 287 private: |
264 Size size_; | 288 Size size_; |
265 }; | 289 }; |
266 | 290 |
267 } // namespace pp | 291 } // namespace pp |
268 | 292 |
269 #endif // PPAPI_CPP_GRAPHICS_2D_H_ | 293 #endif // PPAPI_CPP_GRAPHICS_2D_H_ |
OLD | NEW |