gfx::Rect picture;
};
+class OutputSurfaceScaler : public OutputSurface {
+ public:
+ OutputSurfaceScaler() = default;
+ virtual ~OutputSurfaceScaler() = default;
+
+ virtual bool Initialize(Plane plane) = 0;
+ virtual gfx::VideoOutputMode PrepareToRender(base::UnguessableToken,
+ bool) = 0;
+ virtual void SetBelowParent() = 0;
+};
+
// Real implementation of surface that actually does rendering
// to scaler and holds platform resources.
-class OutputSurfaceImpl : public OutputSurface {
+class OutputSurfaceImpl : public OutputSurfaceScaler {
public:
OutputSurfaceImpl(int device_id,
const RenderingWorkarounds& rendering_workarounds);
~OutputSurfaceImpl() override;
- bool Initialize(Plane plane);
+ bool Initialize(Plane plane) override;
- gfx::VideoOutputMode PrepareToRender(base::UnguessableToken, bool);
+ gfx::VideoOutputMode PrepareToRender(base::UnguessableToken, bool) override;
// Might be called on different thread than creation and initialization
// was done. It's also common scenario that each decoder has it's own
gfx::Size,
gfx::OverlayRenderData) override;
- void SetBelowParent();
+ void SetBelowParent() override;
private:
void EnableSeqMode(bool enabled);
} // namespace
OutputSurfaceProxy::OutputSurfaceProxy(
- const RenderingWorkarounds& rendering_workarounds)
+ const RenderingWorkarounds& rendering_workarounds,
+ base::RepeatingCallback<std::unique_ptr<OutputSurfaceScaler>(
+ int device_id,
+ const RenderingWorkarounds& rendering_workarounds)> create_surface_cb)
: worker_thread_("output_surface_worker"),
- rendering_workarounds_(rendering_workarounds) {}
+ rendering_workarounds_(rendering_workarounds),
+ create_surface_cb_(std::move(create_surface_cb)) {}
OutputSurfaceProxy::~OutputSurfaceProxy() {
TIZEN_MEDIA_LOG(INFO);
// First one is explicitly checking for initialization.
// TODO(vdwasm) |SetBelowParent| should be considered to move to worker thread
// if there are against that.
- impl_ =
- std::make_unique<OutputSurfaceImpl>(device_id, rendering_workarounds_);
+ impl_ = create_surface_cb_.Run(device_id, rendering_workarounds_);
bool result = impl_->Initialize(plane_);
if (!result) {
public base::RefCountedThreadSafe<OutputSurfaceProxy> {
public:
explicit OutputSurfaceProxy(
- const RenderingWorkarounds& rendering_workarounds);
+ const RenderingWorkarounds& rendering_workarounds,
+ base::RepeatingCallback<std::unique_ptr<OutputSurfaceScaler>(
+ int device_id,
+ const RenderingWorkarounds& rendering_workarounds)>
+ create_surface_cb);
// Called on client (viz compositor/decoder) thread.
bool Initialize(Plane plane, base::OnceCallback<void(Plane)> conflict_cb);
base::ConditionVariable initialization_done_{&lock_};
// Implementation for accessing scaler, note it's not permitted
// to call any method on this object without holding |scaler_token_|.
- std::unique_ptr<OutputSurfaceImpl> impl_ GUARDED_BY(lock_);
+ std::unique_ptr<OutputSurfaceScaler> impl_ GUARDED_BY(lock_);
base::OnceCallback<void(Plane)> conflict_cb_ GUARDED_BY(lock_);
bool initialized_ GUARDED_BY(lock_) = false;
int device_id_ GUARDED_BY(lock_) = 0;
const RenderingWorkarounds rendering_workarounds_;
+ base::RepeatingCallback<std::unique_ptr<OutputSurfaceScaler>(
+ int device_id,
+ const RenderingWorkarounds& rendering_workarounds)>
+ create_surface_cb_;
+
base::WeakPtr<OutputSurfaceProxy> weak_this_on_worker_;
base::WeakPtrFactory<OutputSurfaceProxy> weak_factory_on_worker_{this};
};
base::OnceCallback<void(OutputSurface::Plane)> conflict_cb,
const ui::RenderingWorkarounds& rendering_workarounds) {
TIZEN_MEDIA_LOG(INFO) << "Allocate new surface: " << plane_;
- auto temp_surface =
- base::MakeRefCounted<ui::OutputSurfaceProxy>(rendering_workarounds);
+
+ auto create_surface_cb = base::BindRepeating(
+ [](int device_id, const RenderingWorkarounds& rendering_workarounds)
+ -> std::unique_ptr<OutputSurfaceScaler> {
+ return std::make_unique<OutputSurfaceImpl>(device_id,
+ rendering_workarounds);
+ });
+ auto temp_surface = base::MakeRefCounted<ui::OutputSurfaceProxy>(
+ rendering_workarounds, std::move(create_surface_cb));
if (!temp_surface->Initialize(plane_, std::move(conflict_cb))) {
TIZEN_MEDIA_LOG(INFO) << "Failed to initialize surface: " << plane_;
state_ = State::kError;