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

Side by Side Diff: gpu/ipc/service/image_transport_surface_overlay_mac.mm

Issue 2028303002: Modify ImageTransportSurfaceOverlayMac to allow pipelining (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « gpu/ipc/service/image_transport_surface_overlay_mac.h ('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 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 "gpu/ipc/service/image_transport_surface_overlay_mac.h" 5 #include "gpu/ipc/service/image_transport_surface_overlay_mac.h"
6 6
7 #include <CoreGraphics/CoreGraphics.h> 7 #include <CoreGraphics/CoreGraphics.h>
8 #include <IOSurface/IOSurface.h> 8 #include <IOSurface/IOSurface.h>
9 #include <OpenGL/CGLRenderers.h> 9 #include <OpenGL/CGLRenderers.h>
10 #include <OpenGL/CGLTypes.h> 10 #include <OpenGL/CGLTypes.h>
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 params.scale_factor = scale_factor; 150 params.scale_factor = scale_factor;
151 params.latency_info = std::move(latency_info); 151 params.latency_info = std::move(latency_info);
152 params.result = gfx::SwapResult::SWAP_ACK; 152 params.result = gfx::SwapResult::SWAP_ACK;
153 stub_->SendSwapBuffersCompleted(params); 153 stub_->SendSwapBuffersCompleted(params);
154 } 154 }
155 155
156 gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal( 156 gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal(
157 const gfx::Rect& pixel_damage_rect) { 157 const gfx::Rect& pixel_damage_rect) {
158 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::SwapBuffersInternal"); 158 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::SwapBuffersInternal");
159 159
160 // A glFlush is necessary to ensure correct content appears. A glFinish 160 // If supported, use GLFence to ensure that we haven't gotten more than one
161 // appears empirically to be the best way to get maximum performance when 161 // frame ahead of GL.
162 // GPU bound. 162 if (gl::GLFence::IsSupported()) {
163 { 163 // If we have gotten more than one frame ahead of GL, wait for the previous
164 // frame to complete.
165 if (previous_frame_fence_) {
166 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::ClientWait");
167 previous_frame_fence_->ClientWait();
ccameron 2016/06/01 21:26:37 This will cause the CPU to spin up to 100% on Mac.
168 previous_frame_fence_ = nullptr;
169 }
170
171 // A glFlush is necessary to ensure correct content appears.
172 {
173 gl::ScopedSetGLToRealGLApi scoped_set_gl_api;
174 CheckGLErrors("Before flush");
175 glFlush();
176 CheckGLErrors("After flush");
177 }
178
179 // Create a new fence after flushing work from the current frame.
180 previous_frame_fence_.reset(gl::GLFence::Create());
181 } else {
182 // GLFence isn't supported - issue a glFinish on each frame to ensure
183 // there is backpressure from GL.
164 gl::ScopedSetGLToRealGLApi scoped_set_gl_api; 184 gl::ScopedSetGLToRealGLApi scoped_set_gl_api;
165 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::glFinish"); 185 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::glFinish");
166 CheckGLErrors("Before finish"); 186 CheckGLErrors("Before finish");
167 glFinish(); 187 glFinish();
168 CheckGLErrors("After finish"); 188 CheckGLErrors("After finish");
169 } 189 }
170 190
171 base::TimeTicks finish_time = base::TimeTicks::Now(); 191 base::TimeTicks finish_time = base::TimeTicks::Now();
172 192
173 bool fullscreen_low_power_layer_valid = false; 193 bool fullscreen_low_power_layer_valid = false;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; 336 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask;
317 337
318 // Post a task holding a reference to the new GL context. The reason for 338 // Post a task holding a reference to the new GL context. The reason for
319 // this is to avoid creating-then-destroying the context for every image 339 // this is to avoid creating-then-destroying the context for every image
320 // transport surface that is observing the GPU switch. 340 // transport surface that is observing the GPU switch.
321 base::MessageLoop::current()->PostTask( 341 base::MessageLoop::current()->PostTask(
322 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); 342 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu));
323 } 343 }
324 344
325 } // namespace gpu 345 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/service/image_transport_surface_overlay_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698