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

Side by Side Diff: ui/gl/gl_surface_ozone.cc

Issue 1486773002: Add NativeViewGLSurfaceEGL::CommitOverlayPlanes support for Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cop-bare-implementation
Patch Set: Move comment Created 5 years 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/gl/gl_surface_overlay.cc ('k') | no next file » | 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/gl/gl_surface.h" 5 #include "ui/gl/gl_surface.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/worker_pool.h" 14 #include "base/threading/worker_pool.h"
15 #include "ui/gfx/native_widget_types.h" 15 #include "ui/gfx/native_widget_types.h"
16 #include "ui/gl/gl_context.h" 16 #include "ui/gl/gl_context.h"
17 #include "ui/gl/gl_image.h" 17 #include "ui/gl/gl_image.h"
18 #include "ui/gl/gl_image_ozone_native_pixmap.h" 18 #include "ui/gl/gl_image_ozone_native_pixmap.h"
19 #include "ui/gl/gl_implementation.h" 19 #include "ui/gl/gl_implementation.h"
20 #include "ui/gl/gl_surface_egl.h" 20 #include "ui/gl/gl_surface_egl.h"
21 #include "ui/gl/gl_surface_osmesa.h" 21 #include "ui/gl/gl_surface_osmesa.h"
22 #include "ui/gl/gl_surface_overlay.h"
22 #include "ui/gl/gl_surface_stub.h" 23 #include "ui/gl/gl_surface_stub.h"
23 #include "ui/gl/scoped_binders.h" 24 #include "ui/gl/scoped_binders.h"
24 #include "ui/gl/scoped_make_current.h" 25 #include "ui/gl/scoped_make_current.h"
25 #include "ui/ozone/public/native_pixmap.h" 26 #include "ui/ozone/public/native_pixmap.h"
26 #include "ui/ozone/public/ozone_platform.h" 27 #include "ui/ozone/public/ozone_platform.h"
27 #include "ui/ozone/public/surface_factory_ozone.h" 28 #include "ui/ozone/public/surface_factory_ozone.h"
28 #include "ui/ozone/public/surface_ozone_egl.h" 29 #include "ui/ozone/public/surface_ozone_egl.h"
29 30
30 using gl::GLImage; 31 using gl::GLImage;
31 32
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 bool SupportsPostSubBuffer() override; 158 bool SupportsPostSubBuffer() override;
158 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; 159 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override;
159 void SwapBuffersAsync(const SwapCompletionCallback& callback) override; 160 void SwapBuffersAsync(const SwapCompletionCallback& callback) override;
160 void PostSubBufferAsync(int x, 161 void PostSubBufferAsync(int x,
161 int y, 162 int y,
162 int width, 163 int width,
163 int height, 164 int height,
164 const SwapCompletionCallback& callback) override; 165 const SwapCompletionCallback& callback) override;
165 166
166 protected: 167 protected:
167 struct Overlay {
168 Overlay(int z_order,
169 OverlayTransform transform,
170 GLImage* image,
171 const Rect& bounds_rect,
172 const RectF& crop_rect);
173
174 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget) const;
175
176 int z_order;
177 OverlayTransform transform;
178 scoped_refptr<GLImage> image;
179 Rect bounds_rect;
180 RectF crop_rect;
181 };
182
183 struct PendingFrame { 168 struct PendingFrame {
184 PendingFrame(); 169 PendingFrame();
185 170
186 bool ScheduleOverlayPlanes(gfx::AcceleratedWidget widget); 171 bool ScheduleOverlayPlanes(gfx::AcceleratedWidget widget);
187 172
188 bool ready; 173 bool ready;
189 std::vector<Overlay> overlays; 174 std::vector<GLSurfaceOverlay> overlays;
190 SwapCompletionCallback callback; 175 SwapCompletionCallback callback;
191 }; 176 };
192 177
193 ~GLSurfaceOzoneSurfaceless() override; 178 ~GLSurfaceOzoneSurfaceless() override;
194 179
195 void SubmitFrame(); 180 void SubmitFrame();
196 181
197 EGLSyncKHR InsertFence(); 182 EGLSyncKHR InsertFence();
198 void FenceRetired(EGLSyncKHR fence, PendingFrame* frame); 183 void FenceRetired(EGLSyncKHR fence, PendingFrame* frame);
199 184
200 void SwapCompleted(const SwapCompletionCallback& callback, 185 void SwapCompleted(const SwapCompletionCallback& callback,
201 gfx::SwapResult result); 186 gfx::SwapResult result);
202 187
203 // The native surface. Deleting this is allowed to free the EGLNativeWindow. 188 // The native surface. Deleting this is allowed to free the EGLNativeWindow.
204 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_; 189 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_;
205 AcceleratedWidget widget_; 190 AcceleratedWidget widget_;
206 scoped_ptr<VSyncProvider> vsync_provider_; 191 scoped_ptr<VSyncProvider> vsync_provider_;
207 ScopedVector<PendingFrame> unsubmitted_frames_; 192 ScopedVector<PendingFrame> unsubmitted_frames_;
208 bool has_implicit_external_sync_; 193 bool has_implicit_external_sync_;
209 bool last_swap_buffers_result_; 194 bool last_swap_buffers_result_;
210 bool swap_buffers_pending_; 195 bool swap_buffers_pending_;
211 196
212 base::WeakPtrFactory<GLSurfaceOzoneSurfaceless> weak_factory_; 197 base::WeakPtrFactory<GLSurfaceOzoneSurfaceless> weak_factory_;
213 198
214 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneSurfaceless); 199 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneSurfaceless);
215 }; 200 };
216 201
217 GLSurfaceOzoneSurfaceless::Overlay::Overlay(int z_order,
218 OverlayTransform transform,
219 GLImage* image,
220 const Rect& bounds_rect,
221 const RectF& crop_rect)
222 : z_order(z_order),
223 transform(transform),
224 image(image),
225 bounds_rect(bounds_rect),
226 crop_rect(crop_rect) {}
227
228 bool GLSurfaceOzoneSurfaceless::Overlay::ScheduleOverlayPlane(
229 gfx::AcceleratedWidget widget) const {
230 return image->ScheduleOverlayPlane(widget, z_order, transform, bounds_rect,
231 crop_rect);
232 }
233
234 GLSurfaceOzoneSurfaceless::PendingFrame::PendingFrame() : ready(false) {} 202 GLSurfaceOzoneSurfaceless::PendingFrame::PendingFrame() : ready(false) {}
235 203
236 bool GLSurfaceOzoneSurfaceless::PendingFrame::ScheduleOverlayPlanes( 204 bool GLSurfaceOzoneSurfaceless::PendingFrame::ScheduleOverlayPlanes(
237 gfx::AcceleratedWidget widget) { 205 gfx::AcceleratedWidget widget) {
238 for (const auto& overlay : overlays) 206 for (const auto& overlay : overlays)
239 if (!overlay.ScheduleOverlayPlane(widget)) 207 if (!overlay.ScheduleOverlayPlane(widget))
240 return false; 208 return false;
241 return true; 209 return true;
242 } 210 }
243 211
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 return ozone_surface_->OnSwapBuffers() ? gfx::SwapResult::SWAP_ACK 262 return ozone_surface_->OnSwapBuffers() ? gfx::SwapResult::SWAP_ACK
295 : gfx::SwapResult::SWAP_FAILED; 263 : gfx::SwapResult::SWAP_FAILED;
296 } 264 }
297 265
298 bool GLSurfaceOzoneSurfaceless::ScheduleOverlayPlane(int z_order, 266 bool GLSurfaceOzoneSurfaceless::ScheduleOverlayPlane(int z_order,
299 OverlayTransform transform, 267 OverlayTransform transform,
300 GLImage* image, 268 GLImage* image,
301 const Rect& bounds_rect, 269 const Rect& bounds_rect,
302 const RectF& crop_rect) { 270 const RectF& crop_rect) {
303 unsubmitted_frames_.back()->overlays.push_back( 271 unsubmitted_frames_.back()->overlays.push_back(
304 Overlay(z_order, transform, image, bounds_rect, crop_rect)); 272 GLSurfaceOverlay(z_order, transform, image, bounds_rect, crop_rect));
305 return true; 273 return true;
306 } 274 }
307 275
308 bool GLSurfaceOzoneSurfaceless::IsOffscreen() { 276 bool GLSurfaceOzoneSurfaceless::IsOffscreen() {
309 return false; 277 return false;
310 } 278 }
311 279
312 VSyncProvider* GLSurfaceOzoneSurfaceless::GetVSyncProvider() { 280 VSyncProvider* GLSurfaceOzoneSurfaceless::GetVSyncProvider() {
313 return vsync_provider_.get(); 281 return vsync_provider_.get();
314 } 282 }
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 } 701 }
734 } 702 }
735 703
736 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { 704 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() {
737 return ui::OzonePlatform::GetInstance() 705 return ui::OzonePlatform::GetInstance()
738 ->GetSurfaceFactoryOzone() 706 ->GetSurfaceFactoryOzone()
739 ->GetNativeDisplay(); 707 ->GetNativeDisplay();
740 } 708 }
741 709
742 } // namespace gfx 710 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_surface_overlay.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698