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

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

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 #ifndef UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRI_WRAPPER_H_ 5 #ifndef UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRI_WRAPPER_H_
6 #define UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRI_WRAPPER_H_ 6 #define UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRI_WRAPPER_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <vector> 9 #include <vector>
10 10
11 #include "skia/ext/refptr.h" 11 #include "skia/ext/refptr.h"
12 #include "third_party/skia/include/core/SkSurface.h" 12 #include "third_party/skia/include/core/SkSurface.h"
13 #include "ui/ozone/platform/dri/dri_wrapper.h" 13 #include "ui/ozone/platform/dri/dri_wrapper.h"
14 14
15 namespace ui { 15 namespace ui {
16 16
17 class CrtcController; 17 class CrtcController;
18 18
19 // The real DriWrapper makes actual DRM calls which we can't use in unit tests. 19 // The real DriWrapper makes actual DRM calls which we can't use in unit tests.
20 class MockDriWrapper : public ui::DriWrapper { 20 class MockDriWrapper : public ui::DriWrapper {
21 public: 21 public:
22 MockDriWrapper(int fd); 22 MockDriWrapper(int fd);
23 MockDriWrapper(int fd, std::vector<uint32_t> crtcs, size_t planes_per_crtc); 23 MockDriWrapper(int fd,
24 bool software_mode,
25 std::vector<uint32_t> crtcs,
26 size_t planes_per_crtc);
24 ~MockDriWrapper() override; 27 ~MockDriWrapper() override;
25 28
26 int get_get_crtc_call_count() const { return get_crtc_call_count_; } 29 int get_get_crtc_call_count() const { return get_crtc_call_count_; }
27 int get_set_crtc_call_count() const { return set_crtc_call_count_; } 30 int get_set_crtc_call_count() const { return set_crtc_call_count_; }
28 int get_restore_crtc_call_count() const { return restore_crtc_call_count_; } 31 int get_restore_crtc_call_count() const { return restore_crtc_call_count_; }
29 int get_add_framebuffer_call_count() const { 32 int get_add_framebuffer_call_count() const {
30 return add_framebuffer_call_count_; 33 return add_framebuffer_call_count_;
31 } 34 }
32 int get_remove_framebuffer_call_count() const { 35 int get_remove_framebuffer_call_count() const {
33 return remove_framebuffer_call_count_; 36 return remove_framebuffer_call_count_;
34 } 37 }
35 int get_page_flip_call_count() const { return page_flip_call_count_; } 38 int get_page_flip_call_count() const { return page_flip_call_count_; }
36 int get_overlay_flip_call_count() const { return overlay_flip_call_count_; } 39 int get_overlay_flip_call_count() const { return overlay_flip_call_count_; }
37 int get_handle_events_count() const { return handle_events_count_; }
38 void fail_init() { fd_ = -1; } 40 void fail_init() { fd_ = -1; }
39 void set_set_crtc_expectation(bool state) { set_crtc_expectation_ = state; } 41 void set_set_crtc_expectation(bool state) { set_crtc_expectation_ = state; }
40 void set_page_flip_expectation(bool state) { page_flip_expectation_ = state; } 42 void set_page_flip_expectation(bool state) { page_flip_expectation_ = state; }
41 void set_add_framebuffer_expectation(bool state) { 43 void set_add_framebuffer_expectation(bool state) {
42 add_framebuffer_expectation_ = state; 44 add_framebuffer_expectation_ = state;
43 } 45 }
44 void set_create_dumb_buffer_expectation(bool state) { 46 void set_create_dumb_buffer_expectation(bool state) {
45 create_dumb_buffer_expectation_ = state; 47 create_dumb_buffer_expectation_ = state;
46 } 48 }
47 49
48 uint32_t current_framebuffer() const { return current_framebuffer_; } 50 uint32_t current_framebuffer() const { return current_framebuffer_; }
49 51
50 const std::vector<skia::RefPtr<SkSurface> > buffers() const { 52 const std::vector<skia::RefPtr<SkSurface> > buffers() const {
51 return buffers_; 53 return buffers_;
52 } 54 }
53 55
54 // Overwrite the list of controllers used when serving the PageFlip requests. 56 void RunCallbacks();
55 void set_controllers(const std::queue<CrtcController*>& controllers) {
56 controllers_ = controllers;
57 }
58 57
59 // DriWrapper: 58 // DriWrapper:
60 ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id) override; 59 ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id) override;
61 bool SetCrtc(uint32_t crtc_id, 60 bool SetCrtc(uint32_t crtc_id,
62 uint32_t framebuffer, 61 uint32_t framebuffer,
63 std::vector<uint32_t> connectors, 62 std::vector<uint32_t> connectors,
64 drmModeModeInfo* mode) override; 63 drmModeModeInfo* mode) override;
65 bool SetCrtc(drmModeCrtc* crtc, std::vector<uint32_t> connectors) override; 64 bool SetCrtc(drmModeCrtc* crtc, std::vector<uint32_t> connectors) override;
66 bool DisableCrtc(uint32_t crtc_id) override; 65 bool DisableCrtc(uint32_t crtc_id) override;
67 ScopedDrmConnectorPtr GetConnector(uint32_t connector_id) override; 66 ScopedDrmConnectorPtr GetConnector(uint32_t connector_id) override;
68 bool AddFramebuffer(uint32_t width, 67 bool AddFramebuffer(uint32_t width,
69 uint32_t height, 68 uint32_t height,
70 uint8_t depth, 69 uint8_t depth,
71 uint8_t bpp, 70 uint8_t bpp,
72 uint32_t stride, 71 uint32_t stride,
73 uint32_t handle, 72 uint32_t handle,
74 uint32_t* framebuffer) override; 73 uint32_t* framebuffer) override;
75 bool RemoveFramebuffer(uint32_t framebuffer) override; 74 bool RemoveFramebuffer(uint32_t framebuffer) override;
76 ScopedDrmFramebufferPtr GetFramebuffer(uint32_t framebuffer) override; 75 ScopedDrmFramebufferPtr GetFramebuffer(uint32_t framebuffer) override;
77 bool PageFlip(uint32_t crtc_id, uint32_t framebuffer, void* data) override; 76 bool PageFlip(uint32_t crtc_id,
77 uint32_t framebuffer,
78 const PageFlipCallback& callback) override;
78 bool PageFlipOverlay(uint32_t crtc_id, 79 bool PageFlipOverlay(uint32_t crtc_id,
79 uint32_t framebuffer, 80 uint32_t framebuffer,
80 const gfx::Rect& location, 81 const gfx::Rect& location,
81 const gfx::Rect& source, 82 const gfx::Rect& source,
82 int overlay_plane) override; 83 int overlay_plane) override;
83 ScopedDrmPropertyPtr GetProperty(drmModeConnector* connector, 84 ScopedDrmPropertyPtr GetProperty(drmModeConnector* connector,
84 const char* name) override; 85 const char* name) override;
85 bool SetProperty(uint32_t connector_id, 86 bool SetProperty(uint32_t connector_id,
86 uint32_t property_id, 87 uint32_t property_id,
87 uint64_t value) override; 88 uint64_t value) override;
88 bool GetCapability(uint64_t capability, uint64_t* value) override; 89 bool GetCapability(uint64_t capability, uint64_t* value) override;
89 ScopedDrmPropertyBlobPtr GetPropertyBlob(drmModeConnector* connector, 90 ScopedDrmPropertyBlobPtr GetPropertyBlob(drmModeConnector* connector,
90 const char* name) override; 91 const char* name) override;
91 bool SetCursor(uint32_t crtc_id, 92 bool SetCursor(uint32_t crtc_id,
92 uint32_t handle, 93 uint32_t handle,
93 const gfx::Size& size) override; 94 const gfx::Size& size) override;
94 bool MoveCursor(uint32_t crtc_id, const gfx::Point& point) override; 95 bool MoveCursor(uint32_t crtc_id, const gfx::Point& point) override;
95 void HandleEvent(drmEventContext& event) override;
96 bool CreateDumbBuffer(const SkImageInfo& info, 96 bool CreateDumbBuffer(const SkImageInfo& info,
97 uint32_t* handle, 97 uint32_t* handle,
98 uint32_t* stride, 98 uint32_t* stride,
99 void** pixels) override; 99 void** pixels) override;
100 void DestroyDumbBuffer(const SkImageInfo& info, 100 void DestroyDumbBuffer(const SkImageInfo& info,
101 uint32_t handle, 101 uint32_t handle,
102 uint32_t stride, 102 uint32_t stride,
103 void* pixels) override; 103 void* pixels) override;
104 104
105 private: 105 private:
106 int get_crtc_call_count_; 106 int get_crtc_call_count_;
107 int set_crtc_call_count_; 107 int set_crtc_call_count_;
108 int restore_crtc_call_count_; 108 int restore_crtc_call_count_;
109 int add_framebuffer_call_count_; 109 int add_framebuffer_call_count_;
110 int remove_framebuffer_call_count_; 110 int remove_framebuffer_call_count_;
111 int page_flip_call_count_; 111 int page_flip_call_count_;
112 int overlay_flip_call_count_; 112 int overlay_flip_call_count_;
113 int handle_events_count_;
114 113
115 bool set_crtc_expectation_; 114 bool set_crtc_expectation_;
116 bool add_framebuffer_expectation_; 115 bool add_framebuffer_expectation_;
117 bool page_flip_expectation_; 116 bool page_flip_expectation_;
118 bool create_dumb_buffer_expectation_; 117 bool create_dumb_buffer_expectation_;
119 118
120 uint32_t current_framebuffer_; 119 uint32_t current_framebuffer_;
121 120
122 std::vector<skia::RefPtr<SkSurface> > buffers_; 121 std::vector<skia::RefPtr<SkSurface> > buffers_;
123 122
124 std::queue<CrtcController*> controllers_; 123 std::queue<PageFlipCallback> callbacks_;
125 124
126 DISALLOW_COPY_AND_ASSIGN(MockDriWrapper); 125 DISALLOW_COPY_AND_ASSIGN(MockDriWrapper);
127 }; 126 };
128 127
129 } // namespace ui 128 } // namespace ui
130 129
131 #endif // UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRI_WRAPPER_H_ 130 #endif // UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRI_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698