summaryrefslogtreecommitdiffstats
path: root/ui/ozone/platform/drm/gpu/drm_surface.h
blob: efb0f8a0e4a8dcf17cbbdaf12606b5bb76e1a3af (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
// Copyright 2014 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 UI_OZONE_PLATFORM_DRM_GPU_DRM_SURFACE_H_
#define UI_OZONE_PLATFORM_DRM_GPU_DRM_SURFACE_H_

#include "base/memory/ref_counted.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/skia_util.h"
#include "ui/ozone/ozone_export.h"
#include "ui/ozone/public/surface_ozone_canvas.h"

class SkSurface;

namespace ui {

class DrmBuffer;
class DrmWindow;
class HardwareDisplayController;

class OZONE_EXPORT DrmSurface : public SurfaceOzoneCanvas {
 public:
  DrmSurface(DrmWindow* window_delegate);
  ~DrmSurface() override;

  // SurfaceOzoneCanvas:
  skia::RefPtr<SkSurface> GetSurface() override;
  void ResizeCanvas(const gfx::Size& viewport_size) override;
  void PresentCanvas(const gfx::Rect& damage) override;
  scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() override;

 private:
  void UpdateNativeSurface(const gfx::Rect& damage);

  DrmWindow* window_delegate_;

  // The actual buffers used for painting.
  scoped_refptr<DrmBuffer> buffers_[2];

  // Keeps track of which bitmap is |buffers_| is the frontbuffer.
  int front_buffer_;

  skia::RefPtr<SkSurface> surface_;
  gfx::Rect last_damage_;

  DISALLOW_COPY_AND_ASSIGN(DrmSurface);
};

}  // namespace ui

#endif  // UI_OZONE_PLATFORM_DRM_GPU_DRM_SURFACE_H_