| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 // Mode of size 6x4. | 26 // Mode of size 6x4. |
| 27 const drmModeModeInfo kDefaultMode = | 27 const drmModeModeInfo kDefaultMode = |
| 28 {0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}}; | 28 {0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}}; |
| 29 | 29 |
| 30 const gfx::AcceleratedWidget kDefaultWidgetHandle = 1; | 30 const gfx::AcceleratedWidget kDefaultWidgetHandle = 1; |
| 31 const uint32_t kDefaultCrtc = 1; | 31 const uint32_t kDefaultCrtc = 1; |
| 32 const uint32_t kDefaultConnector = 2; | 32 const uint32_t kDefaultConnector = 2; |
| 33 const int kDefaultCursorSize = 64; | 33 const int kDefaultCursorSize = 64; |
| 34 | 34 |
| 35 std::vector<skia::RefPtr<SkSurface>> GetCursorBuffers( | 35 std::vector<sk_sp<SkSurface>> GetCursorBuffers( |
| 36 const scoped_refptr<ui::MockDrmDevice> drm) { | 36 const scoped_refptr<ui::MockDrmDevice> drm) { |
| 37 std::vector<skia::RefPtr<SkSurface>> cursor_buffers; | 37 std::vector<sk_sp<SkSurface>> cursor_buffers; |
| 38 for (const skia::RefPtr<SkSurface>& cursor_buffer : drm->buffers()) { | 38 for (const sk_sp<SkSurface>& cursor_buffer : drm->buffers()) { |
| 39 if (cursor_buffer->width() == kDefaultCursorSize && | 39 if (cursor_buffer->width() == kDefaultCursorSize && |
| 40 cursor_buffer->height() == kDefaultCursorSize) { | 40 cursor_buffer->height() == kDefaultCursorSize) { |
| 41 cursor_buffers.push_back(cursor_buffer); | 41 cursor_buffers.push_back(cursor_buffer); |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 | 44 |
| 45 return cursor_buffers; | 45 return cursor_buffers; |
| 46 } | 46 } |
| 47 | 47 |
| 48 SkBitmap AllocateBitmap(const gfx::Size& size) { | 48 SkBitmap AllocateBitmap(const gfx::Size& size) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 message_loop_.reset(); | 100 message_loop_.reset(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 TEST_F(DrmWindowTest, SetCursorImage) { | 103 TEST_F(DrmWindowTest, SetCursorImage) { |
| 104 const gfx::Size cursor_size(6, 4); | 104 const gfx::Size cursor_size(6, 4); |
| 105 screen_manager_->GetWindow(kDefaultWidgetHandle) | 105 screen_manager_->GetWindow(kDefaultWidgetHandle) |
| 106 ->SetCursor(std::vector<SkBitmap>(1, AllocateBitmap(cursor_size)), | 106 ->SetCursor(std::vector<SkBitmap>(1, AllocateBitmap(cursor_size)), |
| 107 gfx::Point(4, 2), 0); | 107 gfx::Point(4, 2), 0); |
| 108 | 108 |
| 109 SkBitmap cursor; | 109 SkBitmap cursor; |
| 110 std::vector<skia::RefPtr<SkSurface>> cursor_buffers = GetCursorBuffers(drm_); | 110 std::vector<sk_sp<SkSurface>> cursor_buffers = GetCursorBuffers(drm_); |
| 111 EXPECT_EQ(2u, cursor_buffers.size()); | 111 EXPECT_EQ(2u, cursor_buffers.size()); |
| 112 | 112 |
| 113 // Buffers 1 is the cursor backbuffer we just drew in. | 113 // Buffers 1 is the cursor backbuffer we just drew in. |
| 114 cursor.setInfo(cursor_buffers[1]->getCanvas()->imageInfo()); | 114 cursor.setInfo(cursor_buffers[1]->getCanvas()->imageInfo()); |
| 115 EXPECT_TRUE(cursor_buffers[1]->getCanvas()->readPixels(&cursor, 0, 0)); | 115 EXPECT_TRUE(cursor_buffers[1]->getCanvas()->readPixels(&cursor, 0, 0)); |
| 116 | 116 |
| 117 // Check that the frontbuffer is displaying the right image as set above. | 117 // Check that the frontbuffer is displaying the right image as set above. |
| 118 for (int i = 0; i < cursor.height(); ++i) { | 118 for (int i = 0; i < cursor.height(); ++i) { |
| 119 for (int j = 0; j < cursor.width(); ++j) { | 119 for (int j = 0; j < cursor.width(); ++j) { |
| 120 if (j < cursor_size.width() && i < cursor_size.height()) | 120 if (j < cursor_size.width() && i < cursor_size.height()) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 142 // Move window to the display on the new device. | 142 // Move window to the display on the new device. |
| 143 screen_manager_->GetWindow(kDefaultWidgetHandle) | 143 screen_manager_->GetWindow(kDefaultWidgetHandle) |
| 144 ->OnBoundsChanged(gfx::Rect(0, kDefaultMode.vdisplay, | 144 ->OnBoundsChanged(gfx::Rect(0, kDefaultMode.vdisplay, |
| 145 kDefaultMode.hdisplay, | 145 kDefaultMode.hdisplay, |
| 146 kDefaultMode.vdisplay)); | 146 kDefaultMode.vdisplay)); |
| 147 | 147 |
| 148 EXPECT_EQ(2u, GetCursorBuffers(drm).size()); | 148 EXPECT_EQ(2u, GetCursorBuffers(drm).size()); |
| 149 // Make sure the cursor is showing on the new display. | 149 // Make sure the cursor is showing on the new display. |
| 150 EXPECT_NE(0u, drm->get_cursor_handle_for_crtc(kDefaultCrtc)); | 150 EXPECT_NE(0u, drm->get_cursor_handle_for_crtc(kDefaultCrtc)); |
| 151 } | 151 } |
| OLD | NEW |