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

Side by Side Diff: webkit/plugins/ppapi/ppb_graphics_2d_impl.h

Issue 5828003: Move the Pepper implementation from webkit/glue/plugins/pepper_* to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years 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 | « webkit/plugins/ppapi/ppb_font_impl.cc ('k') | webkit/plugins/ppapi/ppb_graphics_2d_impl.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_GRAPHICS_2D_H_ 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_
6 #define WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_2D_H_ 6 #define WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "ppapi/c/pp_completion_callback.h" 11 #include "ppapi/c/pp_completion_callback.h"
12 #include "ppapi/c/ppb_graphics_2d.h" 12 #include "ppapi/c/ppb_graphics_2d.h"
13 #include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h" 13 #include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h"
14 #include "webkit/glue/plugins/pepper_resource.h" 14 #include "webkit/plugins/ppapi/resource.h"
15 15
16 struct PPB_Graphics2D; 16 struct PPB_Graphics2D;
17 17
18 namespace gfx { 18 namespace gfx {
19 class Rect; 19 class Rect;
20 } 20 }
21 21
22 namespace pepper { 22 namespace webkit {
23 namespace ppapi {
23 24
24 class ImageData; 25 class PPB_ImageData_Impl;
25 class PluginInstance; 26 class PluginInstance;
26 class PluginModule; 27 class PluginModule;
27 28
28 class Graphics2D : public Resource { 29 class PPB_Graphics2D_Impl : public Resource {
29 public: 30 public:
30 Graphics2D(PluginModule* module); 31 PPB_Graphics2D_Impl(PluginModule* module);
31 virtual ~Graphics2D(); 32 virtual ~PPB_Graphics2D_Impl();
32 33
33 // Returns a pointer to the interface implementing PPB_ImageData that is 34 // Returns a pointer to the interface implementing PPB_ImageData that is
34 // exposed to the plugin. 35 // exposed to the plugin.
35 static const PPB_Graphics2D* GetInterface(); 36 static const PPB_Graphics2D* GetInterface();
36 37
37 bool Init(int width, int height, bool is_always_opaque); 38 bool Init(int width, int height, bool is_always_opaque);
38 39
39 bool is_always_opaque() const { return is_always_opaque_; } 40 bool is_always_opaque() const { return is_always_opaque_; }
40 41
41 // Resource override. 42 // Resource override.
42 virtual Graphics2D* AsGraphics2D() { return this; } 43 virtual PPB_Graphics2D_Impl* AsPPB_Graphics2D_Impl();
43 44
44 // PPB_Graphics2D functions. 45 // PPB_Graphics2D functions.
45 PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque); 46 PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque);
46 void PaintImageData(PP_Resource image_data, 47 void PaintImageData(PP_Resource image_data,
47 const PP_Point* top_left, 48 const PP_Point* top_left,
48 const PP_Rect* src_rect); 49 const PP_Rect* src_rect);
49 void Scroll(const PP_Rect* clip_rect, const PP_Point* amount); 50 void Scroll(const PP_Rect* clip_rect, const PP_Point* amount);
50 void ReplaceContents(PP_Resource image_data); 51 void ReplaceContents(PP_Resource image_data);
51 int32_t Flush(const PP_CompletionCallback& callback); 52 int32_t Flush(const PP_CompletionCallback& callback);
52 53
53 bool ReadImageData(PP_Resource image, const PP_Point* top_left); 54 bool ReadImageData(PP_Resource image, const PP_Point* top_left);
54 55
55 // Assciates this device with the given plugin instance. You can pass NULL to 56 // Assciates this device with the given plugin instance. You can pass NULL to
56 // clear the existing device. Returns true on success. In this case, a 57 // clear the existing device. Returns true on success. In this case, a
57 // repaint of the page will also be scheduled. Failure means that the device 58 // repaint of the page will also be scheduled. Failure means that the device
58 // is already bound to a different instance, and nothing will happen. 59 // is already bound to a different instance, and nothing will happen.
59 bool BindToInstance(PluginInstance* new_instance); 60 bool BindToInstance(PluginInstance* new_instance);
60 61
61 // Paints the current backing store to the web page. 62 // Paints the current backing store to the web page.
62 void Paint(WebKit::WebCanvas* canvas, 63 void Paint(WebKit::WebCanvas* canvas,
63 const gfx::Rect& plugin_rect, 64 const gfx::Rect& plugin_rect,
64 const gfx::Rect& paint_rect); 65 const gfx::Rect& paint_rect);
65 66
66 // Notifications that the view has rendered the page and that it has been 67 // Notifications that the view has rendered the page and that it has been
67 // flushed to the screen. These messages are used to send Flush callbacks to 68 // flushed to the screen. These messages are used to send Flush callbacks to
68 // the plugin. See 69 // the plugin. See
69 void ViewInitiatedPaint(); 70 void ViewInitiatedPaint();
70 void ViewFlushedPaint(); 71 void ViewFlushedPaint();
71 72
72 ImageData* image_data() { return image_data_.get(); } 73 PPB_ImageData_Impl* image_data() { return image_data_.get(); }
73 74
74 private: 75 private:
75 // Tracks a call to flush that requires a callback. 76 // Tracks a call to flush that requires a callback.
76 class FlushCallbackData { 77 class FlushCallbackData {
77 public: 78 public:
78 FlushCallbackData() { 79 FlushCallbackData() {
79 Clear(); 80 Clear();
80 } 81 }
81 82
82 FlushCallbackData(const PP_CompletionCallback& callback) { 83 FlushCallbackData(const PP_CompletionCallback& callback) {
(...skipping 16 matching lines...) Expand all
99 100
100 private: 101 private:
101 PP_CompletionCallback callback_; 102 PP_CompletionCallback callback_;
102 }; 103 };
103 104
104 // Called internally to execute the different queued commands. The 105 // Called internally to execute the different queued commands. The
105 // parameters to these functions will have already been validated. The last 106 // parameters to these functions will have already been validated. The last
106 // rect argument will be filled by each function with the area affected by 107 // rect argument will be filled by each function with the area affected by
107 // the update that requires invalidation. If there were no pixels changed, 108 // the update that requires invalidation. If there were no pixels changed,
108 // this rect can be untouched. 109 // this rect can be untouched.
109 void ExecutePaintImageData(ImageData* image, 110 void ExecutePaintImageData(PPB_ImageData_Impl* image,
110 int x, int y, 111 int x, int y,
111 const gfx::Rect& src_rect, 112 const gfx::Rect& src_rect,
112 gfx::Rect* invalidated_rect); 113 gfx::Rect* invalidated_rect);
113 void ExecuteScroll(const gfx::Rect& clip, int dx, int dy, 114 void ExecuteScroll(const gfx::Rect& clip, int dx, int dy,
114 gfx::Rect* invalidated_rect); 115 gfx::Rect* invalidated_rect);
115 void ExecuteReplaceContents(ImageData* image, 116 void ExecuteReplaceContents(PPB_ImageData_Impl* image,
116 gfx::Rect* invalidated_rect); 117 gfx::Rect* invalidated_rect);
117 118
118 // Schedules the offscreen callback to be fired at a future time. This 119 // Schedules the offscreen callback to be fired at a future time. This
119 // will add the given item to the offscreen_flush_callbacks_ vector. 120 // will add the given item to the offscreen_flush_callbacks_ vector.
120 void ScheduleOffscreenCallback(const FlushCallbackData& callback); 121 void ScheduleOffscreenCallback(const FlushCallbackData& callback);
121 122
122 // Function scheduled to execute by ScheduleOffscreenCallback that actually 123 // Function scheduled to execute by ScheduleOffscreenCallback that actually
123 // issues the offscreen callbacks. 124 // issues the offscreen callbacks.
124 void ExecuteOffscreenCallback(FlushCallbackData data); 125 void ExecuteOffscreenCallback(FlushCallbackData data);
125 126
126 // Returns true if there is any type of flush callback pending. 127 // Returns true if there is any type of flush callback pending.
127 bool HasPendingFlush() const; 128 bool HasPendingFlush() const;
128 129
129 scoped_refptr<ImageData> image_data_; 130 scoped_refptr<PPB_ImageData_Impl> image_data_;
130 131
131 // Non-owning pointer to the plugin instance this context is currently bound 132 // Non-owning pointer to the plugin instance this context is currently bound
132 // to, if any. If the context is currently unbound, this will be NULL. 133 // to, if any. If the context is currently unbound, this will be NULL.
133 PluginInstance* bound_instance_; 134 PluginInstance* bound_instance_;
134 135
135 // Keeps track of all drawing commands queued before a Flush call. 136 // Keeps track of all drawing commands queued before a Flush call.
136 struct QueuedOperation; 137 struct QueuedOperation;
137 typedef std::vector<QueuedOperation> OperationQueue; 138 typedef std::vector<QueuedOperation> OperationQueue;
138 OperationQueue queued_operations_; 139 OperationQueue queued_operations_;
139 140
(...skipping 25 matching lines...) Expand all
165 166
166 // When doing offscreen flushes, we issue a task that issues the callback 167 // When doing offscreen flushes, we issue a task that issues the callback
167 // later. This is set when one of those tasks is pending so that we can 168 // later. This is set when one of those tasks is pending so that we can
168 // enforce the "only one pending flush at a time" constraint in the API. 169 // enforce the "only one pending flush at a time" constraint in the API.
169 bool offscreen_flush_pending_; 170 bool offscreen_flush_pending_;
170 171
171 // Set to true if the plugin declares that this device will always be opaque. 172 // Set to true if the plugin declares that this device will always be opaque.
172 // This allows us to do more optimized painting in some cases. 173 // This allows us to do more optimized painting in some cases.
173 bool is_always_opaque_; 174 bool is_always_opaque_;
174 175
175 DISALLOW_COPY_AND_ASSIGN(Graphics2D); 176 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics2D_Impl);
176 }; 177 };
177 178
178 } // namespace pepper 179 } // namespace ppapi
180 } // namespace webkit
179 181
180 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_2D_H_ 182 #endif // WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_font_impl.cc ('k') | webkit/plugins/ppapi/ppb_graphics_2d_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698