Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1065)

Side by Side Diff: ui/ozone/platform/dri/gbm_surface.cc

Issue 371813004: ozone: gbm: Add overlay support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test build Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/ozone/platform/dri/gbm_surface.h ('k') | ui/ozone/platform/dri/gbm_surface_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::SwapBuffers() { 84 // Before scheduling the backbuffer to be scanned out we need to "lock" it.
85 // If there was a frontbuffer, is no longer active. Release it back to GBM. 85 // When we lock it, GBM will give a pointer to a buffer representing the
86 if (buffers_[front_buffer_]) 86 // backbuffer. It will also update its information on which buffers can not be
87 gbm_surface_release_buffer(native_surface_, buffers_[front_buffer_]); 87 // used for drawing. The buffer will be released when the page flip event
88 88 // occurs (see SwapBuffers). This is called from HardwareDisplayController
89 // Update the index to the frontbuffer. 89 // before scheduling a page flip.
90 front_buffer_ ^= 1; 90 void GbmSurface::PreSwapBuffers() {
91 // 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
93 // have been destroyed.
94 buffers_[front_buffer_ ^ 1] = NULL;
95 }
96
97 void GbmSurface::LockCurrentDrawable() {
98 CHECK(native_surface_); 91 CHECK(native_surface_);
99 // Lock the buffer we want to display. 92 // Lock the buffer we want to display.
100 buffers_[front_buffer_ ^ 1] = gbm_surface_lock_front_buffer(native_surface_); 93 buffers_[front_buffer_ ^ 1] = gbm_surface_lock_front_buffer(native_surface_);
101 94
102 BufferData* data = BufferData::GetData(buffers_[front_buffer_ ^ 1]); 95 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 96 // 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 97 // create it. On creation it will associate itself with the buffer and
105 // register the buffer. 98 // register the buffer.
106 if (!data) { 99 if (!data) {
107 data = BufferData::CreateData(dri_, buffers_[front_buffer_ ^ 1]); 100 data = BufferData::CreateData(dri_, buffers_[front_buffer_ ^ 1]);
108 DCHECK(data) << "Failed to associate the buffer with the controller"; 101 DCHECK(data) << "Failed to associate the buffer with the controller";
109 } 102 }
110 } 103 }
111 104
105 void GbmSurface::SwapBuffers() {
106 // If there was a frontbuffer, is no longer active. Release it back to GBM.
107 if (buffers_[front_buffer_])
108 gbm_surface_release_buffer(native_surface_, buffers_[front_buffer_]);
109
110 // Update the index to the frontbuffer.
111 front_buffer_ ^= 1;
112 // We've just released it. Since GBM doesn't guarantee we'll get the same
113 // buffer back, we set it to NULL so we don't keep track of objects that may
114 // have been destroyed.
115 buffers_[front_buffer_ ^ 1] = NULL;
116 }
117
112 } // namespace ui 118 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/gbm_surface.h ('k') | ui/ozone/platform/dri/gbm_surface_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698