OLD | NEW |
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/thunk/ppb_graphics_2d_api.h" | 16 #include "ppapi/thunk/ppb_graphics_2d_api.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h" |
17 | 18 |
18 namespace gfx { | 19 namespace gfx { |
19 class Rect; | 20 class Rect; |
20 } | 21 } |
21 | 22 |
22 namespace webkit { | 23 namespace webkit { |
23 namespace ppapi { | 24 namespace ppapi { |
24 | 25 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 77 |
77 bool Init(int width, int height, bool is_always_opaque); | 78 bool Init(int width, int height, bool is_always_opaque); |
78 | 79 |
79 // Tracks a call to flush that requires a callback. | 80 // Tracks a call to flush that requires a callback. |
80 class FlushCallbackData { | 81 class FlushCallbackData { |
81 public: | 82 public: |
82 FlushCallbackData() { | 83 FlushCallbackData() { |
83 Clear(); | 84 Clear(); |
84 } | 85 } |
85 | 86 |
86 explicit FlushCallbackData(const PP_CompletionCallback& callback) { | 87 explicit FlushCallbackData( |
| 88 scoped_refptr< ::ppapi::TrackedCallback> callback) { |
87 Set(callback); | 89 Set(callback); |
88 } | 90 } |
89 | 91 |
90 bool is_null() const { return !callback_.func; } | 92 bool is_null() const { |
| 93 return !::ppapi::TrackedCallback::IsPending(callback_); |
| 94 } |
91 | 95 |
92 void Set(const PP_CompletionCallback& callback) { | 96 void Set(scoped_refptr< ::ppapi::TrackedCallback> callback) { |
93 callback_ = callback; | 97 callback_ = callback; |
94 } | 98 } |
95 | 99 |
96 void Clear() { | 100 void Clear() { |
97 callback_ = PP_MakeCompletionCallback(NULL, 0); | 101 callback_ = NULL; |
98 } | 102 } |
99 | 103 |
100 void Execute(int32_t result) { | 104 void Execute(int32_t result) { |
101 PP_RunAndClearCompletionCallback(&callback_, result); | 105 ::ppapi::TrackedCallback::ClearAndRun(&callback_, result); |
102 } | 106 } |
103 | 107 |
104 private: | 108 private: |
105 PP_CompletionCallback callback_; | 109 scoped_refptr< ::ppapi::TrackedCallback> callback_; |
106 }; | 110 }; |
107 | 111 |
108 // Called internally to execute the different queued commands. The | 112 // Called internally to execute the different queued commands. The |
109 // parameters to these functions will have already been validated. The last | 113 // parameters to these functions will have already been validated. The last |
110 // rect argument will be filled by each function with the area affected by | 114 // rect argument will be filled by each function with the area affected by |
111 // the update that requires invalidation. If there were no pixels changed, | 115 // the update that requires invalidation. If there were no pixels changed, |
112 // this rect can be untouched. | 116 // this rect can be untouched. |
113 void ExecutePaintImageData(PPB_ImageData_Impl* image, | 117 void ExecutePaintImageData(PPB_ImageData_Impl* image, |
114 int x, int y, | 118 int x, int y, |
115 const gfx::Rect& src_rect, | 119 const gfx::Rect& src_rect, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 178 |
175 base::WeakPtrFactory<PPB_Graphics2D_Impl> weak_ptr_factory_; | 179 base::WeakPtrFactory<PPB_Graphics2D_Impl> weak_ptr_factory_; |
176 | 180 |
177 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics2D_Impl); | 181 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics2D_Impl); |
178 }; | 182 }; |
179 | 183 |
180 } // namespace ppapi | 184 } // namespace ppapi |
181 } // namespace webkit | 185 } // namespace webkit |
182 | 186 |
183 #endif // WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_ | 187 #endif // WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_ |
OLD | NEW |