summaryrefslogtreecommitdiffstats
path: root/components/exo/sub_surface.h
blob: a2503a6e03d646c7d358ffe935b9e17a517880b5 (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
61
62
63
64
65
66
67
// Copyright 2015 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_EXO_SUB_SURFACE_H_
#define COMPONENTS_EXO_SUB_SURFACE_H_

#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "components/exo/surface_delegate.h"
#include "components/exo/surface_observer.h"
#include "ui/gfx/geometry/point.h"

namespace base {
namespace trace_event {
class TracedValue;
}
}

namespace exo {
class Surface;

// This class provides functions for treating a surface as a sub-surface. A
// sub-surface has one parent surface.
class SubSurface : public SurfaceDelegate, public SurfaceObserver {
 public:
  SubSurface(Surface* surface, Surface* parent);
  ~SubSurface() override;

  // This schedules a sub-surface position change. The sub-surface will be
  // moved so, that its origin (top-left corner pixel) will be at the |position|
  // of the parent surface coordinate system.
  void SetPosition(const gfx::Point& position);

  // This removes sub-surface from the stack, and puts it back just above the
  // reference surface, changing the z-order of the sub-surfaces. The reference
  // surface must be one of the sibling surfaces, or the parent surface.
  void PlaceAbove(Surface* reference);

  // This removes sub-surface from the stack, and puts it back just below the
  // sibling surface.
  void PlaceBelow(Surface* sibiling);

  // Change the commit behaviour of the sub-surface.
  void SetCommitBehavior(bool synchronized);

  // Returns a trace value representing the state of the surface.
  scoped_refptr<base::trace_event::TracedValue> AsTracedValue() const;

  // Overridden from SurfaceDelegate:
  void OnSurfaceCommit() override;
  bool IsSurfaceSynchronized() const override;

  // Overridden from SurfaceObserver:
  void OnSurfaceDestroying(Surface* surface) override;

 private:
  Surface* surface_;
  Surface* parent_;
  bool is_synchronized_;

  DISALLOW_COPY_AND_ASSIGN(SubSurface);
};

}  // namespace exo

#endif  // COMPONENTS_EXO_SUB_SURFACE_H_