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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 : ca_layer_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 bool in_use = false; | 165 bool in_use = false; |
166 gl::GLImageIOSurface* io_surface_image = | 166 if (query.image) { |
167 gl::GLImageIOSurface::FromGLImage(query.image.get()); | 167 gl::GLImageIOSurface* io_surface_image = |
168 if (io_surface_image) { | 168 static_cast<gl::GLImageIOSurface*>(query.image.get()); |
169 in_use = io_surface_image->CanCheckIOSurfaceIsInUse() && | 169 in_use = io_surface_image->CanCheckIOSurfaceIsInUse() && |
170 IOSurfaceIsInUse(io_surface_image->io_surface()); | 170 IOSurfaceIsInUse(io_surface_image->io_surface()); |
171 } | 171 } |
172 response.in_use = in_use; | 172 response.in_use = in_use; |
173 params.in_use_responses.push_back(std::move(response)); | 173 params.in_use_responses.push_back(std::move(response)); |
174 } | 174 } |
175 ca_layer_in_use_queries_.clear(); | 175 ca_layer_in_use_queries_.clear(); |
176 | 176 |
177 stub_->SendSwapBuffersCompleted(params); | 177 stub_->SendSwapBuffersCompleted(params); |
178 } | 178 } |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 const gfx::Rect& pixel_frame_rect, | 313 const gfx::Rect& pixel_frame_rect, |
314 const gfx::RectF& crop_rect) { | 314 const gfx::RectF& crop_rect) { |
315 if (transform != gfx::OVERLAY_TRANSFORM_NONE) { | 315 if (transform != gfx::OVERLAY_TRANSFORM_NONE) { |
316 DLOG(ERROR) << "Invalid overlay plane transform."; | 316 DLOG(ERROR) << "Invalid overlay plane transform."; |
317 return false; | 317 return false; |
318 } | 318 } |
319 if (z_order) { | 319 if (z_order) { |
320 DLOG(ERROR) << "Invalid non-zero Z order."; | 320 DLOG(ERROR) << "Invalid non-zero Z order."; |
321 return false; | 321 return false; |
322 } | 322 } |
323 gl::GLImageIOSurface* io_surface_image = | |
324 gl::GLImageIOSurface::FromGLImage(image); | |
325 if (!io_surface_image) { | |
326 DLOG(ERROR) << "Not an IOSurface image."; | |
327 return false; | |
328 } | |
329 return ca_layer_tree_coordinator_->SetPendingGLRendererBackbuffer( | 323 return ca_layer_tree_coordinator_->SetPendingGLRendererBackbuffer( |
330 io_surface_image->io_surface()); | 324 static_cast<gl::GLImageIOSurface*>(image)->io_surface()); |
331 } | 325 } |
332 | 326 |
333 bool ImageTransportSurfaceOverlayMac::ScheduleCALayer( | 327 bool ImageTransportSurfaceOverlayMac::ScheduleCALayer( |
334 gl::GLImage* contents_image, | 328 gl::GLImage* contents_image, |
335 const gfx::RectF& contents_rect, | 329 const gfx::RectF& contents_rect, |
336 float opacity, | 330 float opacity, |
337 unsigned background_color, | 331 unsigned background_color, |
338 unsigned edge_aa_mask, | 332 unsigned edge_aa_mask, |
339 const gfx::RectF& rect, | 333 const gfx::RectF& rect, |
340 bool is_clipped, | 334 bool is_clipped, |
341 const gfx::RectF& clip_rect, | 335 const gfx::RectF& clip_rect, |
342 const gfx::Transform& transform, | 336 const gfx::Transform& transform, |
343 int sorting_context_id, | 337 int sorting_context_id, |
344 unsigned filter) { | 338 unsigned filter) { |
345 gl::GLImageIOSurface* io_surface_image = | 339 base::ScopedCFTypeRef<IOSurfaceRef> io_surface; |
346 gl::GLImageIOSurface::FromGLImage(contents_image); | 340 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer; |
347 if (!io_surface_image) | 341 if (contents_image) { |
348 return false; | 342 gl::GLImageIOSurface* io_surface_image = |
349 base::ScopedCFTypeRef<IOSurfaceRef> io_surface = | 343 static_cast<gl::GLImageIOSurface*>(contents_image); |
350 io_surface_image->io_surface(); | 344 io_surface = io_surface_image->io_surface(); |
351 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer = | 345 cv_pixel_buffer = io_surface_image->cv_pixel_buffer(); |
352 io_surface_image->cv_pixel_buffer(); | 346 } |
353 return ca_layer_tree_coordinator_->GetPendingCARendererLayerTree() | 347 return ca_layer_tree_coordinator_->GetPendingCARendererLayerTree() |
354 ->ScheduleCALayer(is_clipped, gfx::ToEnclosingRect(clip_rect), | 348 ->ScheduleCALayer(is_clipped, gfx::ToEnclosingRect(clip_rect), |
355 sorting_context_id, transform, io_surface, | 349 sorting_context_id, transform, io_surface, |
356 cv_pixel_buffer, contents_rect, | 350 cv_pixel_buffer, contents_rect, |
357 gfx::ToEnclosingRect(rect), background_color, | 351 gfx::ToEnclosingRect(rect), background_color, |
358 edge_aa_mask, opacity, filter); | 352 edge_aa_mask, opacity, filter); |
359 } | 353 } |
360 | 354 |
361 void ImageTransportSurfaceOverlayMac::ScheduleCALayerInUseQuery( | 355 void ImageTransportSurfaceOverlayMac::ScheduleCALayerInUseQuery( |
362 std::vector<CALayerInUseQuery> queries) { | 356 std::vector<CALayerInUseQuery> queries) { |
(...skipping 29 matching lines...) Expand all Loading... |
392 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; | 386 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; |
393 | 387 |
394 // 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 |
395 // 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 |
396 // transport surface that is observing the GPU switch. | 390 // transport surface that is observing the GPU switch. |
397 base::MessageLoop::current()->PostTask( | 391 base::MessageLoop::current()->PostTask( |
398 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); | 392 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); |
399 } | 393 } |
400 | 394 |
401 } // namespace gpu | 395 } // namespace gpu |
OLD | NEW |