OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/ozone/platform/dri/gbm_surface.h" | 5 #include "ui/ozone/platform/dri/gbm_surface.h" |
6 | 6 |
7 #include <gbm.h> | 7 #include <gbm.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "third_party/skia/include/core/SkImageInfo.h" | 10 #include "third_party/skia/include/core/SkImageInfo.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 | 74 |
75 BufferData* data = BufferData::GetData(buffers_[front_buffer_ ^ 1]); | 75 BufferData* data = BufferData::GetData(buffers_[front_buffer_ ^ 1]); |
76 CHECK(data); | 76 CHECK(data); |
77 return data->handle(); | 77 return data->handle(); |
78 } | 78 } |
79 | 79 |
80 gfx::Size GbmSurface::Size() const { | 80 gfx::Size GbmSurface::Size() const { |
81 return size_; | 81 return size_; |
82 } | 82 } |
83 | 83 |
84 void GbmSurface::PreSwapBuffers() { | |
85 LockCurrentDrawable(); | |
dnicoara
2014/07/07 19:17:54
Just move the contents of LockCurrentDrawable into
achaulk
2014/07/07 20:18:04
Done.
| |
86 } | |
87 | |
84 void GbmSurface::SwapBuffers() { | 88 void GbmSurface::SwapBuffers() { |
85 // If there was a frontbuffer, is no longer active. Release it back to GBM. | 89 // If there was a frontbuffer, is no longer active. Release it back to GBM. |
86 if (buffers_[front_buffer_]) | 90 if (buffers_[front_buffer_]) |
87 gbm_surface_release_buffer(native_surface_, buffers_[front_buffer_]); | 91 gbm_surface_release_buffer(native_surface_, buffers_[front_buffer_]); |
88 | 92 |
89 // Update the index to the frontbuffer. | 93 // Update the index to the frontbuffer. |
90 front_buffer_ ^= 1; | 94 front_buffer_ ^= 1; |
91 // We've just released it. Since GBM doesn't guarantee we'll get the same | 95 // We've just released it. Since GBM doesn't guarantee we'll get the same |
92 // buffer back, we set it to NULL so we don't keep track of objects that may | 96 // buffer back, we set it to NULL so we don't keep track of objects that may |
93 // have been destroyed. | 97 // have been destroyed. |
94 buffers_[front_buffer_ ^ 1] = NULL; | 98 buffers_[front_buffer_ ^ 1] = NULL; |
95 } | 99 } |
96 | 100 |
97 void GbmSurface::LockCurrentDrawable() { | 101 void GbmSurface::LockCurrentDrawable() { |
98 CHECK(native_surface_); | 102 CHECK(native_surface_); |
99 // Lock the buffer we want to display. | 103 // Lock the buffer we want to display. |
100 buffers_[front_buffer_ ^ 1] = gbm_surface_lock_front_buffer(native_surface_); | 104 buffers_[front_buffer_ ^ 1] = gbm_surface_lock_front_buffer(native_surface_); |
101 | 105 |
102 BufferData* data = BufferData::GetData(buffers_[front_buffer_ ^ 1]); | 106 BufferData* data = BufferData::GetData(buffers_[front_buffer_ ^ 1]); |
103 // If it is a new buffer, it won't have any data associated with it. So we | 107 // If it is a new buffer, it won't have any data associated with it. So we |
104 // create it. On creation it will associate itself with the buffer and | 108 // create it. On creation it will associate itself with the buffer and |
105 // register the buffer. | 109 // register the buffer. |
106 if (!data) { | 110 if (!data) { |
107 data = BufferData::CreateData(dri_, buffers_[front_buffer_ ^ 1]); | 111 data = BufferData::CreateData(dri_, buffers_[front_buffer_ ^ 1]); |
108 DCHECK(data) << "Failed to associate the buffer with the controller"; | 112 DCHECK(data) << "Failed to associate the buffer with the controller"; |
109 } | 113 } |
110 } | 114 } |
111 | 115 |
112 } // namespace ui | 116 } // namespace ui |
OLD | NEW |