| Index: content/browser/renderer_host/compositing_iosurface_context_mac.mm
|
| diff --git a/content/browser/renderer_host/compositing_iosurface_context_mac.mm b/content/browser/renderer_host/compositing_iosurface_context_mac.mm
|
| index fecab509325fd0c1f8d6cd3cb840afdf488ae973..a66bf5022d3a484b995208e6f891fd53393080f3 100644
|
| --- a/content/browser/renderer_host/compositing_iosurface_context_mac.mm
|
| +++ b/content/browser/renderer_host/compositing_iosurface_context_mac.mm
|
| @@ -19,14 +19,6 @@
|
|
|
| namespace content {
|
|
|
| -CoreAnimationStatus GetCoreAnimationStatus() {
|
| - static CoreAnimationStatus status =
|
| - CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kDisableCoreAnimation) ?
|
| - CORE_ANIMATION_DISABLED : CORE_ANIMATION_ENABLED;
|
| - return status;
|
| -}
|
| -
|
| // static
|
| scoped_refptr<CompositingIOSurfaceContext>
|
| CompositingIOSurfaceContext::Get(int window_number) {
|
| @@ -42,88 +34,44 @@ CompositingIOSurfaceContext::Get(int window_number) {
|
| static bool is_vsync_disabled =
|
| CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync);
|
|
|
| - base::scoped_nsobject<NSOpenGLContext> nsgl_context;
|
| base::ScopedTypeRef<CGLContextObj> cgl_context_strong;
|
| CGLContextObj cgl_context = NULL;
|
| - if (GetCoreAnimationStatus() == CORE_ANIMATION_DISABLED) {
|
| - std::vector<NSOpenGLPixelFormatAttribute> attributes;
|
| - attributes.push_back(NSOpenGLPFADoubleBuffer);
|
| - // We don't need a depth buffer - try setting its size to 0...
|
| - attributes.push_back(NSOpenGLPFADepthSize); attributes.push_back(0);
|
| - if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus())
|
| - attributes.push_back(NSOpenGLPFAAllowOfflineRenderers);
|
| - attributes.push_back(0);
|
| -
|
| - base::scoped_nsobject<NSOpenGLPixelFormat> glPixelFormat(
|
| - [[NSOpenGLPixelFormat alloc] initWithAttributes:&attributes.front()]);
|
| - if (!glPixelFormat) {
|
| - LOG(ERROR) << "NSOpenGLPixelFormat initWithAttributes failed";
|
| - return NULL;
|
| - }
|
| -
|
| - // Create all contexts in the same share group so that the textures don't
|
| - // need to be recreated when transitioning contexts.
|
| - NSOpenGLContext* share_context = nil;
|
| - if (!window_map()->empty())
|
| - share_context = window_map()->begin()->second->nsgl_context();
|
| - nsgl_context.reset(
|
| - [[NSOpenGLContext alloc] initWithFormat:glPixelFormat
|
| - shareContext:share_context]);
|
| - if (!nsgl_context) {
|
| - LOG(ERROR) << "NSOpenGLContext initWithFormat failed";
|
| - return NULL;
|
| - }
|
| -
|
| - // Grab the CGL context that the NSGL context is using. Explicitly
|
| - // retain it, so that it is not double-freed by the scoped type.
|
| - cgl_context = reinterpret_cast<CGLContextObj>(
|
| - [nsgl_context CGLContextObj]);
|
| - if (!cgl_context) {
|
| - LOG(ERROR) << "Failed to retrieve CGLContextObj from NSOpenGLContext";
|
| - return NULL;
|
| - }
|
| -
|
| - // Force [nsgl_context flushBuffer] to wait for vsync.
|
| - GLint swapInterval = is_vsync_disabled ? 0 : 1;
|
| - [nsgl_context setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
|
| - } else {
|
| - CGLError error = kCGLNoError;
|
| -
|
| - // Create the pixel format object for the context.
|
| - std::vector<CGLPixelFormatAttribute> attribs;
|
| - attribs.push_back(kCGLPFADepthSize);
|
| - attribs.push_back(static_cast<CGLPixelFormatAttribute>(0));
|
| - if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) {
|
| - attribs.push_back(kCGLPFAAllowOfflineRenderers);
|
| - attribs.push_back(static_cast<CGLPixelFormatAttribute>(1));
|
| - }
|
| - attribs.push_back(static_cast<CGLPixelFormatAttribute>(0));
|
| - GLint number_virtual_screens = 0;
|
| - base::ScopedTypeRef<CGLPixelFormatObj> pixel_format;
|
| - error = CGLChoosePixelFormat(&attribs.front(),
|
| - pixel_format.InitializeInto(),
|
| - &number_virtual_screens);
|
| - if (error != kCGLNoError) {
|
| - LOG(ERROR) << "Failed to create pixel format object.";
|
| - return NULL;
|
| - }
|
| -
|
| - // Create all contexts in the same share group so that the textures don't
|
| - // need to be recreated when transitioning contexts.
|
| - CGLContextObj share_context = NULL;
|
| - if (!window_map()->empty())
|
| - share_context = window_map()->begin()->second->cgl_context();
|
| - error = CGLCreateContext(
|
| - pixel_format, share_context, cgl_context_strong.InitializeInto());
|
| - if (error != kCGLNoError) {
|
| - LOG(ERROR) << "Failed to create context object.";
|
| - return NULL;
|
| - }
|
| - cgl_context = cgl_context_strong;
|
| + CGLError error = kCGLNoError;
|
| +
|
| + // Create the pixel format object for the context.
|
| + std::vector<CGLPixelFormatAttribute> attribs;
|
| + attribs.push_back(kCGLPFADepthSize);
|
| + attribs.push_back(static_cast<CGLPixelFormatAttribute>(0));
|
| + if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) {
|
| + attribs.push_back(kCGLPFAAllowOfflineRenderers);
|
| + attribs.push_back(static_cast<CGLPixelFormatAttribute>(1));
|
| + }
|
| + attribs.push_back(static_cast<CGLPixelFormatAttribute>(0));
|
| + GLint number_virtual_screens = 0;
|
| + base::ScopedTypeRef<CGLPixelFormatObj> pixel_format;
|
| + error = CGLChoosePixelFormat(&attribs.front(),
|
| + pixel_format.InitializeInto(),
|
| + &number_virtual_screens);
|
| + if (error != kCGLNoError) {
|
| + LOG(ERROR) << "Failed to create pixel format object.";
|
| + return NULL;
|
| + }
|
|
|
| - // Note that VSync is ignored because CoreAnimation will automatically
|
| - // rate limit draws.
|
| + // Create all contexts in the same share group so that the textures don't
|
| + // need to be recreated when transitioning contexts.
|
| + CGLContextObj share_context = NULL;
|
| + if (!window_map()->empty())
|
| + share_context = window_map()->begin()->second->cgl_context();
|
| + error = CGLCreateContext(
|
| + pixel_format, share_context, cgl_context_strong.InitializeInto());
|
| + if (error != kCGLNoError) {
|
| + LOG(ERROR) << "Failed to create context object.";
|
| + return NULL;
|
| }
|
| + cgl_context = cgl_context_strong;
|
| +
|
| + // Note that VSync is ignored because CoreAnimation will automatically
|
| + // rate limit draws.
|
|
|
| // Prepare the shader program cache. Precompile the shader programs
|
| // needed to draw the IO Surface for non-offscreen contexts.
|
| @@ -148,7 +96,6 @@ CompositingIOSurfaceContext::Get(int window_number) {
|
|
|
| return new CompositingIOSurfaceContext(
|
| window_number,
|
| - nsgl_context.release(),
|
| cgl_context_strong,
|
| cgl_context,
|
| is_vsync_disabled,
|
| @@ -169,13 +116,11 @@ void CompositingIOSurfaceContext::PoisonContextAndSharegroup() {
|
|
|
| CompositingIOSurfaceContext::CompositingIOSurfaceContext(
|
| int window_number,
|
| - NSOpenGLContext* nsgl_context,
|
| base::ScopedTypeRef<CGLContextObj> cgl_context_strong,
|
| CGLContextObj cgl_context,
|
| bool is_vsync_disabled,
|
| scoped_ptr<CompositingIOSurfaceShaderPrograms> shader_program_cache)
|
| : window_number_(window_number),
|
| - nsgl_context_(nsgl_context),
|
| cgl_context_strong_(cgl_context_strong),
|
| cgl_context_(cgl_context),
|
| is_vsync_disabled_(is_vsync_disabled),
|
| @@ -205,12 +150,6 @@ CompositingIOSurfaceContext::~CompositingIOSurfaceContext() {
|
| }
|
| }
|
|
|
| -NSOpenGLContext* CompositingIOSurfaceContext::nsgl_context() const {
|
| - // This should not be called from any CoreAnimation paths.
|
| - CHECK(GetCoreAnimationStatus() == CORE_ANIMATION_DISABLED);
|
| - return nsgl_context_;
|
| -}
|
| -
|
| void CompositingIOSurfaceContext::OnGpuSwitching() {
|
| // Recreate all browser-side GL contexts whenever the GPU switches. If this
|
| // is not done, performance will suffer.
|
|
|