[go: nahoru, domu]

blob: 9858f522e29d02199794f12657c770f75089b08e [file] [log] [blame]
Avi Drissman05dfbc822022-09-13 21:25:341// Copyright 2017 The Chromium Authors
Chris Watkins05681d392017-06-01 18:53:072// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Eric Karl0ec495062019-09-10 18:40:155#ifndef GPU_COMMAND_BUFFER_SERVICE_MOCK_TEXTURE_OWNER_H_
6#define GPU_COMMAND_BUFFER_SERVICE_MOCK_TEXTURE_OWNER_H_
Chris Watkins05681d392017-06-01 18:53:077
Vikas Sonib729ade2019-01-24 21:40:118#include <memory>
9
10#include "base/android/scoped_hardware_buffer_fence_sync.h"
Keishi Hattori0e45c022021-11-27 09:25:5211#include "base/memory/raw_ptr.h"
Eric Karl0ec495062019-09-10 18:40:1512#include "gpu/command_buffer/service/texture_owner.h"
Chris Watkins05681d392017-06-01 18:53:0713#include "testing/gmock/include/gmock/gmock.h"
14#include "testing/gtest/include/gtest/gtest.h"
Chris Watkinsa60f5b12017-06-02 19:15:3315#include "ui/gl/gl_bindings.h"
16#include "ui/gl/gl_context.h"
17#include "ui/gl/gl_surface.h"
Chris Watkins05681d392017-06-01 18:53:0718
Vikas Soni0cd28d92019-08-01 18:57:5919using testing::NiceMock;
20
Vikas Soniaa04e982019-08-16 20:57:0821namespace gpu {
Chris Watkins05681d392017-06-01 18:53:0722
Chris Watkinsa60f5b12017-06-02 19:15:3323// This is a mock with a small amount of fake functionality too.
Vikas Sonie5eda882018-05-08 18:30:5824class MockTextureOwner : public TextureOwner {
Chris Watkins05681d392017-06-01 18:53:0725 public:
Vikas Sonie5eda882018-05-08 18:30:5826 MockTextureOwner(GLuint fake_texture_id,
27 gl::GLContext* fake_context,
Khushale2d9fa32019-03-08 00:02:1428 gl::GLSurface* fake_surface,
29 bool binds_texture_on_update = false);
Chris Watkinsa60f5b12017-06-02 19:15:3330
Chris Watkins05681d392017-06-01 18:53:0731 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());
Khushale2d9fa32019-03-08 00:02:1435 MOCK_METHOD0(UpdateTexImage, void());
Chris Watkins05681d392017-06-01 18:53:0736 MOCK_METHOD0(ReleaseBackBuffers, void());
Vikas Soni5dda0892021-05-10 20:01:5237 MOCK_METHOD0(ReleaseResources, void());
Vikas Soni0cd28d92019-08-01 18:57:5938 MOCK_METHOD1(SetFrameAvailableCallback, void(const base::RepeatingClosure&));
Vasiliy Telezhnikovf3b4d4e2020-05-08 23:33:3439 MOCK_METHOD3(GetCodedSizeAndVisibleRect,
Vasiliy Telezhnikov605f7fe32020-07-31 22:40:0940 bool(gfx::Size rotated_visible_size,
Vasiliy Telezhnikovf3b4d4e2020-05-08 23:33:3441 gfx::Size* coded_size,
42 gfx::Rect* visible_rect));
Vasiliy Telezhnikovc9e34c62020-12-01 14:40:0143 MOCK_METHOD1(RunWhenBufferIsAvailable, void(base::OnceClosure));
Chris Watkins05681d392017-06-01 18:53:0744
Vasiliy Telezhnikovc2b79e12024-01-18 14:54:4645 MOCK_METHOD2(OnMemoryDump,
46 bool(const base::trace_event::MemoryDumpArgs& args,
47 base::trace_event::ProcessMemoryDump* pmd));
48
Vikas Sonib729ade2019-01-24 21:40:1149 std::unique_ptr<base::android::ScopedHardwareBufferFenceSync>
50 GetAHardwareBuffer() override {
Khushala55414a2018-10-09 17:13:5351 get_a_hardware_buffer_count++;
52 return nullptr;
53 }
54
Keishi Hattori0e45c022021-11-27 09:25:5255 raw_ptr<gl::GLContext> fake_context;
56 raw_ptr<gl::GLSurface> fake_surface;
Khushala55414a2018-10-09 17:13:5357 int get_a_hardware_buffer_count = 0;
Chris Watkinsa60f5b12017-06-02 19:15:3358
Chris Watkins05681d392017-06-01 18:53:0759 protected:
Arthur Eubanksb34721e2022-08-24 17:47:2060 ~MockTextureOwner() override;
Chris Watkins05681d392017-06-01 18:53:0761};
62
Vikas Soniaa04e982019-08-16 20:57:0863} // namespace gpu
Chris Watkins05681d392017-06-01 18:53:0764
Eric Karl0ec495062019-09-10 18:40:1565#endif // GPU_COMMAND_BUFFER_SERVICE_MOCK_TEXTURE_OWNER_H_