[go: nahoru, domu]

blob: e74ac32600c3718fffabf7dc4102af136f9b21cd [file] [log] [blame]
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_SLIM_TEST_FRAME_SINK_IMPL_H_
#define CC_SLIM_TEST_FRAME_SINK_IMPL_H_
#include <memory>
#include "cc/slim/frame_sink_impl.h"
namespace cc::slim {
class TestFrameSinkImpl : public FrameSinkImpl {
public:
static std::unique_ptr<TestFrameSinkImpl> Create();
~TestFrameSinkImpl() override;
base::WeakPtr<TestFrameSinkImpl> GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
void SetBindToClientResult(bool result) {
DCHECK(!bind_to_client_called_);
bind_to_client_result_ = result;
}
viz::CompositorFrame TakeLastFrame();
bool bind_to_client_called() const { return bind_to_client_called_; }
bool needs_begin_frames() const { return needs_begin_frames_; }
// FrameSinkImpl overrides.
bool BindToClient(FrameSinkImplClient* client) override;
void SetNeedsBeginFrame(bool needs_begin_frame) override;
private:
class TestMojoCompositorFrameSink;
TestFrameSinkImpl(
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
mojo::PendingAssociatedRemote<viz::mojom::CompositorFrameSink>
compositor_frame_sink_associated_remote,
mojo::PendingReceiver<viz::mojom::CompositorFrameSinkClient>
client_receiver,
scoped_refptr<viz::ContextProvider> context_provider,
mojo::PendingAssociatedReceiver<viz::mojom::CompositorFrameSink>
sink_receiver);
std::unique_ptr<TestMojoCompositorFrameSink> mojo_sink_;
bool bind_to_client_called_ = false;
bool bind_to_client_result_ = true;
bool needs_begin_frames_ = false;
base::WeakPtrFactory<TestFrameSinkImpl> weak_factory_{this};
};
} // namespace cc::slim
#endif // CC_SLIM_TEST_FRAME_SINK_IMPL_H_