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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 147493011: Use base::ScopedTypeRef for CGL types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase again Created 6 years, 10 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 | « content/browser/renderer_host/display_link_mac.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <QuartzCore/QuartzCore.h> 8 #include <QuartzCore/QuartzCore.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 NSWindow* window = [cocoa_view_ window]; 1303 NSWindow* window = [cocoa_view_ window];
1304 if (window_number() <= 0) { 1304 if (window_number() <= 0) {
1305 // There is no window to present so capturing during present won't work. 1305 // There is no window to present so capturing during present won't work.
1306 // We check if frame subscriber wants this frame and capture manually. 1306 // We check if frame subscriber wants this frame and capture manually.
1307 if (compositing_iosurface_ && frame_subscriber_) { 1307 if (compositing_iosurface_ && frame_subscriber_) {
1308 const base::TimeTicks present_time = base::TimeTicks::Now(); 1308 const base::TimeTicks present_time = base::TimeTicks::Now();
1309 scoped_refptr<media::VideoFrame> frame; 1309 scoped_refptr<media::VideoFrame> frame;
1310 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback; 1310 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback;
1311 if (frame_subscriber_->ShouldCaptureFrame(present_time, 1311 if (frame_subscriber_->ShouldCaptureFrame(present_time,
1312 &frame, &callback)) { 1312 &frame, &callback)) {
1313 CGLSetCurrentContext(compositing_iosurface_context_->cgl_context()); 1313 gfx::ScopedCGLSetCurrentContext scoped_set_current_context(
1314 compositing_iosurface_context_->cgl_context());
1314 compositing_iosurface_->SetIOSurfaceWithContextCurrent( 1315 compositing_iosurface_->SetIOSurfaceWithContextCurrent(
1315 compositing_iosurface_context_, surface_handle, size, 1316 compositing_iosurface_context_, surface_handle, size,
1316 surface_scale_factor); 1317 surface_scale_factor);
1317 compositing_iosurface_->CopyToVideoFrame( 1318 compositing_iosurface_->CopyToVideoFrame(
1318 gfx::Rect(size), frame, 1319 gfx::Rect(size), frame,
1319 base::Bind(callback, present_time)); 1320 base::Bind(callback, present_time));
1320 return; 1321 return;
1321 } 1322 }
1322 } 1323 }
1323 1324
(...skipping 21 matching lines...) Expand all
1345 // Ensure compositing_iosurface_ and compositing_iosurface_context_ be 1346 // Ensure compositing_iosurface_ and compositing_iosurface_context_ be
1346 // allocated. 1347 // allocated.
1347 if (!CreateCompositedIOSurface()) { 1348 if (!CreateCompositedIOSurface()) {
1348 LOG(ERROR) << "Failed to create CompositingIOSurface"; 1349 LOG(ERROR) << "Failed to create CompositingIOSurface";
1349 GotAcceleratedCompositingError(); 1350 GotAcceleratedCompositingError();
1350 return; 1351 return;
1351 } 1352 }
1352 1353
1353 // Make the context current and update the IOSurface with the handle 1354 // Make the context current and update the IOSurface with the handle
1354 // passed in by the swap command. 1355 // passed in by the swap command.
1355 CGLSetCurrentContext(compositing_iosurface_context_->cgl_context()); 1356 gfx::ScopedCGLSetCurrentContext scoped_set_current_context(
1357 compositing_iosurface_context_->cgl_context());
1356 if (!compositing_iosurface_->SetIOSurfaceWithContextCurrent( 1358 if (!compositing_iosurface_->SetIOSurfaceWithContextCurrent(
1357 compositing_iosurface_context_, surface_handle, size, 1359 compositing_iosurface_context_, surface_handle, size,
1358 surface_scale_factor)) { 1360 surface_scale_factor)) {
1359 LOG(ERROR) << "Failed SetIOSurface on CompositingIOSurfaceMac"; 1361 LOG(ERROR) << "Failed SetIOSurface on CompositingIOSurfaceMac";
1360 GotAcceleratedCompositingError(); 1362 GotAcceleratedCompositingError();
1361 return; 1363 return;
1362 } 1364 }
1363 1365
1364 // Grab video frames now that the IOSurface has been set up. Note that this 1366 // Grab video frames now that the IOSurface has been set up. Note that this
1365 // will be done in an offscreen context, so it is necessary to re-set the 1367 // will be done in an offscreen context, so it is necessary to re-set the
1366 // current context afterward. 1368 // current context afterward.
1367 if (frame_subscriber_) { 1369 if (frame_subscriber_) {
1368 const base::TimeTicks present_time = base::TimeTicks::Now(); 1370 const base::TimeTicks present_time = base::TimeTicks::Now();
1369 scoped_refptr<media::VideoFrame> frame; 1371 scoped_refptr<media::VideoFrame> frame;
1370 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback; 1372 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback;
1371 if (frame_subscriber_->ShouldCaptureFrame(present_time, 1373 if (frame_subscriber_->ShouldCaptureFrame(present_time,
1372 &frame, &callback)) { 1374 &frame, &callback)) {
1373 // Flush the context that updated the IOSurface, to ensure that the 1375 // Flush the context that updated the IOSurface, to ensure that the
1374 // context that does the copy picks up the correct version. 1376 // context that does the copy picks up the correct version.
1375 glFlush(); 1377 glFlush();
1376 compositing_iosurface_->CopyToVideoFrame( 1378 compositing_iosurface_->CopyToVideoFrame(
1377 gfx::Rect(size), frame, 1379 gfx::Rect(size), frame,
1378 base::Bind(callback, present_time)); 1380 base::Bind(callback, present_time));
1379 CGLSetCurrentContext(compositing_iosurface_context_->cgl_context()); 1381 DCHECK_EQ(CGLGetCurrentContext(),
1382 compositing_iosurface_context_->cgl_context());
1380 } 1383 }
1381 } 1384 }
1382 1385
1383 // Create the layer for the composited content only after the IOSurface has 1386 // Create the layer for the composited content only after the IOSurface has
1384 // been initialized. 1387 // been initialized.
1385 if (!CreateCompositedIOSurfaceLayer()) { 1388 if (!CreateCompositedIOSurfaceLayer()) {
1386 LOG(ERROR) << "Failed to create CompositingIOSurface layer"; 1389 LOG(ERROR) << "Failed to create CompositingIOSurface layer";
1387 GotAcceleratedCompositingError(); 1390 GotAcceleratedCompositingError();
1388 return; 1391 return;
1389 } 1392 }
(...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after
2904 "h", damagedRect.height()); 2907 "h", damagedRect.height());
2905 // NSRectFill is extremely slow (15ms for a window on a fast MacPro), so 2908 // NSRectFill is extremely slow (15ms for a window on a fast MacPro), so
2906 // this is only done when it's a real invalidation from window damage (not 2909 // this is only done when it's a real invalidation from window damage (not
2907 // when a BuffersSwapped was received). Note that even a 1x1 NSRectFill 2910 // when a BuffersSwapped was received). Note that even a 1x1 NSRectFill
2908 // can take many milliseconds sometimes (!) so this is skipped completely 2911 // can take many milliseconds sometimes (!) so this is skipped completely
2909 // for drawRects that are triggered by BuffersSwapped messages. 2912 // for drawRects that are triggered by BuffersSwapped messages.
2910 [[NSColor clearColor] set]; 2913 [[NSColor clearColor] set];
2911 NSRectFill(dirtyRect); 2914 NSRectFill(dirtyRect);
2912 } 2915 }
2913 2916
2914 CGLSetCurrentContext( 2917 gfx::ScopedCGLSetCurrentContext scoped_set_current_context(
2915 renderWidgetHostView_->compositing_iosurface_context_->cgl_context()); 2918 renderWidgetHostView_->compositing_iosurface_context_->cgl_context());
2916 if (renderWidgetHostView_->DrawIOSurfaceWithoutCoreAnimation()) 2919 if (renderWidgetHostView_->DrawIOSurfaceWithoutCoreAnimation())
2917 return; 2920 return;
2918 2921
2919 // On error, fall back to software and fall through to the non-accelerated 2922 // On error, fall back to software and fall through to the non-accelerated
2920 // drawing path. 2923 // drawing path.
2921 renderWidgetHostView_->GotAcceleratedCompositingError(); 2924 renderWidgetHostView_->GotAcceleratedCompositingError();
2922 } 2925 }
2923 2926
2924 CGContextRef context = static_cast<CGContextRef>( 2927 CGContextRef context = static_cast<CGContextRef>(
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after
4090 return YES; 4093 return YES;
4091 } 4094 }
4092 4095
4093 - (BOOL)isOpaque { 4096 - (BOOL)isOpaque {
4094 if (renderWidgetHostView_->use_core_animation_) 4097 if (renderWidgetHostView_->use_core_animation_)
4095 return YES; 4098 return YES;
4096 return [super isOpaque]; 4099 return [super isOpaque];
4097 } 4100 }
4098 4101
4099 @end 4102 @end
OLDNEW
« no previous file with comments | « content/browser/renderer_host/display_link_mac.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698