OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_C_DEV_PPB_TESTING_DEV_H_ | 5 #ifndef PPAPI_C_DEV_PPB_TESTING_DEV_H_ |
6 #define PPAPI_C_DEV_PPB_TESTING_DEV_H_ | 6 #define PPAPI_C_DEV_PPB_TESTING_DEV_H_ |
7 | 7 |
| 8 #include "ppapi/c/pp_bool.h" |
8 #include "ppapi/c/pp_module.h" | 9 #include "ppapi/c/pp_module.h" |
9 #include "ppapi/c/pp_resource.h" | 10 #include "ppapi/c/pp_resource.h" |
10 #include "ppapi/c/pp_stdint.h" | 11 #include "ppapi/c/pp_stdint.h" |
11 | 12 |
12 struct PP_Point; | 13 struct PP_Point; |
13 | 14 |
14 #define PPB_TESTING_DEV_INTERFACE "PPB_Testing(Dev);0.2" | 15 #define PPB_TESTING_DEV_INTERFACE "PPB_Testing(Dev);0.3" |
15 | 16 |
16 // This interface contains functions used for unit testing. Do not use in | 17 // This interface contains functions used for unit testing. Do not use in |
17 // production code. They are not guaranteed to be available in normal plugin | 18 // production code. They are not guaranteed to be available in normal plugin |
18 // environments so you should not depend on them. | 19 // environments so you should not depend on them. |
19 struct PPB_Testing_Dev { | 20 struct PPB_Testing_Dev { |
20 // Reads the bitmap data out of the backing store for the given | 21 // Reads the bitmap data out of the backing store for the given |
21 // DeviceContext2D and into the given image. If the data was successfully | 22 // DeviceContext2D and into the given image. If the data was successfully |
22 // read, it will return true. | 23 // read, it will return PP_TRUE. |
23 // | 24 // |
24 // This function should not generally be necessary for normal plugin | 25 // This function should not generally be necessary for normal plugin |
25 // operation. If you want to update portions of a device, the expectation is | 26 // operation. If you want to update portions of a device, the expectation is |
26 // that you will either regenerate the data, or maintain a backing store | 27 // that you will either regenerate the data, or maintain a backing store |
27 // pushing updates to the device from your backing store via PaintImageData. | 28 // pushing updates to the device from your backing store via PaintImageData. |
28 // Using this function will introduce an extra copy which will make your | 29 // Using this function will introduce an extra copy which will make your |
29 // plugin slower. In some cases, this may be a very expensive operation (it | 30 // plugin slower. In some cases, this may be a very expensive operation (it |
30 // may require slow cross-process transitions or graphics card readbacks). | 31 // may require slow cross-process transitions or graphics card readbacks). |
31 // | 32 // |
32 // Data will be read into the image starting at |top_left| in the device | 33 // Data will be read into the image starting at |top_left| in the device |
33 // context, and proceeding down and to the right for as many pixels as the | 34 // context, and proceeding down and to the right for as many pixels as the |
34 // image is large. If any part of the image bound would fall outside of the | 35 // image is large. If any part of the image bound would fall outside of the |
35 // backing store of the device if positioned at |top_left|, this function | 36 // backing store of the device if positioned at |top_left|, this function |
36 // will fail and return false. | 37 // will fail and return PP_FALSE. |
37 // | 38 // |
38 // The image format must be of the format | 39 // The image format must be of the format |
39 // PPB_ImageData.GetNativeImageDataFormat() or this function will fail and | 40 // PPB_ImageData.GetNativeImageDataFormat() or this function will fail and |
40 // return false. | 41 // return PP_FALSE. |
41 // | 42 // |
42 // The returned image data will represent the current status of the backing | 43 // The returned image data will represent the current status of the backing |
43 // store. This will not include any paint, scroll, or replace operations | 44 // store. This will not include any paint, scroll, or replace operations |
44 // that have not yet been flushed; these operations are only reflected in | 45 // that have not yet been flushed; these operations are only reflected in |
45 // the backing store (and hence ReadImageData) until after a Flush() | 46 // the backing store (and hence ReadImageData) until after a Flush() |
46 // operation has completed. | 47 // operation has completed. |
47 bool (*ReadImageData)(PP_Resource device_context_2d, | 48 PP_Bool (*ReadImageData)(PP_Resource device_context_2d, |
48 PP_Resource image, | 49 PP_Resource image, |
49 const struct PP_Point* top_left); | 50 const struct PP_Point* top_left); |
50 | 51 |
51 // Runs a nested message loop. The plugin will be reentered from this call. | 52 // Runs a nested message loop. The plugin will be reentered from this call. |
52 // This function is used for unit testing the API. The normal pattern is to | 53 // This function is used for unit testing the API. The normal pattern is to |
53 // issue some asynchronous call that has a callback. Then you call | 54 // issue some asynchronous call that has a callback. Then you call |
54 // RunMessageLoop which will suspend the plugin and go back to processing | 55 // RunMessageLoop which will suspend the plugin and go back to processing |
55 // messages, giving the asynchronous operation time to complete. In your | 56 // messages, giving the asynchronous operation time to complete. In your |
56 // callback, you save the data and call QuitMessageLoop, which will then | 57 // callback, you save the data and call QuitMessageLoop, which will then |
57 // pop back up and continue with the test. This avoids having to write a | 58 // pop back up and continue with the test. This avoids having to write a |
58 // complicated state machine for simple tests for asynchronous APIs. | 59 // complicated state machine for simple tests for asynchronous APIs. |
59 void (*RunMessageLoop)(); | 60 void (*RunMessageLoop)(); |
60 | 61 |
61 // Posts a quit message for the outermost nested message loop. Use this to | 62 // Posts a quit message for the outermost nested message loop. Use this to |
62 // exit and return back to the caller after you call RunMessageLoop. | 63 // exit and return back to the caller after you call RunMessageLoop. |
63 void (*QuitMessageLoop)(); | 64 void (*QuitMessageLoop)(); |
64 | 65 |
65 // Returns the number of live objects (resources + strings + objects) | 66 // Returns the number of live objects (resources + strings + objects) |
66 // associated with this plugin module. Used for detecting leaks. | 67 // associated with this plugin module. Used for detecting leaks. |
67 uint32_t (*GetLiveObjectCount)(PP_Module module); | 68 uint32_t (*GetLiveObjectCount)(PP_Module module); |
68 }; | 69 }; |
69 | 70 |
70 #endif // PPAPI_C_DEV_PPB_TESTING_DEV_H_ | 71 #endif // PPAPI_C_DEV_PPB_TESTING_DEV_H_ |
OLD | NEW |