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

Side by Side Diff: ui/ozone/platform/dri/test/mock_dri_wrapper.cc

Issue 821023003: [Ozone-DRI] Listen for swap events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@async-swap
Patch Set: Created 5 years, 11 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
OLDNEW
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 "ui/ozone/platform/dri/test/mock_dri_wrapper.h" 5 #include "ui/ozone/platform/dri/test/mock_dri_wrapper.h"
6 6
7 #include <xf86drm.h> 7 #include <xf86drm.h>
8 #include <xf86drmMode.h> 8 #include <xf86drmMode.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "third_party/skia/include/core/SkCanvas.h" 11 #include "third_party/skia/include/core/SkCanvas.h"
12 #include "ui/ozone/platform/dri/crtc_controller.h"
13 #include "ui/ozone/platform/dri/hardware_display_plane_manager_legacy.h" 12 #include "ui/ozone/platform/dri/hardware_display_plane_manager_legacy.h"
14 13
15 namespace ui { 14 namespace ui {
16 15
17 namespace { 16 namespace {
18 17
19 template<class Object> Object* DrmAllocator() { 18 template<class Object> Object* DrmAllocator() {
20 return static_cast<Object*>(drmMalloc(sizeof(Object))); 19 return static_cast<Object*>(drmMalloc(sizeof(Object)));
21 } 20 }
22 21
(...skipping 11 matching lines...) Expand all
34 planes_.push_back( 33 planes_.push_back(
35 new HardwareDisplayPlane(kPlaneBaseId + i, 1 << crtc_idx)); 34 new HardwareDisplayPlane(kPlaneBaseId + i, 1 << crtc_idx));
36 } 35 }
37 } 36 }
38 } 37 }
39 }; 38 };
40 39
41 } // namespace 40 } // namespace
42 41
43 MockDriWrapper::MockDriWrapper(int fd) 42 MockDriWrapper::MockDriWrapper(int fd)
44 : DriWrapper(""), 43 : DriWrapper("", true),
45 get_crtc_call_count_(0), 44 get_crtc_call_count_(0),
46 set_crtc_call_count_(0), 45 set_crtc_call_count_(0),
47 restore_crtc_call_count_(0), 46 restore_crtc_call_count_(0),
48 add_framebuffer_call_count_(0), 47 add_framebuffer_call_count_(0),
49 remove_framebuffer_call_count_(0), 48 remove_framebuffer_call_count_(0),
50 page_flip_call_count_(0), 49 page_flip_call_count_(0),
51 overlay_flip_call_count_(0), 50 overlay_flip_call_count_(0),
52 handle_events_count_(0),
53 set_crtc_expectation_(true), 51 set_crtc_expectation_(true),
54 add_framebuffer_expectation_(true), 52 add_framebuffer_expectation_(true),
55 page_flip_expectation_(true), 53 page_flip_expectation_(true),
56 create_dumb_buffer_expectation_(true), 54 create_dumb_buffer_expectation_(true),
57 current_framebuffer_(0) { 55 current_framebuffer_(0) {
58 fd_ = fd; 56 fd_ = fd;
59 plane_manager_.reset(new HardwareDisplayPlaneManagerLegacy()); 57 plane_manager_.reset(new HardwareDisplayPlaneManagerLegacy());
60 } 58 }
61 59
62 MockDriWrapper::MockDriWrapper(int fd, 60 MockDriWrapper::MockDriWrapper(int fd,
63 std::vector<uint32_t> crtcs, 61 std::vector<uint32_t> crtcs,
64 size_t planes_per_crtc) 62 size_t planes_per_crtc)
65 : DriWrapper(""), 63 : DriWrapper("", true),
66 get_crtc_call_count_(0), 64 get_crtc_call_count_(0),
67 set_crtc_call_count_(0), 65 set_crtc_call_count_(0),
68 restore_crtc_call_count_(0), 66 restore_crtc_call_count_(0),
69 add_framebuffer_call_count_(0), 67 add_framebuffer_call_count_(0),
70 remove_framebuffer_call_count_(0), 68 remove_framebuffer_call_count_(0),
71 page_flip_call_count_(0), 69 page_flip_call_count_(0),
72 overlay_flip_call_count_(0), 70 overlay_flip_call_count_(0),
73 handle_events_count_(0),
74 set_crtc_expectation_(true), 71 set_crtc_expectation_(true),
75 add_framebuffer_expectation_(true), 72 add_framebuffer_expectation_(true),
76 page_flip_expectation_(true), 73 page_flip_expectation_(true),
77 create_dumb_buffer_expectation_(true), 74 create_dumb_buffer_expectation_(true),
78 current_framebuffer_(0) { 75 current_framebuffer_(0) {
79 fd_ = fd; 76 fd_ = fd;
80 plane_manager_.reset( 77 plane_manager_.reset(
81 new MockHardwareDisplayPlaneManager(this, crtcs, planes_per_crtc)); 78 new MockHardwareDisplayPlaneManager(this, crtcs, planes_per_crtc));
82 } 79 }
83 80
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 remove_framebuffer_call_count_++; 127 remove_framebuffer_call_count_++;
131 return true; 128 return true;
132 } 129 }
133 130
134 ScopedDrmFramebufferPtr MockDriWrapper::GetFramebuffer(uint32_t framebuffer) { 131 ScopedDrmFramebufferPtr MockDriWrapper::GetFramebuffer(uint32_t framebuffer) {
135 return ScopedDrmFramebufferPtr(); 132 return ScopedDrmFramebufferPtr();
136 } 133 }
137 134
138 bool MockDriWrapper::PageFlip(uint32_t crtc_id, 135 bool MockDriWrapper::PageFlip(uint32_t crtc_id,
139 uint32_t framebuffer, 136 uint32_t framebuffer,
140 void* data) { 137 const PageFlipCallback& callback) {
141 page_flip_call_count_++; 138 page_flip_call_count_++;
142 current_framebuffer_ = framebuffer; 139 current_framebuffer_ = framebuffer;
143 controllers_.push(static_cast<ui::CrtcController*>(data)); 140 if (page_flip_expectation_)
141 callback.Run(0, 0, 0);
142
144 return page_flip_expectation_; 143 return page_flip_expectation_;
145 } 144 }
146 145
147 bool MockDriWrapper::PageFlipOverlay(uint32_t crtc_id, 146 bool MockDriWrapper::PageFlipOverlay(uint32_t crtc_id,
148 uint32_t framebuffer, 147 uint32_t framebuffer,
149 const gfx::Rect& location, 148 const gfx::Rect& location,
150 const gfx::Rect& source, 149 const gfx::Rect& source,
151 int overlay_plane) { 150 int overlay_plane) {
152 overlay_flip_call_count_++; 151 overlay_flip_call_count_++;
153 return true; 152 return true;
(...skipping 23 matching lines...) Expand all
177 bool MockDriWrapper::SetCursor(uint32_t crtc_id, 176 bool MockDriWrapper::SetCursor(uint32_t crtc_id,
178 uint32_t handle, 177 uint32_t handle,
179 const gfx::Size& size) { 178 const gfx::Size& size) {
180 return true; 179 return true;
181 } 180 }
182 181
183 bool MockDriWrapper::MoveCursor(uint32_t crtc_id, const gfx::Point& point) { 182 bool MockDriWrapper::MoveCursor(uint32_t crtc_id, const gfx::Point& point) {
184 return true; 183 return true;
185 } 184 }
186 185
187 void MockDriWrapper::HandleEvent(drmEventContext& event) {
188 CHECK(!controllers_.empty());
189 controllers_.front()->OnPageFlipEvent(0, 0, 0);
190 controllers_.pop();
191 handle_events_count_++;
192 }
193
194 bool MockDriWrapper::CreateDumbBuffer(const SkImageInfo& info, 186 bool MockDriWrapper::CreateDumbBuffer(const SkImageInfo& info,
195 uint32_t* handle, 187 uint32_t* handle,
196 uint32_t* stride, 188 uint32_t* stride,
197 void** pixels) { 189 void** pixels) {
198 if (!create_dumb_buffer_expectation_) 190 if (!create_dumb_buffer_expectation_)
199 return false; 191 return false;
200 192
201 *handle = 0; 193 *handle = 0;
202 *stride = info.minRowBytes(); 194 *stride = info.minRowBytes();
203 *pixels = new char[info.getSafeSize(*stride)]; 195 *pixels = new char[info.getSafeSize(*stride)];
204 buffers_.push_back( 196 buffers_.push_back(
205 skia::AdoptRef(SkSurface::NewRasterDirect(info, *pixels, *stride))); 197 skia::AdoptRef(SkSurface::NewRasterDirect(info, *pixels, *stride)));
206 buffers_.back()->getCanvas()->clear(SK_ColorBLACK); 198 buffers_.back()->getCanvas()->clear(SK_ColorBLACK);
207 199
208 return true; 200 return true;
209 } 201 }
210 202
211 void MockDriWrapper::DestroyDumbBuffer(const SkImageInfo& info, 203 void MockDriWrapper::DestroyDumbBuffer(const SkImageInfo& info,
212 uint32_t handle, 204 uint32_t handle,
213 uint32_t stride, 205 uint32_t stride,
214 void* pixels) { 206 void* pixels) {
215 delete[] static_cast<char*>(pixels); 207 delete[] static_cast<char*>(pixels);
216 } 208 }
217 209
218 } // namespace ui 210 } // namespace ui
OLDNEW
« ui/ozone/platform/dri/crtc_controller.h ('K') | « ui/ozone/platform/dri/test/mock_dri_wrapper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698