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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/plugins/pepper_device_context_2d.h
===================================================================
--- webkit/glue/plugins/pepper_device_context_2d.h (revision 49266)
+++ webkit/glue/plugins/pepper_device_context_2d.h (working copy)
@@ -21,6 +21,7 @@
namespace pepper {
class ImageData;
+class PluginInstance;
class PluginModule;
class DeviceContext2D : public Resource {
@@ -48,26 +49,91 @@
void* callback_data);
bool ReadImageData(PP_Resource image, int32_t x, int32_t y);
+ // Assciates this device with the given plugin instance. You can pass NULL to
+ // clear the existing device. Returns true on success. In this case, a
+ // repaint of the page will also be scheduled. Failure means that the device
+ // is already bound to a different instance, and nothing will happen.
+ bool BindToInstance(PluginInstance* new_instance);
+
+ // Paints the current backing store to the web page.
void Paint(WebKit::WebCanvas* canvas,
const gfx::Rect& plugin_rect,
const gfx::Rect& paint_rect);
+ // Notifications that the view has rendered the page and that it has been
+ // flushed to the screen. These messages are used to send Flush callbacks to
+ // the plugin. See
+ void ViewInitiatedPaint();
+ void ViewFlushedPaint();
+
private:
+ // Tracks a call to flush that requires a callback.
+ // See unpainted_flush_callbacks_ below.
+ class FlushCallbackData {
+ public:
+ FlushCallbackData(PPB_DeviceContext2D_FlushCallback c, void* d);
+
+ void Execute(PP_Resource device_context);
+
+ private:
+ PPB_DeviceContext2D_FlushCallback callback_;
+ void* callback_data_;
+ };
+ typedef std::vector<FlushCallbackData> FlushCallbackVector;
+
// Called internally to execute the different queued commands. The
- // parameters to these functions will have already been validated.
+ // parameters to these functions will have already been validated. The last
+ // rect argument will be filled by each function with the area affected by
+ // the update that requires invalidation. If there were no pixels changed,
+ // this rect can be untouched.
void ExecutePaintImageData(ImageData* image,
int x, int y,
- const gfx::Rect& src_rect);
- void ExecuteScroll(const gfx::Rect& clip, int dx, int dy);
- void ExecuteReplaceContents(ImageData* image);
+ const gfx::Rect& src_rect,
+ gfx::Rect* invalidated_rect);
+ void ExecuteScroll(const gfx::Rect& clip, int dx, int dy,
+ gfx::Rect* invalidated_rect);
+ void ExecuteReplaceContents(ImageData* image,
+ gfx::Rect* invalidated_rect);
+ // Schedules the offscreen callback to be fired at a future time. This
+ // will add the given item to the offscreen_flush_callbacks_ vector.
+ void ScheduleOffscreenCallback(const FlushCallbackData& callback);
+
+ // Function scheduled to execute by ScheduleOffscreenCallback that actually
+ // issues the offscreen callbacks.
+ void ExecuteOffscreenCallback(FlushCallbackData data);
+
scoped_refptr<ImageData> image_data_;
+ // Non-owning pointer to the plugin instance this device context is currently
+ // bound to, if any. If the device context is currently unbound, this will
+ // be NULL.
+ PluginInstance* bound_instance_;
+
// Keeps track of all drawing commands queued before a Flush call.
struct QueuedOperation;
typedef std::vector<QueuedOperation> OperationQueue;
OperationQueue queued_operations_;
+ // Indicates whether any changes have been flushed to the backing store.
+ // This is initially false and is set to true at the first Flush() call.
+ bool flushed_any_data_;
+
+ // The plugin may be constantly giving us paint messages. "Unpainted" ones
+ // are paint requests which have never been painted. These could have been
+ // done while the RenderView was already waiting for an ACK from a previous
+ // paint, so won't generate a new one yet.
+ //
+ // "Painted" ones are those paints that have been painted by RenderView, but
+ // for which the ACK from the browser has not yet been received.
+ //
+ // When we get updates from a plugin with a callback, it is first added to
+ // the unpainted callbacks. When the renderer has initiated a paint, we'll
+ // move it to the painted callbacks list. When the renderer receives a flush,
+ // we'll execute the callback and remove it from the list.
+ FlushCallbackVector unpainted_flush_callbacks_;
+ FlushCallbackVector painted_flush_callbacks_;
+
DISALLOW_COPY_AND_ASSIGN(DeviceContext2D);
};
« 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