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

Side by Side Diff: ui/gfx/blit_unittest.cc

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RenderText fixup Created 8 years, 1 month 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/shared_memory.h" 6 #include "base/shared_memory.h"
7 #include "skia/ext/platform_canvas.h" 7 #include "skia/ext/platform_canvas.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/blit.h" 9 #include "ui/gfx/blit.h"
10 #include "ui/gfx/point.h" 10 #include "ui/gfx/point.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 { 0x30, 0x31, 0x32, 0x33, 0x34 }, 69 { 0x30, 0x31, 0x32, 0x33, 0x34 },
70 { 0x40, 0x41, 0x42, 0x43, 0x44 }}; 70 { 0x40, 0x41, 0x42, 0x43, 0x44 }};
71 SetToCanvas<5, 5>(&canvas, initial_values); 71 SetToCanvas<5, 5>(&canvas, initial_values);
72 72
73 // Sanity check on input. 73 // Sanity check on input.
74 VerifyCanvasValues<5, 5>(&canvas, initial_values); 74 VerifyCanvasValues<5, 5>(&canvas, initial_values);
75 75
76 // Scroll none and make sure it's a NOP. 76 // Scroll none and make sure it's a NOP.
77 gfx::ScrollCanvas(&canvas, 77 gfx::ScrollCanvas(&canvas,
78 gfx::Rect(0, 0, kCanvasWidth, kCanvasHeight), 78 gfx::Rect(0, 0, kCanvasWidth, kCanvasHeight),
79 gfx::Point(0, 0)); 79 gfx::Vector2d(0, 0));
80 VerifyCanvasValues<5, 5>(&canvas, initial_values); 80 VerifyCanvasValues<5, 5>(&canvas, initial_values);
81 81
82 // Scroll the center 3 pixels up one. 82 // Scroll the center 3 pixels up one.
83 gfx::Rect center_three(1, 1, 3, 3); 83 gfx::Rect center_three(1, 1, 3, 3);
84 gfx::ScrollCanvas(&canvas, center_three, gfx::Point(0, -1)); 84 gfx::ScrollCanvas(&canvas, center_three, gfx::Vector2d(0, -1));
85 uint8 scroll_up_expected[kCanvasHeight][kCanvasWidth] = { 85 uint8 scroll_up_expected[kCanvasHeight][kCanvasWidth] = {
86 { 0x00, 0x01, 0x02, 0x03, 0x04 }, 86 { 0x00, 0x01, 0x02, 0x03, 0x04 },
87 { 0x10, 0x21, 0x22, 0x23, 0x14 }, 87 { 0x10, 0x21, 0x22, 0x23, 0x14 },
88 { 0x20, 0x31, 0x32, 0x33, 0x24 }, 88 { 0x20, 0x31, 0x32, 0x33, 0x24 },
89 { 0x30, 0x31, 0x32, 0x33, 0x34 }, 89 { 0x30, 0x31, 0x32, 0x33, 0x34 },
90 { 0x40, 0x41, 0x42, 0x43, 0x44 }}; 90 { 0x40, 0x41, 0x42, 0x43, 0x44 }};
91 VerifyCanvasValues<5, 5>(&canvas, scroll_up_expected); 91 VerifyCanvasValues<5, 5>(&canvas, scroll_up_expected);
92 92
93 // Reset and scroll the center 3 pixels down one. 93 // Reset and scroll the center 3 pixels down one.
94 SetToCanvas<5, 5>(&canvas, initial_values); 94 SetToCanvas<5, 5>(&canvas, initial_values);
95 gfx::ScrollCanvas(&canvas, center_three, gfx::Point(0, 1)); 95 gfx::ScrollCanvas(&canvas, center_three, gfx::Vector2d(0, 1));
96 uint8 scroll_down_expected[kCanvasHeight][kCanvasWidth] = { 96 uint8 scroll_down_expected[kCanvasHeight][kCanvasWidth] = {
97 { 0x00, 0x01, 0x02, 0x03, 0x04 }, 97 { 0x00, 0x01, 0x02, 0x03, 0x04 },
98 { 0x10, 0x11, 0x12, 0x13, 0x14 }, 98 { 0x10, 0x11, 0x12, 0x13, 0x14 },
99 { 0x20, 0x11, 0x12, 0x13, 0x24 }, 99 { 0x20, 0x11, 0x12, 0x13, 0x24 },
100 { 0x30, 0x21, 0x22, 0x23, 0x34 }, 100 { 0x30, 0x21, 0x22, 0x23, 0x34 },
101 { 0x40, 0x41, 0x42, 0x43, 0x44 }}; 101 { 0x40, 0x41, 0x42, 0x43, 0x44 }};
102 VerifyCanvasValues<5, 5>(&canvas, scroll_down_expected); 102 VerifyCanvasValues<5, 5>(&canvas, scroll_down_expected);
103 103
104 // Reset and scroll the center 3 pixels right one. 104 // Reset and scroll the center 3 pixels right one.
105 SetToCanvas<5, 5>(&canvas, initial_values); 105 SetToCanvas<5, 5>(&canvas, initial_values);
106 gfx::ScrollCanvas(&canvas, center_three, gfx::Point(1, 0)); 106 gfx::ScrollCanvas(&canvas, center_three, gfx::Vector2d(1, 0));
107 uint8 scroll_right_expected[kCanvasHeight][kCanvasWidth] = { 107 uint8 scroll_right_expected[kCanvasHeight][kCanvasWidth] = {
108 { 0x00, 0x01, 0x02, 0x03, 0x04 }, 108 { 0x00, 0x01, 0x02, 0x03, 0x04 },
109 { 0x10, 0x11, 0x11, 0x12, 0x14 }, 109 { 0x10, 0x11, 0x11, 0x12, 0x14 },
110 { 0x20, 0x21, 0x21, 0x22, 0x24 }, 110 { 0x20, 0x21, 0x21, 0x22, 0x24 },
111 { 0x30, 0x31, 0x31, 0x32, 0x34 }, 111 { 0x30, 0x31, 0x31, 0x32, 0x34 },
112 { 0x40, 0x41, 0x42, 0x43, 0x44 }}; 112 { 0x40, 0x41, 0x42, 0x43, 0x44 }};
113 VerifyCanvasValues<5, 5>(&canvas, scroll_right_expected); 113 VerifyCanvasValues<5, 5>(&canvas, scroll_right_expected);
114 114
115 // Reset and scroll the center 3 pixels left one. 115 // Reset and scroll the center 3 pixels left one.
116 SetToCanvas<5, 5>(&canvas, initial_values); 116 SetToCanvas<5, 5>(&canvas, initial_values);
117 gfx::ScrollCanvas(&canvas, center_three, gfx::Point(-1, 0)); 117 gfx::ScrollCanvas(&canvas, center_three, gfx::Vector2d(-1, 0));
118 uint8 scroll_left_expected[kCanvasHeight][kCanvasWidth] = { 118 uint8 scroll_left_expected[kCanvasHeight][kCanvasWidth] = {
119 { 0x00, 0x01, 0x02, 0x03, 0x04 }, 119 { 0x00, 0x01, 0x02, 0x03, 0x04 },
120 { 0x10, 0x12, 0x13, 0x13, 0x14 }, 120 { 0x10, 0x12, 0x13, 0x13, 0x14 },
121 { 0x20, 0x22, 0x23, 0x23, 0x24 }, 121 { 0x20, 0x22, 0x23, 0x23, 0x24 },
122 { 0x30, 0x32, 0x33, 0x33, 0x34 }, 122 { 0x30, 0x32, 0x33, 0x33, 0x34 },
123 { 0x40, 0x41, 0x42, 0x43, 0x44 }}; 123 { 0x40, 0x41, 0x42, 0x43, 0x44 }};
124 VerifyCanvasValues<5, 5>(&canvas, scroll_left_expected); 124 VerifyCanvasValues<5, 5>(&canvas, scroll_left_expected);
125 125
126 // Diagonal scroll. 126 // Diagonal scroll.
127 SetToCanvas<5, 5>(&canvas, initial_values); 127 SetToCanvas<5, 5>(&canvas, initial_values);
128 gfx::ScrollCanvas(&canvas, center_three, gfx::Point(2, 2)); 128 gfx::ScrollCanvas(&canvas, center_three, gfx::Vector2d(2, 2));
129 uint8 scroll_diagonal_expected[kCanvasHeight][kCanvasWidth] = { 129 uint8 scroll_diagonal_expected[kCanvasHeight][kCanvasWidth] = {
130 { 0x00, 0x01, 0x02, 0x03, 0x04 }, 130 { 0x00, 0x01, 0x02, 0x03, 0x04 },
131 { 0x10, 0x11, 0x12, 0x13, 0x14 }, 131 { 0x10, 0x11, 0x12, 0x13, 0x14 },
132 { 0x20, 0x21, 0x22, 0x23, 0x24 }, 132 { 0x20, 0x21, 0x22, 0x23, 0x24 },
133 { 0x30, 0x31, 0x32, 0x11, 0x34 }, 133 { 0x30, 0x31, 0x32, 0x11, 0x34 },
134 { 0x40, 0x41, 0x42, 0x43, 0x44 }}; 134 { 0x40, 0x41, 0x42, 0x43, 0x44 }};
135 VerifyCanvasValues<5, 5>(&canvas, scroll_diagonal_expected); 135 VerifyCanvasValues<5, 5>(&canvas, scroll_diagonal_expected);
136 } 136 }
137 137
138 #if defined(OS_WIN) 138 #if defined(OS_WIN)
(...skipping 15 matching lines...) Expand all
154 { 0x30, 0x31, 0x32, 0x33, 0x34 }, 154 { 0x30, 0x31, 0x32, 0x33, 0x34 },
155 { 0x40, 0x41, 0x42, 0x43, 0x44 }}; 155 { 0x40, 0x41, 0x42, 0x43, 0x44 }};
156 SetToCanvas<5, 5>(&canvas, initial_values); 156 SetToCanvas<5, 5>(&canvas, initial_values);
157 157
158 // Sanity check on input. 158 // Sanity check on input.
159 VerifyCanvasValues<5, 5>(&canvas, initial_values); 159 VerifyCanvasValues<5, 5>(&canvas, initial_values);
160 } 160 }
161 161
162 #endif 162 #endif
163 163
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698