| 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/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "content/renderer/pepper/gfx_conversion.h" | 9 #include "content/renderer/pepper/gfx_conversion.h" |
| 10 #include "content/renderer/pepper/mock_renderer_ppapi_host.h" | 10 #include "content/renderer/pepper/mock_renderer_ppapi_host.h" |
| 11 #include "content/renderer/pepper/ppb_image_data_impl.h" | 11 #include "content/renderer/pepper/ppb_image_data_impl.h" |
| 12 #include "ppapi/shared_impl/ppb_view_shared.h" | 12 #include "ppapi/shared_impl/ppb_view_shared.h" |
| 13 #include "ppapi/shared_impl/proxy_lock.h" | 13 #include "ppapi/shared_impl/proxy_lock.h" |
| 14 #include "ppapi/shared_impl/test_globals.h" | 14 #include "ppapi/shared_impl/test_globals.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "third_party/WebKit/public/platform/WebCanvas.h" | 16 #include "third_party/WebKit/public/platform/WebCanvas.h" |
| 17 #include "third_party/skia/include/core/SkCanvas.h" | 17 #include "third_party/skia/include/core/SkCanvas.h" |
| 18 #include "ui/events/latency_info.h" |
| 18 #include "ui/gfx/point.h" | 19 #include "ui/gfx/point.h" |
| 19 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 20 | 21 |
| 21 using blink::WebCanvas; | 22 using blink::WebCanvas; |
| 22 | 23 |
| 23 namespace content { | 24 namespace content { |
| 24 | 25 |
| 25 class PepperGraphics2DHostTest : public testing::Test { | 26 class PepperGraphics2DHostTest : public testing::Test { |
| 26 public: | 27 public: |
| 27 static bool ConvertToLogicalPixels(float scale, | 28 static bool ConvertToLogicalPixels(float scale, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 57 ppapi::HostResource image_data_resource; | 58 ppapi::HostResource image_data_resource; |
| 58 image_data_resource.SetHostResource(image_data->pp_instance(), | 59 image_data_resource.SetHostResource(image_data->pp_instance(), |
| 59 image_data->pp_resource()); | 60 image_data->pp_resource()); |
| 60 host_->OnHostMsgPaintImageData( | 61 host_->OnHostMsgPaintImageData( |
| 61 NULL, image_data_resource, PP_Point(), false, PP_Rect()); | 62 NULL, image_data_resource, PP_Point(), false, PP_Rect()); |
| 62 } | 63 } |
| 63 | 64 |
| 64 void Flush() { | 65 void Flush() { |
| 65 ppapi::host::HostMessageContext context( | 66 ppapi::host::HostMessageContext context( |
| 66 ppapi::proxy::ResourceMessageCallParams(host_->pp_resource(), 0)); | 67 ppapi::proxy::ResourceMessageCallParams(host_->pp_resource(), 0)); |
| 67 host_->OnHostMsgFlush(&context); | 68 std::vector<ui::LatencyInfo> latency; |
| 69 host_->OnHostMsgFlush(&context, latency); |
| 68 host_->ViewFlushedPaint(); | 70 host_->ViewFlushedPaint(); |
| 69 host_->SendOffscreenFlushAck(); | 71 host_->SendOffscreenFlushAck(); |
| 70 } | 72 } |
| 71 | 73 |
| 72 void PaintToWebCanvas(SkBitmap* bitmap) { | 74 void PaintToWebCanvas(SkBitmap* bitmap) { |
| 73 scoped_ptr<WebCanvas> canvas(new WebCanvas(*bitmap)); | 75 scoped_ptr<WebCanvas> canvas(new WebCanvas(*bitmap)); |
| 74 gfx::Rect plugin_rect(PP_ToGfxRect(renderer_view_data_.rect)); | 76 gfx::Rect plugin_rect(PP_ToGfxRect(renderer_view_data_.rect)); |
| 75 host_->Paint(canvas.get(), | 77 host_->Paint(canvas.get(), |
| 76 plugin_rect, | 78 plugin_rect, |
| 77 gfx::Rect(0, 0, plugin_rect.width(), plugin_rect.height())); | 79 gfx::Rect(0, 0, plugin_rect.width(), plugin_rect.height())); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 EXPECT_EQ(delta, gfx::Point(tests[i].dx2, tests[i].dy2)); | 160 EXPECT_EQ(delta, gfx::Point(tests[i].dx2, tests[i].dy2)); |
| 159 } | 161 } |
| 160 // Reverse the scale and ensure all the original pixels are still inside | 162 // Reverse the scale and ensure all the original pixels are still inside |
| 161 // the result. | 163 // the result. |
| 162 ConvertToLogicalPixels(1.0f / tests[i].scale, &r1, NULL); | 164 ConvertToLogicalPixels(1.0f / tests[i].scale, &r1, NULL); |
| 163 EXPECT_TRUE(r1.Contains(orig)); | 165 EXPECT_TRUE(r1.Contains(orig)); |
| 164 } | 166 } |
| 165 } | 167 } |
| 166 | 168 |
| 167 } // namespace content | 169 } // namespace content |
| OLD | NEW |