Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(968)

Side by Side Diff: webkit/plugins/ppapi/ppb_graphics_2d_impl_unittest.cc

Issue 11146009: Mac Flash: Fix scaling bitmap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/ppb_graphics_2d_impl.h ('k') | webkit/tools/test_shell/test_shell.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "ui/gfx/point.h" 7 #include "ui/gfx/point.h"
8 #include "ui/gfx/rect.h" 8 #include "ui/gfx/rect.h"
9 #include "ui/gfx/safe_integer_conversions.h"
10 #include "webkit/plugins/ppapi/ppapi_unittest.h"
11 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
9 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" 12 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
10 13
11 TEST(PpapiGraphics2DImplTest, ConvertToLogicalPixels) { 14 namespace webkit {
15 namespace ppapi {
16
17 typedef PpapiUnittest PpapiGraphics2DImplTest;
18
19 TEST_F(PpapiGraphics2DImplTest, ConvertToLogicalPixels) {
12 static const struct { 20 static const struct {
13 int x1; 21 int x1;
14 int y1; 22 int y1;
15 int w1; 23 int w1;
16 int h1; 24 int h1;
17 int x2; 25 int x2;
18 int y2; 26 int y2;
19 int w2; 27 int w2;
20 int h2; 28 int h2;
21 int dx1; 29 int dx1;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 if (res) { 79 if (res) {
72 EXPECT_EQ(delta, gfx::Point(tests[i].dx2, tests[i].dy2)); 80 EXPECT_EQ(delta, gfx::Point(tests[i].dx2, tests[i].dy2));
73 } 81 }
74 // Reverse the scale and ensure all the original pixels are still inside 82 // Reverse the scale and ensure all the original pixels are still inside
75 // the result. 83 // the result.
76 webkit::ppapi::PPB_Graphics2D_Impl::ConvertToLogicalPixels( 84 webkit::ppapi::PPB_Graphics2D_Impl::ConvertToLogicalPixels(
77 1.0f / tests[i].scale, &r1, NULL); 85 1.0f / tests[i].scale, &r1, NULL);
78 EXPECT_TRUE(r1.Contains(orig)); 86 EXPECT_TRUE(r1.Contains(orig));
79 } 87 }
80 } 88 }
89
90 // Test that GetBitmapForOptimizedPluginPaint doesn't return a bitmap rect
91 // that's bigger than the actual backing store bitmap.
92 TEST_F(PpapiGraphics2DImplTest, GetBitmap2xScale) {
93 PP_Size size;
94 size.width = 3;
95 size.height = 3;
96 PP_Resource resource =
97 PPB_Graphics2D_Impl::Create(instance()->pp_instance(), size, PP_TRUE);
98 EXPECT_TRUE(resource);
99 EXPECT_TRUE(instance()->BindGraphics(instance()->pp_instance(), resource));
100 instance()->set_always_on_top(true);
101 float scale = 2.0;
102 SetViewSize(size.width, size.height, 1.0 / scale);
103
104 gfx::Rect bounds(0, 0, 1, 1);
105 gfx::Rect location;
106 gfx::Rect clip;
107 float bitmap_scale = 0;
108 TransportDIB* dib = NULL;
109 EXPECT_TRUE(instance()->GetBitmapForOptimizedPluginPaint(
110 bounds, &dib, &location, &clip, &bitmap_scale));
111
112 EXPECT_EQ(0, location.x());
113 EXPECT_EQ(0, location.y());
114 EXPECT_EQ(gfx::ToFlooredInt(size.width / scale), location.width());
115 EXPECT_EQ(gfx::ToFlooredInt(size.height / scale), location.height());
116 EXPECT_EQ(0, clip.x());
117 EXPECT_EQ(0, clip.y());
118 EXPECT_EQ(size.width, clip.width());
119 EXPECT_EQ(size.height, clip.height());
120 EXPECT_EQ(scale, bitmap_scale);
121 }
122
123 } // namespace ppapi
124 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_graphics_2d_impl.h ('k') | webkit/tools/test_shell/test_shell.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698