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

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

Issue 2106843002: Remove unsafe cast from ImageTransportSurfaceOverlayMac::ScheduleCALayer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from piman. Created 4 years, 5 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 | « no previous file | ui/gl/gl_image.h » ('j') | 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (query.image) { 166 gl::GLImageIOSurface* io_surface_image =
167 gl::GLImageIOSurface* io_surface_image = 167 gl::GLImageIOSurface::FromGLImage(query.image.get());
168 static_cast<gl::GLImageIOSurface*>(query.image.get()); 168 if (io_surface_image) {
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
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 }
323 return ca_layer_tree_coordinator_->SetPendingGLRendererBackbuffer( 329 return ca_layer_tree_coordinator_->SetPendingGLRendererBackbuffer(
324 static_cast<gl::GLImageIOSurface*>(image)->io_surface()); 330 io_surface_image->io_surface());
325 } 331 }
326 332
327 bool ImageTransportSurfaceOverlayMac::ScheduleCALayer( 333 bool ImageTransportSurfaceOverlayMac::ScheduleCALayer(
328 gl::GLImage* contents_image, 334 gl::GLImage* contents_image,
329 const gfx::RectF& contents_rect, 335 const gfx::RectF& contents_rect,
330 float opacity, 336 float opacity,
331 unsigned background_color, 337 unsigned background_color,
332 unsigned edge_aa_mask, 338 unsigned edge_aa_mask,
333 const gfx::RectF& rect, 339 const gfx::RectF& rect,
334 bool is_clipped, 340 bool is_clipped,
335 const gfx::RectF& clip_rect, 341 const gfx::RectF& clip_rect,
336 const gfx::Transform& transform, 342 const gfx::Transform& transform,
337 int sorting_context_id, 343 int sorting_context_id,
338 unsigned filter) { 344 unsigned filter) {
339 base::ScopedCFTypeRef<IOSurfaceRef> io_surface; 345 gl::GLImageIOSurface* io_surface_image =
340 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer; 346 gl::GLImageIOSurface::FromGLImage(contents_image);
341 if (contents_image) { 347 if (!io_surface_image)
342 gl::GLImageIOSurface* io_surface_image = 348 return false;
ccameron 2016/06/30 02:48:35 |io_surface_image| will be null for solid color la
343 static_cast<gl::GLImageIOSurface*>(contents_image); 349 base::ScopedCFTypeRef<IOSurfaceRef> io_surface =
344 io_surface = io_surface_image->io_surface(); 350 io_surface_image->io_surface();
345 cv_pixel_buffer = io_surface_image->cv_pixel_buffer(); 351 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer =
346 } 352 io_surface_image->cv_pixel_buffer();
347 return ca_layer_tree_coordinator_->GetPendingCARendererLayerTree() 353 return ca_layer_tree_coordinator_->GetPendingCARendererLayerTree()
348 ->ScheduleCALayer(is_clipped, gfx::ToEnclosingRect(clip_rect), 354 ->ScheduleCALayer(is_clipped, gfx::ToEnclosingRect(clip_rect),
349 sorting_context_id, transform, io_surface, 355 sorting_context_id, transform, io_surface,
350 cv_pixel_buffer, contents_rect, 356 cv_pixel_buffer, contents_rect,
351 gfx::ToEnclosingRect(rect), background_color, 357 gfx::ToEnclosingRect(rect), background_color,
352 edge_aa_mask, opacity, filter); 358 edge_aa_mask, opacity, filter);
353 } 359 }
354 360
355 void ImageTransportSurfaceOverlayMac::ScheduleCALayerInUseQuery( 361 void ImageTransportSurfaceOverlayMac::ScheduleCALayerInUseQuery(
356 std::vector<CALayerInUseQuery> queries) { 362 std::vector<CALayerInUseQuery> queries) {
(...skipping 29 matching lines...) Expand all
386 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; 392 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask;
387 393
388 // Post a task holding a reference to the new GL context. The reason for 394 // Post a task holding a reference to the new GL context. The reason for
389 // this is to avoid creating-then-destroying the context for every image 395 // this is to avoid creating-then-destroying the context for every image
390 // transport surface that is observing the GPU switch. 396 // transport surface that is observing the GPU switch.
391 base::MessageLoop::current()->PostTask( 397 base::MessageLoop::current()->PostTask(
392 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); 398 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu));
393 } 399 }
394 400
395 } // namespace gpu 401 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | ui/gl/gl_image.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698