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

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

Issue 11053003: Migrate Graphics2D to new design. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 8 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
OLDNEW
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 WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_ 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_
6 #define WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_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 "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "ppapi/c/pp_completion_callback.h" 12 #include "ppapi/c/pp_completion_callback.h"
13 #include "ppapi/c/ppb_graphics_2d.h" 13 #include "ppapi/c/ppb_graphics_2d.h"
14 #include "ppapi/shared_impl/resource.h" 14 #include "ppapi/shared_impl/resource.h"
15 #include "ppapi/shared_impl/tracked_callback.h" 15 #include "ppapi/shared_impl/tracked_callback.h"
16 #include "ppapi/thunk/ppb_graphics_2d_api.h" 16 #include "ppapi/thunk/ppb_graphics_2d_api.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h"
18 #include "webkit/plugins/webkit_plugins_export.h" 18 #include "webkit/plugins/webkit_plugins_export.h"
19 19
20 namespace gfx { 20 namespace gfx {
21 class Point; 21 class Point;
22 class Rect; 22 class Rect;
23 } 23 }
24 24
25 namespace content {
26 class PepperGraphics2DHost;
27 }
28
25 namespace webkit { 29 namespace webkit {
26 namespace ppapi { 30 namespace ppapi {
27 31
28 class PPB_ImageData_Impl; 32 class PPB_ImageData_Impl;
29 class PluginInstance; 33 class PluginInstance;
30 34
31 class PPB_Graphics2D_Impl : public ::ppapi::Resource, 35 class WEBKIT_PLUGINS_EXPORT PPB_Graphics2D_Impl :
32 public ::ppapi::thunk::PPB_Graphics2D_API { 36 public ::ppapi::Resource,
37 public ::ppapi::thunk::PPB_Graphics2D_API {
33 public: 38 public:
34 virtual ~PPB_Graphics2D_Impl(); 39 virtual ~PPB_Graphics2D_Impl();
35 40
36 WEBKIT_PLUGINS_EXPORT static PP_Resource Create(PP_Instance instance, 41 static PP_Resource Create(PP_Instance instance,
37 const PP_Size& size, 42 const PP_Size& size,
38 PP_Bool is_always_opaque); 43 PP_Bool is_always_opaque);
39 44
40 bool is_always_opaque() const { return is_always_opaque_; } 45 bool is_always_opaque() const { return is_always_opaque_; }
41 46
42 // Resource overrides. 47 // Resource overrides.
43 virtual ::ppapi::thunk::PPB_Graphics2D_API* AsPPB_Graphics2D_API(); 48 virtual ::ppapi::thunk::PPB_Graphics2D_API* AsPPB_Graphics2D_API();
44 virtual void LastPluginRefWasDeleted() OVERRIDE; 49 virtual void LastPluginRefWasDeleted() OVERRIDE;
45 50
46 // PPB_Graphics2D functions. 51 // PPB_Graphics2D functions.
47 virtual PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque) OVERRIDE; 52 virtual PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque) OVERRIDE;
48 virtual void PaintImageData(PP_Resource image_data, 53 virtual void PaintImageData(PP_Resource image_data,
(...skipping 27 matching lines...) Expand all
76 void ViewInitiatedPaint(); 81 void ViewInitiatedPaint();
77 void ViewFlushedPaint(); 82 void ViewFlushedPaint();
78 83
79 PPB_ImageData_Impl* image_data() { return image_data_.get(); } 84 PPB_ImageData_Impl* image_data() { return image_data_.get(); }
80 85
81 // Scale |op_rect| to logical pixels, taking care to include partially- 86 // Scale |op_rect| to logical pixels, taking care to include partially-
82 // covered logical pixels (aka DIPs). Also scale optional |delta| to logical 87 // covered logical pixels (aka DIPs). Also scale optional |delta| to logical
83 // pixels as well for scrolling cases. Returns false for scrolling cases where 88 // pixels as well for scrolling cases. Returns false for scrolling cases where
84 // scaling either |op_rect| or |delta| would require scrolling to fall back to 89 // scaling either |op_rect| or |delta| would require scrolling to fall back to
85 // invalidation due to rounding errors, true otherwise. 90 // invalidation due to rounding errors, true otherwise.
86 WEBKIT_PLUGINS_EXPORT static bool ConvertToLogicalPixels(float scale, 91 static bool ConvertToLogicalPixels(float scale,
87 gfx::Rect* op_rect, 92 gfx::Rect* op_rect,
88 gfx::Point* delta); 93 gfx::Point* delta);
89 94
90 private: 95 private:
91 explicit PPB_Graphics2D_Impl(PP_Instance instance); 96 explicit PPB_Graphics2D_Impl(PP_Instance instance);
92 97
93 bool Init(int width, int height, bool is_always_opaque); 98 bool Init(int width, int height, bool is_always_opaque);
94 99
95 // Tracks a call to flush that requires a callback. 100 // Tracks a call to flush that requires a callback.
96 class FlushCallbackData { 101 class FlushCallbackData {
97 public: 102 public:
98 FlushCallbackData() { 103 FlushCallbackData() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // Set to true if the plugin declares that this device will always be opaque. 204 // Set to true if the plugin declares that this device will always be opaque.
200 // This allows us to do more optimized painting in some cases. 205 // This allows us to do more optimized painting in some cases.
201 bool is_always_opaque_; 206 bool is_always_opaque_;
202 207
203 // Set to the scale between what the plugin considers to be one pixel and one 208 // Set to the scale between what the plugin considers to be one pixel and one
204 // DIP 209 // DIP
205 float scale_; 210 float scale_;
206 211
207 base::WeakPtrFactory<PPB_Graphics2D_Impl> weak_ptr_factory_; 212 base::WeakPtrFactory<PPB_Graphics2D_Impl> weak_ptr_factory_;
208 213
214 friend class content::PepperGraphics2DHost;
209 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics2D_Impl); 215 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics2D_Impl);
210 }; 216 };
211 217
212 } // namespace ppapi 218 } // namespace ppapi
213 } // namespace webkit 219 } // namespace webkit
214 220
215 #endif // WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_ 221 #endif // WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.cc ('k') | webkit/plugins/ppapi/resource_creation_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698