Avi Drissman | 05dfbc82 | 2022-09-13 21:25:34 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Eric Karl | 0ec49506 | 2019-09-10 18:40:15 | [diff] [blame] | 5 | #ifndef GPU_COMMAND_BUFFER_SERVICE_MOCK_TEXTURE_OWNER_H_ |
| 6 | #define GPU_COMMAND_BUFFER_SERVICE_MOCK_TEXTURE_OWNER_H_ |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 7 | |
Vikas Soni | b729ade | 2019-01-24 21:40:11 | [diff] [blame] | 8 | #include <memory> |
| 9 | |
| 10 | #include "base/android/scoped_hardware_buffer_fence_sync.h" |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 11 | #include "base/memory/raw_ptr.h" |
Eric Karl | 0ec49506 | 2019-09-10 18:40:15 | [diff] [blame] | 12 | #include "gpu/command_buffer/service/texture_owner.h" |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 13 | #include "testing/gmock/include/gmock/gmock.h" |
| 14 | #include "testing/gtest/include/gtest/gtest.h" |
Chris Watkins | a60f5b1 | 2017-06-02 19:15:33 | [diff] [blame] | 15 | #include "ui/gl/gl_bindings.h" |
| 16 | #include "ui/gl/gl_context.h" |
| 17 | #include "ui/gl/gl_surface.h" |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 18 | |
Vikas Soni | 0cd28d9 | 2019-08-01 18:57:59 | [diff] [blame] | 19 | using testing::NiceMock; |
| 20 | |
Vikas Soni | aa04e98 | 2019-08-16 20:57:08 | [diff] [blame] | 21 | namespace gpu { |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 22 | |
Chris Watkins | a60f5b1 | 2017-06-02 19:15:33 | [diff] [blame] | 23 | // This is a mock with a small amount of fake functionality too. |
Vikas Soni | e5eda88 | 2018-05-08 18:30:58 | [diff] [blame] | 24 | class MockTextureOwner : public TextureOwner { |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 25 | public: |
Vikas Soni | e5eda88 | 2018-05-08 18:30:58 | [diff] [blame] | 26 | MockTextureOwner(GLuint fake_texture_id, |
| 27 | gl::GLContext* fake_context, |
Khushal | e2d9fa3 | 2019-03-08 00:02:14 | [diff] [blame] | 28 | gl::GLSurface* fake_surface, |
| 29 | bool binds_texture_on_update = false); |
Chris Watkins | a60f5b1 | 2017-06-02 19:15:33 | [diff] [blame] | 30 | |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 31 | MOCK_CONST_METHOD0(GetTextureId, GLuint()); |
| 32 | MOCK_CONST_METHOD0(GetContext, gl::GLContext*()); |
| 33 | MOCK_CONST_METHOD0(GetSurface, gl::GLSurface*()); |
| 34 | MOCK_CONST_METHOD0(CreateJavaSurface, gl::ScopedJavaSurface()); |
Khushal | e2d9fa3 | 2019-03-08 00:02:14 | [diff] [blame] | 35 | MOCK_METHOD0(UpdateTexImage, void()); |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 36 | MOCK_METHOD0(ReleaseBackBuffers, void()); |
Vikas Soni | 5dda089 | 2021-05-10 20:01:52 | [diff] [blame] | 37 | MOCK_METHOD0(ReleaseResources, void()); |
Vikas Soni | 0cd28d9 | 2019-08-01 18:57:59 | [diff] [blame] | 38 | MOCK_METHOD1(SetFrameAvailableCallback, void(const base::RepeatingClosure&)); |
Vasiliy Telezhnikov | f3b4d4e | 2020-05-08 23:33:34 | [diff] [blame] | 39 | MOCK_METHOD3(GetCodedSizeAndVisibleRect, |
Vasiliy Telezhnikov | 605f7fe3 | 2020-07-31 22:40:09 | [diff] [blame] | 40 | bool(gfx::Size rotated_visible_size, |
Vasiliy Telezhnikov | f3b4d4e | 2020-05-08 23:33:34 | [diff] [blame] | 41 | gfx::Size* coded_size, |
| 42 | gfx::Rect* visible_rect)); |
Vasiliy Telezhnikov | c9e34c6 | 2020-12-01 14:40:01 | [diff] [blame] | 43 | MOCK_METHOD1(RunWhenBufferIsAvailable, void(base::OnceClosure)); |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 44 | |
Vasiliy Telezhnikov | c2b79e1 | 2024-01-18 14:54:46 | [diff] [blame] | 45 | MOCK_METHOD2(OnMemoryDump, |
| 46 | bool(const base::trace_event::MemoryDumpArgs& args, |
| 47 | base::trace_event::ProcessMemoryDump* pmd)); |
| 48 | |
Vikas Soni | b729ade | 2019-01-24 21:40:11 | [diff] [blame] | 49 | std::unique_ptr<base::android::ScopedHardwareBufferFenceSync> |
| 50 | GetAHardwareBuffer() override { |
Khushal | a55414a | 2018-10-09 17:13:53 | [diff] [blame] | 51 | get_a_hardware_buffer_count++; |
| 52 | return nullptr; |
| 53 | } |
| 54 | |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 55 | raw_ptr<gl::GLContext> fake_context; |
| 56 | raw_ptr<gl::GLSurface> fake_surface; |
Khushal | a55414a | 2018-10-09 17:13:53 | [diff] [blame] | 57 | int get_a_hardware_buffer_count = 0; |
Chris Watkins | a60f5b1 | 2017-06-02 19:15:33 | [diff] [blame] | 58 | |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 59 | protected: |
Arthur Eubanks | b34721e | 2022-08-24 17:47:20 | [diff] [blame] | 60 | ~MockTextureOwner() override; |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 61 | }; |
| 62 | |
Vikas Soni | aa04e98 | 2019-08-16 20:57:08 | [diff] [blame] | 63 | } // namespace gpu |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 64 | |
Eric Karl | 0ec49506 | 2019-09-10 18:40:15 | [diff] [blame] | 65 | #endif // GPU_COMMAND_BUFFER_SERVICE_MOCK_TEXTURE_OWNER_H_ |