| 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/graphics_2d_resource.h" | 5 #include "ppapi/proxy/graphics_2d_resource.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_bool.h" | 7 #include "ppapi/c/pp_bool.h" |
| 8 #include "ppapi/c/pp_point.h" | 8 #include "ppapi/c/pp_point.h" |
| 9 #include "ppapi/c/pp_rect.h" | 9 #include "ppapi/c/pp_rect.h" |
| 10 #include "ppapi/c/pp_resource.h" | 10 #include "ppapi/c/pp_resource.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 int32_t Graphics2DResource::Flush(scoped_refptr<TrackedCallback> callback) { | 115 int32_t Graphics2DResource::Flush(scoped_refptr<TrackedCallback> callback) { |
| 116 // If host is not even created, return failure immediately. This can happen | 116 // If host is not even created, return failure immediately. This can happen |
| 117 // when failed to initialize (in constructor). | 117 // when failed to initialize (in constructor). |
| 118 if (!sent_create_to_renderer()) | 118 if (!sent_create_to_renderer()) |
| 119 return PP_ERROR_FAILED; | 119 return PP_ERROR_FAILED; |
| 120 | 120 |
| 121 if (TrackedCallback::IsPending(current_flush_callback_)) | 121 if (TrackedCallback::IsPending(current_flush_callback_)) |
| 122 return PP_ERROR_INPROGRESS; // Can't have >1 flush pending. | 122 return PP_ERROR_INPROGRESS; // Can't have >1 flush pending. |
| 123 current_flush_callback_ = callback; | 123 current_flush_callback_ = callback; |
| 124 | 124 |
| 125 std::vector<ui::LatencyInfo> latency_info; |
| 126 PpapiGlobals::Get()->TransferLatencyInfoTo(&latency_info, pp_instance()); |
| 127 |
| 125 Call<PpapiPluginMsg_Graphics2D_FlushAck>( | 128 Call<PpapiPluginMsg_Graphics2D_FlushAck>( |
| 126 RENDERER, | 129 RENDERER, |
| 127 PpapiHostMsg_Graphics2D_Flush(), | 130 PpapiHostMsg_Graphics2D_Flush(latency_info), |
| 128 base::Bind(&Graphics2DResource::OnPluginMsgFlushACK, this)); | 131 base::Bind(&Graphics2DResource::OnPluginMsgFlushACK, this)); |
| 129 return PP_OK_COMPLETIONPENDING; | 132 return PP_OK_COMPLETIONPENDING; |
| 130 } | 133 } |
| 131 | 134 |
| 132 bool Graphics2DResource::ReadImageData(PP_Resource image, | 135 bool Graphics2DResource::ReadImageData(PP_Resource image, |
| 133 const PP_Point* top_left) { | 136 const PP_Point* top_left) { |
| 134 if (!top_left) | 137 if (!top_left) |
| 135 return false; | 138 return false; |
| 136 int32_t result = SyncCall<PpapiPluginMsg_Graphics2D_ReadImageDataAck>( | 139 int32_t result = SyncCall<PpapiPluginMsg_Graphics2D_ReadImageDataAck>( |
| 137 RENDERER, | 140 RENDERER, |
| 138 PpapiHostMsg_Graphics2D_ReadImageData(image, *top_left)); | 141 PpapiHostMsg_Graphics2D_ReadImageData(image, *top_left)); |
| 139 return result == PP_OK; | 142 return result == PP_OK; |
| 140 } | 143 } |
| 141 | 144 |
| 142 void Graphics2DResource::OnPluginMsgFlushACK( | 145 void Graphics2DResource::OnPluginMsgFlushACK( |
| 143 const ResourceMessageReplyParams& params) { | 146 const ResourceMessageReplyParams& params) { |
| 144 current_flush_callback_->Run(params.result()); | 147 current_flush_callback_->Run(params.result()); |
| 145 } | 148 } |
| 146 | 149 |
| 147 } // namespace proxy | 150 } // namespace proxy |
| 148 } // namespace ppapi | 151 } // namespace ppapi |
| OLD | NEW |