Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Side by Side Diff: webkit/glue/plugins/pepper_device_context_2d.h

Issue 2712002: First pass at implementing real Flush callbacks. This does not currently... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/ui/ppapi_uitest.cc ('k') | webkit/glue/plugins/pepper_device_context_2d.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_2D_H_ 5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_2D_H_
6 #define WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_2D_H_ 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_2D_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "third_party/ppapi/c/ppb_device_context_2d.h" 11 #include "third_party/ppapi/c/ppb_device_context_2d.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h" 12 #include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h"
13 #include "webkit/glue/plugins/pepper_resource.h" 13 #include "webkit/glue/plugins/pepper_resource.h"
14 14
15 typedef struct _ppb_DeviceContext2D PPB_DeviceContext2D; 15 typedef struct _ppb_DeviceContext2D PPB_DeviceContext2D;
16 16
17 namespace gfx { 17 namespace gfx {
18 class Rect; 18 class Rect;
19 } 19 }
20 20
21 namespace pepper { 21 namespace pepper {
22 22
23 class ImageData; 23 class ImageData;
24 class PluginInstance;
24 class PluginModule; 25 class PluginModule;
25 26
26 class DeviceContext2D : public Resource { 27 class DeviceContext2D : public Resource {
27 public: 28 public:
28 DeviceContext2D(PluginModule* module); 29 DeviceContext2D(PluginModule* module);
29 virtual ~DeviceContext2D(); 30 virtual ~DeviceContext2D();
30 31
31 // Returns a pointer to the interface implementing PPB_ImageData that is 32 // Returns a pointer to the interface implementing PPB_ImageData that is
32 // exposed to the plugin. 33 // exposed to the plugin.
33 static const PPB_DeviceContext2D* GetInterface(); 34 static const PPB_DeviceContext2D* GetInterface();
34 35
35 bool Init(int width, int height, bool is_always_opaque); 36 bool Init(int width, int height, bool is_always_opaque);
36 37
37 // Resource override. 38 // Resource override.
38 virtual DeviceContext2D* AsDeviceContext2D() { return this; } 39 virtual DeviceContext2D* AsDeviceContext2D() { return this; }
39 40
40 // PPB_DeviceContext2D functions. 41 // PPB_DeviceContext2D functions.
41 bool Describe(int32_t* width, int32_t* height, bool* is_always_opaque); 42 bool Describe(int32_t* width, int32_t* height, bool* is_always_opaque);
42 bool PaintImageData(PP_Resource image, 43 bool PaintImageData(PP_Resource image,
43 int32_t x, int32_t y, 44 int32_t x, int32_t y,
44 const PP_Rect* src_rect); 45 const PP_Rect* src_rect);
45 bool Scroll(const PP_Rect* clip_rect, int32_t dx, int32_t dy); 46 bool Scroll(const PP_Rect* clip_rect, int32_t dx, int32_t dy);
46 bool ReplaceContents(PP_Resource image); 47 bool ReplaceContents(PP_Resource image);
47 bool Flush(PPB_DeviceContext2D_FlushCallback callback, 48 bool Flush(PPB_DeviceContext2D_FlushCallback callback,
48 void* callback_data); 49 void* callback_data);
49 bool ReadImageData(PP_Resource image, int32_t x, int32_t y); 50 bool ReadImageData(PP_Resource image, int32_t x, int32_t y);
50 51
52 // Assciates this device with the given plugin instance. You can pass NULL to
53 // clear the existing device. Returns true on success. In this case, a
54 // repaint of the page will also be scheduled. Failure means that the device
55 // is already bound to a different instance, and nothing will happen.
56 bool BindToInstance(PluginInstance* new_instance);
57
58 // Paints the current backing store to the web page.
51 void Paint(WebKit::WebCanvas* canvas, 59 void Paint(WebKit::WebCanvas* canvas,
52 const gfx::Rect& plugin_rect, 60 const gfx::Rect& plugin_rect,
53 const gfx::Rect& paint_rect); 61 const gfx::Rect& paint_rect);
54 62
63 // Notifications that the view has rendered the page and that it has been
64 // flushed to the screen. These messages are used to send Flush callbacks to
65 // the plugin. See
66 void ViewInitiatedPaint();
67 void ViewFlushedPaint();
68
55 private: 69 private:
70 // Tracks a call to flush that requires a callback.
71 // See unpainted_flush_callbacks_ below.
72 class FlushCallbackData {
73 public:
74 FlushCallbackData(PPB_DeviceContext2D_FlushCallback c, void* d);
75
76 void Execute(PP_Resource device_context);
77
78 private:
79 PPB_DeviceContext2D_FlushCallback callback_;
80 void* callback_data_;
81 };
82 typedef std::vector<FlushCallbackData> FlushCallbackVector;
83
56 // Called internally to execute the different queued commands. The 84 // Called internally to execute the different queued commands. The
57 // parameters to these functions will have already been validated. 85 // parameters to these functions will have already been validated. The last
86 // rect argument will be filled by each function with the area affected by
87 // the update that requires invalidation. If there were no pixels changed,
88 // this rect can be untouched.
58 void ExecutePaintImageData(ImageData* image, 89 void ExecutePaintImageData(ImageData* image,
59 int x, int y, 90 int x, int y,
60 const gfx::Rect& src_rect); 91 const gfx::Rect& src_rect,
61 void ExecuteScroll(const gfx::Rect& clip, int dx, int dy); 92 gfx::Rect* invalidated_rect);
62 void ExecuteReplaceContents(ImageData* image); 93 void ExecuteScroll(const gfx::Rect& clip, int dx, int dy,
94 gfx::Rect* invalidated_rect);
95 void ExecuteReplaceContents(ImageData* image,
96 gfx::Rect* invalidated_rect);
97
98 // Schedules the offscreen callback to be fired at a future time. This
99 // will add the given item to the offscreen_flush_callbacks_ vector.
100 void ScheduleOffscreenCallback(const FlushCallbackData& callback);
101
102 // Function scheduled to execute by ScheduleOffscreenCallback that actually
103 // issues the offscreen callbacks.
104 void ExecuteOffscreenCallback(FlushCallbackData data);
63 105
64 scoped_refptr<ImageData> image_data_; 106 scoped_refptr<ImageData> image_data_;
65 107
108 // Non-owning pointer to the plugin instance this device context is currently
109 // bound to, if any. If the device context is currently unbound, this will
110 // be NULL.
111 PluginInstance* bound_instance_;
112
66 // Keeps track of all drawing commands queued before a Flush call. 113 // Keeps track of all drawing commands queued before a Flush call.
67 struct QueuedOperation; 114 struct QueuedOperation;
68 typedef std::vector<QueuedOperation> OperationQueue; 115 typedef std::vector<QueuedOperation> OperationQueue;
69 OperationQueue queued_operations_; 116 OperationQueue queued_operations_;
70 117
118 // Indicates whether any changes have been flushed to the backing store.
119 // This is initially false and is set to true at the first Flush() call.
120 bool flushed_any_data_;
121
122 // The plugin may be constantly giving us paint messages. "Unpainted" ones
123 // are paint requests which have never been painted. These could have been
124 // done while the RenderView was already waiting for an ACK from a previous
125 // paint, so won't generate a new one yet.
126 //
127 // "Painted" ones are those paints that have been painted by RenderView, but
128 // for which the ACK from the browser has not yet been received.
129 //
130 // When we get updates from a plugin with a callback, it is first added to
131 // the unpainted callbacks. When the renderer has initiated a paint, we'll
132 // move it to the painted callbacks list. When the renderer receives a flush,
133 // we'll execute the callback and remove it from the list.
134 FlushCallbackVector unpainted_flush_callbacks_;
135 FlushCallbackVector painted_flush_callbacks_;
136
71 DISALLOW_COPY_AND_ASSIGN(DeviceContext2D); 137 DISALLOW_COPY_AND_ASSIGN(DeviceContext2D);
72 }; 138 };
73 139
74 } // namespace pepper 140 } // namespace pepper
75 141
76 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_2D_H_ 142 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_2D_H_
OLDNEW
« no previous file with comments | « chrome/test/ui/ppapi_uitest.cc ('k') | webkit/glue/plugins/pepper_device_context_2d.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698