summaryrefslogtreecommitdiff
path: root/chromium/components/viz/service/display_embedder/software_output_surface.h
blob: 70b20326e25818ce6adb8b424b3270c9b6697d51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_SOFTWARE_OUTPUT_SURFACE_H_
#define COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_SOFTWARE_OUTPUT_SURFACE_H_

#include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h"
#include "components/viz/service/display/output_surface.h"
#include "components/viz/service/viz_service_export.h"

namespace viz {
class SoftwareOutputDevice;

class VIZ_SERVICE_EXPORT SoftwareOutputSurface : public OutputSurface {
 public:
  SoftwareOutputSurface(std::unique_ptr<SoftwareOutputDevice> software_device,
                        scoped_refptr<base::SequencedTaskRunner> task_runner);
  ~SoftwareOutputSurface() override;

  // OutputSurface implementation.
  void BindToClient(OutputSurfaceClient* client) override;
  void EnsureBackbuffer() override;
  void DiscardBackbuffer() override;
  void BindFramebuffer() override;
  void SetDrawRectangle(const gfx::Rect& draw_rectangle) override;
  void Reshape(const gfx::Size& size,
               float device_scale_factor,
               const gfx::ColorSpace& color_space,
               bool has_alpha,
               bool use_stencil) override;
  void SwapBuffers(OutputSurfaceFrame frame) override;
  bool IsDisplayedAsOverlayPlane() const override;
  OverlayCandidateValidator* GetOverlayCandidateValidator() const override;
  unsigned GetOverlayTextureId() const override;
  gfx::BufferFormat GetOverlayBufferFormat() const override;
  bool HasExternalStencilTest() const override;
  void ApplyExternalStencil() override;
  bool SurfaceIsSuspendForRecycle() const override;
  uint32_t GetFramebufferCopyTextureFormat() override;
#if BUILDFLAG(ENABLE_VULKAN)
  gpu::VulkanSurface* GetVulkanSurface() override;
#endif

 private:
  void SwapBuffersCallback(uint64_t swap_id);

  OutputSurfaceClient* client_ = nullptr;
  scoped_refptr<base::SequencedTaskRunner> task_runner_;
  base::TimeDelta refresh_interval_;
  uint64_t swap_id_ = 0;
  base::WeakPtrFactory<SoftwareOutputSurface> weak_factory_;

  DISALLOW_COPY_AND_ASSIGN(SoftwareOutputSurface);
};

}  // namespace viz

#endif  // COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_SOFTWARE_OUTPUT_SURFACE_H_