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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 void Flush() { | 66 void Flush() { |
67 ppapi::host::HostMessageContext context( | 67 ppapi::host::HostMessageContext context( |
68 ppapi::proxy::ResourceMessageCallParams(host_->pp_resource(), 0)); | 68 ppapi::proxy::ResourceMessageCallParams(host_->pp_resource(), 0)); |
69 host_->OnHostMsgFlush(&context); | 69 host_->OnHostMsgFlush(&context); |
70 host_->ViewInitiatedPaint(); | 70 host_->ViewInitiatedPaint(); |
71 host_->SendOffscreenFlushAck(); | 71 host_->SendOffscreenFlushAck(); |
72 } | 72 } |
73 | 73 |
74 void PaintToWebCanvas(SkBitmap* bitmap) { | 74 void PaintToWebCanvas(SkBitmap* bitmap) { |
75 scoped_ptr<WebCanvas> canvas(new WebCanvas(*bitmap)); | 75 std::unique_ptr<WebCanvas> canvas(new WebCanvas(*bitmap)); |
76 gfx::Rect plugin_rect(PP_ToGfxRect(renderer_view_data_.rect)); | 76 gfx::Rect plugin_rect(PP_ToGfxRect(renderer_view_data_.rect)); |
77 host_->Paint(canvas.get(), | 77 host_->Paint(canvas.get(), |
78 plugin_rect, | 78 plugin_rect, |
79 gfx::Rect(0, 0, plugin_rect.width(), plugin_rect.height())); | 79 gfx::Rect(0, 0, plugin_rect.width(), plugin_rect.height())); |
80 } | 80 } |
81 | 81 |
82 void ResetPageBitmap(SkBitmap* bitmap) { | 82 void ResetPageBitmap(SkBitmap* bitmap) { |
83 PP_Rect plugin_rect = renderer_view_data_.rect; | 83 PP_Rect plugin_rect = renderer_view_data_.rect; |
84 int width = plugin_rect.point.x + plugin_rect.size.width; | 84 int width = plugin_rect.point.x + plugin_rect.size.width; |
85 int height = plugin_rect.point.y + plugin_rect.size.height; | 85 int height = plugin_rect.point.y + plugin_rect.size.height; |
86 if (bitmap->isNull() || bitmap->width() != width || | 86 if (bitmap->isNull() || bitmap->width() != width || |
87 bitmap->height() != height) { | 87 bitmap->height() != height) { |
88 bitmap->allocN32Pixels(width, height); | 88 bitmap->allocN32Pixels(width, height); |
89 } | 89 } |
90 bitmap->eraseColor(0); | 90 bitmap->eraseColor(0); |
91 } | 91 } |
92 | 92 |
93 private: | 93 private: |
94 ppapi::ViewData renderer_view_data_; | 94 ppapi::ViewData renderer_view_data_; |
95 scoped_ptr<PepperGraphics2DHost> host_; | 95 std::unique_ptr<PepperGraphics2DHost> host_; |
96 base::MessageLoop message_loop_; | 96 base::MessageLoop message_loop_; |
97 MockRendererPpapiHost renderer_ppapi_host_; | 97 MockRendererPpapiHost renderer_ppapi_host_; |
98 ppapi::TestGlobals test_globals_; | 98 ppapi::TestGlobals test_globals_; |
99 }; | 99 }; |
100 | 100 |
101 TEST_F(PepperGraphics2DHostTest, ConvertToLogicalPixels) { | 101 TEST_F(PepperGraphics2DHostTest, ConvertToLogicalPixels) { |
102 static const struct { | 102 static const struct { |
103 int x1; | 103 int x1; |
104 int y1; | 104 int y1; |
105 int w1; | 105 int w1; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 EXPECT_EQ(delta, gfx::Point(tests[i].dx2, tests[i].dy2)); | 159 EXPECT_EQ(delta, gfx::Point(tests[i].dx2, tests[i].dy2)); |
160 } | 160 } |
161 // Reverse the scale and ensure all the original pixels are still inside | 161 // Reverse the scale and ensure all the original pixels are still inside |
162 // the result. | 162 // the result. |
163 ConvertToLogicalPixels(1.0f / tests[i].scale, &r1, NULL); | 163 ConvertToLogicalPixels(1.0f / tests[i].scale, &r1, NULL); |
164 EXPECT_TRUE(r1.Contains(orig)); | 164 EXPECT_TRUE(r1.Contains(orig)); |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
168 } // namespace content | 168 } // namespace content |
OLD | NEW |