OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/exo/display.h" | 5 #include "components/exo/display.h" |
6 | 6 |
7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
8 #include "base/trace_event/trace_event_argument.h" | 8 #include "base/trace_event/trace_event_argument.h" |
9 #include "components/exo/shared_memory.h" | 9 #include "components/exo/shared_memory.h" |
10 #include "components/exo/shell_surface.h" | 10 #include "components/exo/shell_surface.h" |
11 #include "components/exo/sub_surface.h" | |
11 #include "components/exo/surface.h" | 12 #include "components/exo/surface.h" |
12 | 13 |
13 namespace exo { | 14 namespace exo { |
14 | 15 |
15 //////////////////////////////////////////////////////////////////////////////// | 16 //////////////////////////////////////////////////////////////////////////////// |
16 // Display, public: | 17 // Display, public: |
17 | 18 |
18 Display::Display() {} | 19 Display::Display() {} |
19 | 20 |
20 Display::~Display() {} | 21 Display::~Display() {} |
(...skipping 12 matching lines...) Expand all Loading... | |
33 if (!base::SharedMemory::IsHandleValid(handle)) | 34 if (!base::SharedMemory::IsHandleValid(handle)) |
34 return nullptr; | 35 return nullptr; |
35 | 36 |
36 return make_scoped_ptr(new SharedMemory(handle)); | 37 return make_scoped_ptr(new SharedMemory(handle)); |
37 } | 38 } |
38 | 39 |
39 scoped_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) { | 40 scoped_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) { |
40 TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface", | 41 TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface", |
41 surface->AsTracedValue()); | 42 surface->AsTracedValue()); |
42 | 43 |
44 if (surface->HasSurfaceDelegate()) { | |
45 LOG(ERROR) << "Surface has already been assigned a role"; | |
piman
2015/11/19 21:59:10
nit: DLOG here and below
reveman
2015/11/20 05:19:48
Done.
| |
46 return nullptr; | |
47 } | |
48 | |
43 return make_scoped_ptr(new ShellSurface(surface)); | 49 return make_scoped_ptr(new ShellSurface(surface)); |
44 } | 50 } |
45 | 51 |
52 scoped_ptr<SubSurface> Display::CreateSubSurface(Surface* surface, | |
53 Surface* parent) { | |
54 TRACE_EVENT2("exo", "Display::CreateSubSurface", "surface", | |
55 surface->AsTracedValue(), "parent", parent->AsTracedValue()); | |
56 | |
57 if (surface == parent) { | |
piman
2015/11/19 21:59:10
Is there a possibility that indirect cycles might
reveman
2015/11/20 05:19:48
Yes, that would cause bad behavior. I changed this
| |
58 LOG(ERROR) << "Surface cannot be its own parent"; | |
59 return nullptr; | |
60 } | |
61 | |
62 if (surface->HasSurfaceDelegate()) { | |
63 LOG(ERROR) << "Surface has already been assigned a role"; | |
64 return nullptr; | |
65 } | |
66 | |
67 return make_scoped_ptr(new SubSurface(surface, parent)); | |
68 } | |
69 | |
46 } // namespace exo | 70 } // namespace exo |
OLD | NEW |