| 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 "content/renderer/pepper/pepper_graphics_2d_host.h" | 5 #include "content/renderer/pepper/pepper_graphics_2d_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 int32_t PepperGraphics2DHost::OnResourceMessageReceived( | 221 int32_t PepperGraphics2DHost::OnResourceMessageReceived( |
| 222 const IPC::Message& msg, | 222 const IPC::Message& msg, |
| 223 ppapi::host::HostMessageContext* context) { | 223 ppapi::host::HostMessageContext* context) { |
| 224 IPC_BEGIN_MESSAGE_MAP(PepperGraphics2DHost, msg) | 224 IPC_BEGIN_MESSAGE_MAP(PepperGraphics2DHost, msg) |
| 225 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_PaintImageData, | 225 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_PaintImageData, |
| 226 OnHostMsgPaintImageData) | 226 OnHostMsgPaintImageData) |
| 227 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_Scroll, | 227 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_Scroll, |
| 228 OnHostMsgScroll) | 228 OnHostMsgScroll) |
| 229 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_ReplaceContents, | 229 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_ReplaceContents, |
| 230 OnHostMsgReplaceContents) | 230 OnHostMsgReplaceContents) |
| 231 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Graphics2D_Flush, | 231 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_Flush, |
| 232 OnHostMsgFlush) | 232 OnHostMsgFlush) |
| 233 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_SetScale, | 233 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_SetScale, |
| 234 OnHostMsgSetScale) | 234 OnHostMsgSetScale) |
| 235 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_ReadImageData, | 235 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_ReadImageData, |
| 236 OnHostMsgReadImageData) | 236 OnHostMsgReadImageData) |
| 237 IPC_END_MESSAGE_MAP() | 237 IPC_END_MESSAGE_MAP() |
| 238 return PP_ERROR_FAILED; | 238 return PP_ERROR_FAILED; |
| 239 } | 239 } |
| 240 | 240 |
| 241 bool PepperGraphics2DHost::IsGraphics2DHost() { return true; } | 241 bool PepperGraphics2DHost::IsGraphics2DHost() { return true; } |
| 242 | 242 |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 image_resource->height() != image_data_->height()) | 493 image_resource->height() != image_data_->height()) |
| 494 return PP_ERROR_BADARGUMENT; | 494 return PP_ERROR_BADARGUMENT; |
| 495 | 495 |
| 496 QueuedOperation operation(QueuedOperation::REPLACE); | 496 QueuedOperation operation(QueuedOperation::REPLACE); |
| 497 operation.replace_image = image_resource; | 497 operation.replace_image = image_resource; |
| 498 queued_operations_.push_back(operation); | 498 queued_operations_.push_back(operation); |
| 499 return PP_OK; | 499 return PP_OK; |
| 500 } | 500 } |
| 501 | 501 |
| 502 int32_t PepperGraphics2DHost::OnHostMsgFlush( | 502 int32_t PepperGraphics2DHost::OnHostMsgFlush( |
| 503 ppapi::host::HostMessageContext* context) { | 503 ppapi::host::HostMessageContext* context, |
| 504 const std::vector<ui::LatencyInfo>& latency_info) { |
| 504 // Don't allow more than one pending flush at a time. | 505 // Don't allow more than one pending flush at a time. |
| 505 if (HasPendingFlush()) | 506 if (HasPendingFlush()) |
| 506 return PP_ERROR_INPROGRESS; | 507 return PP_ERROR_INPROGRESS; |
| 507 | 508 |
| 509 if (bound_instance_) |
| 510 bound_instance_->AddLatencyInfo(latency_info); |
| 511 |
| 508 PP_Resource old_image_data = 0; | 512 PP_Resource old_image_data = 0; |
| 509 flush_reply_context_ = context->MakeReplyMessageContext(); | 513 flush_reply_context_ = context->MakeReplyMessageContext(); |
| 510 if (is_running_in_process_) | 514 if (is_running_in_process_) |
| 511 return Flush(NULL); | 515 return Flush(NULL); |
| 512 | 516 |
| 513 // Reuse image data when running out of process. | 517 // Reuse image data when running out of process. |
| 514 int32_t result = Flush(&old_image_data); | 518 int32_t result = Flush(&old_image_data); |
| 515 | 519 |
| 516 if (old_image_data) { | 520 if (old_image_data) { |
| 517 // If the Graphics2D has an old image data it's not using any more, send | 521 // If the Graphics2D has an old image data it's not using any more, send |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 gfx::Point inverse_scaled_point = | 791 gfx::Point inverse_scaled_point = |
| 788 gfx::ToFlooredPoint(gfx::ScalePoint(*delta, inverse_scale)); | 792 gfx::ToFlooredPoint(gfx::ScalePoint(*delta, inverse_scale)); |
| 789 if (original_delta != inverse_scaled_point) | 793 if (original_delta != inverse_scaled_point) |
| 790 return false; | 794 return false; |
| 791 } | 795 } |
| 792 | 796 |
| 793 return true; | 797 return true; |
| 794 } | 798 } |
| 795 | 799 |
| 796 } // namespace content | 800 } // namespace content |
| OLD | NEW |