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