Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 1 | // Copyright 2017 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 | |
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" |
Eric Karl | 0ec49506 | 2019-09-10 18:40:15 | [diff] [blame] | 11 | #include "gpu/command_buffer/service/texture_owner.h" |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 12 | #include "testing/gmock/include/gmock/gmock.h" |
| 13 | #include "testing/gtest/include/gtest/gtest.h" |
Chris Watkins | a60f5b1 | 2017-06-02 19:15:33 | [diff] [blame] | 14 | #include "ui/gl/gl_bindings.h" |
| 15 | #include "ui/gl/gl_context.h" |
| 16 | #include "ui/gl/gl_surface.h" |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 17 | |
Vikas Soni | 0cd28d9 | 2019-08-01 18:57:59 | [diff] [blame] | 18 | using testing::NiceMock; |
| 19 | |
Vikas Soni | aa04e98 | 2019-08-16 20:57:08 | [diff] [blame] | 20 | namespace gpu { |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 21 | |
Chris Watkins | a60f5b1 | 2017-06-02 19:15:33 | [diff] [blame] | 22 | // This is a mock with a small amount of fake functionality too. |
Vikas Soni | e5eda88 | 2018-05-08 18:30:58 | [diff] [blame] | 23 | class MockTextureOwner : public TextureOwner { |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 24 | public: |
Vikas Soni | e5eda88 | 2018-05-08 18:30:58 | [diff] [blame] | 25 | MockTextureOwner(GLuint fake_texture_id, |
| 26 | gl::GLContext* fake_context, |
Khushal | e2d9fa3 | 2019-03-08 00:02:14 | [diff] [blame] | 27 | gl::GLSurface* fake_surface, |
| 28 | bool binds_texture_on_update = false); |
Chris Watkins | a60f5b1 | 2017-06-02 19:15:33 | [diff] [blame] | 29 | |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 30 | MOCK_CONST_METHOD0(GetTextureId, GLuint()); |
| 31 | MOCK_CONST_METHOD0(GetContext, gl::GLContext*()); |
| 32 | MOCK_CONST_METHOD0(GetSurface, gl::GLSurface*()); |
| 33 | MOCK_CONST_METHOD0(CreateJavaSurface, gl::ScopedJavaSurface()); |
Khushal | e2d9fa3 | 2019-03-08 00:02:14 | [diff] [blame] | 34 | MOCK_METHOD0(UpdateTexImage, void()); |
| 35 | MOCK_METHOD0(EnsureTexImageBound, void()); |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 36 | MOCK_METHOD0(ReleaseBackBuffers, void()); |
liberato@chromium.org | c321478 | 2018-12-19 22:27:10 | [diff] [blame] | 37 | MOCK_METHOD1(OnTextureDestroyed, void(gpu::gles2::AbstractTexture*)); |
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)); |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 43 | |
Vikas Soni | b729ade | 2019-01-24 21:40:11 | [diff] [blame] | 44 | std::unique_ptr<base::android::ScopedHardwareBufferFenceSync> |
| 45 | GetAHardwareBuffer() override { |
Khushal | a55414a | 2018-10-09 17:13:53 | [diff] [blame] | 46 | get_a_hardware_buffer_count++; |
| 47 | return nullptr; |
| 48 | } |
| 49 | |
Chris Watkins | a60f5b1 | 2017-06-02 19:15:33 | [diff] [blame] | 50 | gl::GLContext* fake_context; |
| 51 | gl::GLSurface* fake_surface; |
Khushal | a55414a | 2018-10-09 17:13:53 | [diff] [blame] | 52 | int get_a_hardware_buffer_count = 0; |
Khushal | e2d9fa3 | 2019-03-08 00:02:14 | [diff] [blame] | 53 | bool expect_update_tex_image; |
Chris Watkins | a60f5b1 | 2017-06-02 19:15:33 | [diff] [blame] | 54 | |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 55 | protected: |
Vikas Soni | e5eda88 | 2018-05-08 18:30:58 | [diff] [blame] | 56 | ~MockTextureOwner(); |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 57 | }; |
| 58 | |
Vikas Soni | aa04e98 | 2019-08-16 20:57:08 | [diff] [blame] | 59 | } // namespace gpu |
Chris Watkins | 05681d39 | 2017-06-01 18:53:07 | [diff] [blame] | 60 | |
Eric Karl | 0ec49506 | 2019-09-10 18:40:15 | [diff] [blame] | 61 | #endif // GPU_COMMAND_BUFFER_SERVICE_MOCK_TEXTURE_OWNER_H_ |