| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 161 |
| 162 for (auto& query : io_surface_in_use_queries_) { | 162 for (auto& query : ca_layer_in_use_queries_) { |
| 163 gpu::TextureInUseResponse response; | 163 gpu::TextureInUseResponse response; |
| 164 response.texture = query.texture; | 164 response.texture = query.texture; |
| 165 response.in_use = | 165 bool in_use = false; |
| 166 query.io_surface.get() && IOSurfaceIsInUse(query.io_surface.get()); | 166 if (query.image) { |
| 167 gl::GLImageIOSurface* io_surface_image = |
| 168 static_cast<gl::GLImageIOSurface*>(query.image.get()); |
| 169 in_use = io_surface_image->CanCheckIOSurfaceIsInUse() && |
| 170 IOSurfaceIsInUse(io_surface_image->io_surface()); |
| 171 } |
| 172 response.in_use = in_use; |
| 167 params.in_use_responses.push_back(std::move(response)); | 173 params.in_use_responses.push_back(std::move(response)); |
| 168 } | 174 } |
| 169 io_surface_in_use_queries_.clear(); | 175 ca_layer_in_use_queries_.clear(); |
| 170 | 176 |
| 171 stub_->SendSwapBuffersCompleted(params); | 177 stub_->SendSwapBuffersCompleted(params); |
| 172 } | 178 } |
| 173 | 179 |
| 174 gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal( | 180 gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal( |
| 175 const gfx::Rect& pixel_damage_rect) { | 181 const gfx::Rect& pixel_damage_rect) { |
| 176 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::SwapBuffersInternal"); | 182 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::SwapBuffersInternal"); |
| 177 | 183 |
| 178 // If supported, use GLFence to ensure that we haven't gotten more than one | 184 // If supported, use GLFence to ensure that we haven't gotten more than one |
| 179 // frame ahead of GL. | 185 // frame ahead of GL. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 return ca_layer_tree_coordinator_->GetPendingCARendererLayerTree() | 347 return ca_layer_tree_coordinator_->GetPendingCARendererLayerTree() |
| 342 ->ScheduleCALayer(is_clipped, gfx::ToEnclosingRect(clip_rect), | 348 ->ScheduleCALayer(is_clipped, gfx::ToEnclosingRect(clip_rect), |
| 343 sorting_context_id, transform, io_surface, | 349 sorting_context_id, transform, io_surface, |
| 344 cv_pixel_buffer, contents_rect, | 350 cv_pixel_buffer, contents_rect, |
| 345 gfx::ToEnclosingRect(rect), background_color, | 351 gfx::ToEnclosingRect(rect), background_color, |
| 346 edge_aa_mask, opacity, filter); | 352 edge_aa_mask, opacity, filter); |
| 347 } | 353 } |
| 348 | 354 |
| 349 void ImageTransportSurfaceOverlayMac::ScheduleCALayerInUseQuery( | 355 void ImageTransportSurfaceOverlayMac::ScheduleCALayerInUseQuery( |
| 350 std::vector<CALayerInUseQuery> queries) { | 356 std::vector<CALayerInUseQuery> queries) { |
| 351 for (auto& query : queries) { | 357 ca_layer_in_use_queries_.swap(queries); |
| 352 IOSurfaceInUseQuery io_surface_query; | |
| 353 io_surface_query.texture = query.texture; | |
| 354 if (query.image) { | |
| 355 gl::GLImageIOSurface* io_surface_image = | |
| 356 static_cast<gl::GLImageIOSurface*>(query.image.get()); | |
| 357 io_surface_query.io_surface = io_surface_image->io_surface(); | |
| 358 } | |
| 359 io_surface_in_use_queries_.push_back(std::move(io_surface_query)); | |
| 360 } | |
| 361 } | 358 } |
| 362 | 359 |
| 363 bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const { | 360 bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const { |
| 364 return true; | 361 return true; |
| 365 } | 362 } |
| 366 | 363 |
| 367 bool ImageTransportSurfaceOverlayMac::Resize(const gfx::Size& pixel_size, | 364 bool ImageTransportSurfaceOverlayMac::Resize(const gfx::Size& pixel_size, |
| 368 float scale_factor, | 365 float scale_factor, |
| 369 bool has_alpha) { | 366 bool has_alpha) { |
| 370 pixel_size_ = pixel_size; | 367 pixel_size_ = pixel_size; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 388 } | 385 } |
| 389 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; | 386 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; |
| 390 | 387 |
| 391 // Post a task holding a reference to the new GL context. The reason for | 388 // Post a task holding a reference to the new GL context. The reason for |
| 392 // this is to avoid creating-then-destroying the context for every image | 389 // this is to avoid creating-then-destroying the context for every image |
| 393 // transport surface that is observing the GPU switch. | 390 // transport surface that is observing the GPU switch. |
| 394 base::MessageLoop::current()->PostTask( | 391 base::MessageLoop::current()->PostTask( |
| 395 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); | 392 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); |
| 396 } | 393 } |
| 397 | 394 |
| 398 ImageTransportSurfaceOverlayMac::IOSurfaceInUseQuery::IOSurfaceInUseQuery() = | |
| 399 default; | |
| 400 ImageTransportSurfaceOverlayMac::IOSurfaceInUseQuery::IOSurfaceInUseQuery( | |
| 401 const IOSurfaceInUseQuery&) = default; | |
| 402 ImageTransportSurfaceOverlayMac::IOSurfaceInUseQuery::IOSurfaceInUseQuery( | |
| 403 IOSurfaceInUseQuery&&) = default; | |
| 404 ImageTransportSurfaceOverlayMac::IOSurfaceInUseQuery::~IOSurfaceInUseQuery() = | |
| 405 default; | |
| 406 | |
| 407 } // namespace gpu | 395 } // namespace gpu |
| OLD | NEW |