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 #include "ppapi/proxy/ppb_graphics_2d_proxy.h" | 5 #include "ppapi/proxy/ppb_graphics_2d_proxy.h" |
6 | 6 |
7 #include <string.h> // For memset. | 7 #include <string.h> // For memset. |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 return PluginDispatcher::GetForResource(this); | 58 return PluginDispatcher::GetForResource(this); |
59 } | 59 } |
60 | 60 |
61 static const ApiID kApiID = API_ID_PPB_GRAPHICS_2D; | 61 static const ApiID kApiID = API_ID_PPB_GRAPHICS_2D; |
62 | 62 |
63 PP_Size size_; | 63 PP_Size size_; |
64 PP_Bool is_always_opaque_; | 64 PP_Bool is_always_opaque_; |
65 float scale_; | 65 float scale_; |
66 | 66 |
67 // In the plugin, this is the current callback set for Flushes. When the | 67 // In the plugin, this is the current callback set for Flushes. When the |
68 // pointer is non-NULL, we're waiting for a flush ACK. | 68 // callback is pending, we're waiting for a flush ACK. |
69 scoped_refptr<TrackedCallback> current_flush_callback_; | 69 scoped_refptr<TrackedCallback> current_flush_callback_; |
70 | 70 |
71 DISALLOW_COPY_AND_ASSIGN(Graphics2D); | 71 DISALLOW_COPY_AND_ASSIGN(Graphics2D); |
72 }; | 72 }; |
73 | 73 |
74 Graphics2D::Graphics2D(const HostResource& host_resource, | 74 Graphics2D::Graphics2D(const HostResource& host_resource, |
75 const PP_Size& size, | 75 const PP_Size& size, |
76 PP_Bool is_always_opaque) | 76 PP_Bool is_always_opaque) |
77 : Resource(OBJECT_IS_PROXY, host_resource), | 77 : Resource(OBJECT_IS_PROXY, host_resource), |
78 size_(size), | 78 size_(size), |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 if (TrackedCallback::IsPending(current_flush_callback_)) | 160 if (TrackedCallback::IsPending(current_flush_callback_)) |
161 return PP_ERROR_INPROGRESS; // Can't have >1 flush pending. | 161 return PP_ERROR_INPROGRESS; // Can't have >1 flush pending. |
162 current_flush_callback_ = callback; | 162 current_flush_callback_ = callback; |
163 | 163 |
164 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_Flush(kApiID, | 164 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_Flush(kApiID, |
165 host_resource())); | 165 host_resource())); |
166 return PP_OK_COMPLETIONPENDING; | 166 return PP_OK_COMPLETIONPENDING; |
167 } | 167 } |
168 | 168 |
169 void Graphics2D::FlushACK(int32_t result_code) { | 169 void Graphics2D::FlushACK(int32_t result_code) { |
170 TrackedCallback::ClearAndRun(¤t_flush_callback_, result_code); | 170 current_flush_callback_->Run(result_code); |
171 } | 171 } |
172 | 172 |
173 PPB_Graphics2D_Proxy::PPB_Graphics2D_Proxy(Dispatcher* dispatcher) | 173 PPB_Graphics2D_Proxy::PPB_Graphics2D_Proxy(Dispatcher* dispatcher) |
174 : InterfaceProxy(dispatcher), | 174 : InterfaceProxy(dispatcher), |
175 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 175 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
176 } | 176 } |
177 | 177 |
178 PPB_Graphics2D_Proxy::~PPB_Graphics2D_Proxy() { | 178 PPB_Graphics2D_Proxy::~PPB_Graphics2D_Proxy() { |
179 } | 179 } |
180 | 180 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 300 |
301 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin( | 301 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin( |
302 int32_t result, | 302 int32_t result, |
303 const HostResource& graphics_2d) { | 303 const HostResource& graphics_2d) { |
304 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK(kApiID, graphics_2d, | 304 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK(kApiID, graphics_2d, |
305 result)); | 305 result)); |
306 } | 306 } |
307 | 307 |
308 } // namespace proxy | 308 } // namespace proxy |
309 } // namespace ppapi | 309 } // namespace ppapi |
OLD | NEW |