OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 // Mode of size 6x4. | 28 // Mode of size 6x4. |
29 const drmModeModeInfo kDefaultMode = | 29 const drmModeModeInfo kDefaultMode = |
30 {0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}}; | 30 {0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}}; |
31 | 31 |
32 const gfx::AcceleratedWidget kDefaultWidgetHandle = 1; | 32 const gfx::AcceleratedWidget kDefaultWidgetHandle = 1; |
33 const uint32_t kDefaultCrtc = 1; | 33 const uint32_t kDefaultCrtc = 1; |
34 const uint32_t kDefaultConnector = 2; | 34 const uint32_t kDefaultConnector = 2; |
35 const int kDefaultCursorSize = 64; | 35 const int kDefaultCursorSize = 64; |
36 | 36 |
37 std::vector<skia::RefPtr<SkSurface>> GetCursorBuffers( | 37 std::vector<sk_sp<SkSurface>> GetCursorBuffers( |
38 const scoped_refptr<ui::MockDrmDevice> drm) { | 38 const scoped_refptr<ui::MockDrmDevice> drm) { |
39 std::vector<skia::RefPtr<SkSurface>> cursor_buffers; | 39 std::vector<sk_sp<SkSurface>> cursor_buffers; |
40 for (const auto& cursor_buffer : drm->buffers()) { | 40 for (const auto& cursor_buffer : drm->buffers()) { |
41 if (cursor_buffer->width() == kDefaultCursorSize && | 41 if (cursor_buffer->width() == kDefaultCursorSize && |
42 cursor_buffer->height() == kDefaultCursorSize) { | 42 cursor_buffer->height() == kDefaultCursorSize) { |
43 cursor_buffers.push_back(cursor_buffer); | 43 cursor_buffers.push_back(cursor_buffer); |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 return cursor_buffers; | 47 return cursor_buffers; |
48 } | 48 } |
49 | 49 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 message_loop_.reset(); | 113 message_loop_.reset(); |
114 } | 114 } |
115 | 115 |
116 TEST_F(DrmWindowTest, SetCursorImage) { | 116 TEST_F(DrmWindowTest, SetCursorImage) { |
117 const gfx::Size cursor_size(6, 4); | 117 const gfx::Size cursor_size(6, 4); |
118 screen_manager_->GetWindow(kDefaultWidgetHandle) | 118 screen_manager_->GetWindow(kDefaultWidgetHandle) |
119 ->SetCursor(std::vector<SkBitmap>(1, AllocateBitmap(cursor_size)), | 119 ->SetCursor(std::vector<SkBitmap>(1, AllocateBitmap(cursor_size)), |
120 gfx::Point(4, 2), 0); | 120 gfx::Point(4, 2), 0); |
121 | 121 |
122 SkBitmap cursor; | 122 SkBitmap cursor; |
123 std::vector<skia::RefPtr<SkSurface>> cursor_buffers = GetCursorBuffers(drm_); | 123 std::vector<sk_sp<SkSurface>> cursor_buffers = GetCursorBuffers(drm_); |
124 EXPECT_EQ(2u, cursor_buffers.size()); | 124 EXPECT_EQ(2u, cursor_buffers.size()); |
125 | 125 |
126 // Buffers 1 is the cursor backbuffer we just drew in. | 126 // Buffers 1 is the cursor backbuffer we just drew in. |
127 cursor.setInfo(cursor_buffers[1]->getCanvas()->imageInfo()); | 127 cursor.setInfo(cursor_buffers[1]->getCanvas()->imageInfo()); |
128 EXPECT_TRUE(cursor_buffers[1]->getCanvas()->readPixels(&cursor, 0, 0)); | 128 EXPECT_TRUE(cursor_buffers[1]->getCanvas()->readPixels(&cursor, 0, 0)); |
129 | 129 |
130 // Check that the frontbuffer is displaying the right image as set above. | 130 // Check that the frontbuffer is displaying the right image as set above. |
131 for (int i = 0; i < cursor.height(); ++i) { | 131 for (int i = 0; i < cursor.height(); ++i) { |
132 for (int j = 0; j < cursor.width(); ++j) { | 132 for (int j = 0; j < cursor.width(); ++j) { |
133 if (j < cursor_size.width() && i < cursor_size.height()) | 133 if (j < cursor_size.width() && i < cursor_size.height()) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 EXPECT_EQ(1, on_swap_buffers_count_); | 178 EXPECT_EQ(1, on_swap_buffers_count_); |
179 EXPECT_EQ(gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS, | 179 EXPECT_EQ(gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS, |
180 last_swap_buffers_result_); | 180 last_swap_buffers_result_); |
181 | 181 |
182 window->SchedulePageFlip( | 182 window->SchedulePageFlip( |
183 std::vector<ui::OverlayPlane>(1, ui::OverlayPlane(plane)), | 183 std::vector<ui::OverlayPlane>(1, ui::OverlayPlane(plane)), |
184 base::Bind(&DrmWindowTest::OnSwapBuffers, base::Unretained(this))); | 184 base::Bind(&DrmWindowTest::OnSwapBuffers, base::Unretained(this))); |
185 EXPECT_EQ(2, on_swap_buffers_count_); | 185 EXPECT_EQ(2, on_swap_buffers_count_); |
186 EXPECT_EQ(gfx::SwapResult::SWAP_FAILED, last_swap_buffers_result_); | 186 EXPECT_EQ(gfx::SwapResult::SWAP_FAILED, last_swap_buffers_result_); |
187 } | 187 } |
OLD | NEW |