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

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

Issue 2067503003: Add a new command buffer function glScheduleCALayerInUseQueryCHROMIUM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fix. 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
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 params.ca_context_id = ca_context_id; 151 params.ca_context_id = ca_context_id;
152 params.fullscreen_low_power_ca_context_valid = 152 params.fullscreen_low_power_ca_context_valid =
153 fullscreen_low_power_ca_context_valid; 153 fullscreen_low_power_ca_context_valid;
154 params.fullscreen_low_power_ca_context_id = 154 params.fullscreen_low_power_ca_context_id =
155 fullscreen_low_power_ca_context_id; 155 fullscreen_low_power_ca_context_id;
156 params.io_surface = io_surface; 156 params.io_surface = io_surface;
157 params.pixel_size = size; 157 params.pixel_size = size;
158 params.scale_factor = scale_factor; 158 params.scale_factor = scale_factor;
159 params.latency_info = std::move(latency_info); 159 params.latency_info = std::move(latency_info);
160 params.result = gfx::SwapResult::SWAP_ACK; 160 params.result = gfx::SwapResult::SWAP_ACK;
161
162 for (auto& query : io_surface_in_use_queries_) {
163 uint32_t texture = query.texture;
164 bool in_use =
165 query.io_surface.get() && IOSurfaceIsInUse(query.io_surface.get());
166 auto response = std::make_pair(texture, in_use);
167 params.in_use_queries.push_back(response);
168 }
169 io_surface_in_use_queries_.clear();
170
161 stub_->SendSwapBuffersCompleted(params); 171 stub_->SendSwapBuffersCompleted(params);
162 } 172 }
163 173
164 gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal( 174 gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal(
165 const gfx::Rect& pixel_damage_rect) { 175 const gfx::Rect& pixel_damage_rect) {
166 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::SwapBuffersInternal"); 176 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::SwapBuffersInternal");
167 177
168 // If supported, use GLFence to ensure that we haven't gotten more than one 178 // If supported, use GLFence to ensure that we haven't gotten more than one
169 // frame ahead of GL. 179 // frame ahead of GL.
170 if (gl::GLFence::IsSupported()) { 180 if (gl::GLFence::IsSupported()) {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 cv_pixel_buffer = io_surface_image->cv_pixel_buffer(); 329 cv_pixel_buffer = io_surface_image->cv_pixel_buffer();
320 } 330 }
321 return ca_layer_tree_coordinator_->GetPendingCARendererLayerTree() 331 return ca_layer_tree_coordinator_->GetPendingCARendererLayerTree()
322 ->ScheduleCALayer(is_clipped, gfx::ToEnclosingRect(clip_rect), 332 ->ScheduleCALayer(is_clipped, gfx::ToEnclosingRect(clip_rect),
323 sorting_context_id, transform, io_surface, 333 sorting_context_id, transform, io_surface,
324 cv_pixel_buffer, contents_rect, 334 cv_pixel_buffer, contents_rect,
325 gfx::ToEnclosingRect(rect), background_color, 335 gfx::ToEnclosingRect(rect), background_color,
326 edge_aa_mask, opacity, filter); 336 edge_aa_mask, opacity, filter);
327 } 337 }
328 338
339 void ImageTransportSurfaceOverlayMac::ScheduleCALayerInUseQuery(
340 std::vector<CALayerInUseQuery> queries) {
341 for (auto& query : queries) {
342 IOSurfaceInUseQuery io_surface_query;
343 io_surface_query.texture = query.texture;
344 if (query.image) {
345 gl::GLImageIOSurface* io_surface_image =
346 static_cast<gl::GLImageIOSurface*>(query.image);
347 io_surface_query.io_surface = io_surface_image->io_surface();
348 }
349 io_surface_in_use_queries_.push_back(std::move(io_surface_query));
350 }
351 }
352
329 bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const { 353 bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const {
330 return true; 354 return true;
331 } 355 }
332 356
333 bool ImageTransportSurfaceOverlayMac::Resize(const gfx::Size& pixel_size, 357 bool ImageTransportSurfaceOverlayMac::Resize(const gfx::Size& pixel_size,
334 float scale_factor, 358 float scale_factor,
335 bool has_alpha) { 359 bool has_alpha) {
336 pixel_size_ = pixel_size; 360 pixel_size_ = pixel_size;
337 scale_factor_ = scale_factor; 361 scale_factor_ = scale_factor;
338 ca_layer_tree_coordinator_->Resize(pixel_size, scale_factor); 362 ca_layer_tree_coordinator_->Resize(pixel_size, scale_factor);
(...skipping 15 matching lines...) Expand all
354 } 378 }
355 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; 379 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask;
356 380
357 // Post a task holding a reference to the new GL context. The reason for 381 // Post a task holding a reference to the new GL context. The reason for
358 // this is to avoid creating-then-destroying the context for every image 382 // this is to avoid creating-then-destroying the context for every image
359 // transport surface that is observing the GPU switch. 383 // transport surface that is observing the GPU switch.
360 base::MessageLoop::current()->PostTask( 384 base::MessageLoop::current()->PostTask(
361 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); 385 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu));
362 } 386 }
363 387
388 ImageTransportSurfaceOverlayMac::IOSurfaceInUseQuery::IOSurfaceInUseQuery() =
389 default;
390 ImageTransportSurfaceOverlayMac::IOSurfaceInUseQuery::IOSurfaceInUseQuery(
391 IOSurfaceInUseQuery&) = default;
392 ImageTransportSurfaceOverlayMac::IOSurfaceInUseQuery::IOSurfaceInUseQuery(
393 IOSurfaceInUseQuery&&) = default;
394 ImageTransportSurfaceOverlayMac::IOSurfaceInUseQuery::~IOSurfaceInUseQuery() =
395 default;
396
364 } // namespace gpu 397 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698