OLD | NEW |
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 Loading... |
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 // TODO(erikchen): Re-enable this logic alongside the client code that |
| 163 // consumes this response. https://crbug.com/608026. |
| 164 // for (auto& query : io_surface_in_use_queries_) { |
| 165 // SwapBuffersCompletedIOSurfaceInUseQuery response; |
| 166 // response.texture = query.texture; |
| 167 // response.in_use = |
| 168 // query.io_surface.get() && IOSurfaceIsInUse(query.io_surface.get()); |
| 169 // params.in_use_queries.push_back(std::move(response)); |
| 170 // } |
| 171 io_surface_in_use_queries_.clear(); |
| 172 |
161 stub_->SendSwapBuffersCompleted(params); | 173 stub_->SendSwapBuffersCompleted(params); |
162 } | 174 } |
163 | 175 |
164 gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal( | 176 gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal( |
165 const gfx::Rect& pixel_damage_rect) { | 177 const gfx::Rect& pixel_damage_rect) { |
166 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::SwapBuffersInternal"); | 178 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::SwapBuffersInternal"); |
167 | 179 |
168 // If supported, use GLFence to ensure that we haven't gotten more than one | 180 // If supported, use GLFence to ensure that we haven't gotten more than one |
169 // frame ahead of GL. | 181 // frame ahead of GL. |
170 if (gl::GLFence::IsSupported()) { | 182 if (gl::GLFence::IsSupported()) { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 cv_pixel_buffer = io_surface_image->cv_pixel_buffer(); | 331 cv_pixel_buffer = io_surface_image->cv_pixel_buffer(); |
320 } | 332 } |
321 return ca_layer_tree_coordinator_->GetPendingCARendererLayerTree() | 333 return ca_layer_tree_coordinator_->GetPendingCARendererLayerTree() |
322 ->ScheduleCALayer(is_clipped, gfx::ToEnclosingRect(clip_rect), | 334 ->ScheduleCALayer(is_clipped, gfx::ToEnclosingRect(clip_rect), |
323 sorting_context_id, transform, io_surface, | 335 sorting_context_id, transform, io_surface, |
324 cv_pixel_buffer, contents_rect, | 336 cv_pixel_buffer, contents_rect, |
325 gfx::ToEnclosingRect(rect), background_color, | 337 gfx::ToEnclosingRect(rect), background_color, |
326 edge_aa_mask, opacity, filter); | 338 edge_aa_mask, opacity, filter); |
327 } | 339 } |
328 | 340 |
| 341 void ImageTransportSurfaceOverlayMac::ScheduleCALayerInUseQuery( |
| 342 std::vector<CALayerInUseQuery> queries) { |
| 343 for (auto& query : queries) { |
| 344 IOSurfaceInUseQuery io_surface_query; |
| 345 io_surface_query.texture = query.texture; |
| 346 if (query.image) { |
| 347 gl::GLImageIOSurface* io_surface_image = |
| 348 static_cast<gl::GLImageIOSurface*>(query.image.get()); |
| 349 io_surface_query.io_surface = io_surface_image->io_surface(); |
| 350 } |
| 351 io_surface_in_use_queries_.push_back(std::move(io_surface_query)); |
| 352 } |
| 353 } |
| 354 |
329 bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const { | 355 bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const { |
330 return true; | 356 return true; |
331 } | 357 } |
332 | 358 |
333 bool ImageTransportSurfaceOverlayMac::Resize(const gfx::Size& pixel_size, | 359 bool ImageTransportSurfaceOverlayMac::Resize(const gfx::Size& pixel_size, |
334 float scale_factor, | 360 float scale_factor, |
335 bool has_alpha) { | 361 bool has_alpha) { |
336 pixel_size_ = pixel_size; | 362 pixel_size_ = pixel_size; |
337 scale_factor_ = scale_factor; | 363 scale_factor_ = scale_factor; |
338 ca_layer_tree_coordinator_->Resize(pixel_size, scale_factor); | 364 ca_layer_tree_coordinator_->Resize(pixel_size, scale_factor); |
(...skipping 15 matching lines...) Expand all Loading... |
354 } | 380 } |
355 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; | 381 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; |
356 | 382 |
357 // Post a task holding a reference to the new GL context. The reason for | 383 // 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 | 384 // this is to avoid creating-then-destroying the context for every image |
359 // transport surface that is observing the GPU switch. | 385 // transport surface that is observing the GPU switch. |
360 base::MessageLoop::current()->PostTask( | 386 base::MessageLoop::current()->PostTask( |
361 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); | 387 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); |
362 } | 388 } |
363 | 389 |
| 390 ImageTransportSurfaceOverlayMac::IOSurfaceInUseQuery::IOSurfaceInUseQuery() = |
| 391 default; |
| 392 ImageTransportSurfaceOverlayMac::IOSurfaceInUseQuery::IOSurfaceInUseQuery( |
| 393 const IOSurfaceInUseQuery&) = default; |
| 394 ImageTransportSurfaceOverlayMac::IOSurfaceInUseQuery::IOSurfaceInUseQuery( |
| 395 IOSurfaceInUseQuery&&) = default; |
| 396 ImageTransportSurfaceOverlayMac::IOSurfaceInUseQuery::~IOSurfaceInUseQuery() = |
| 397 default; |
| 398 |
364 } // namespace gpu | 399 } // namespace gpu |
OLD | NEW |