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