Chromium Code Reviews| Index: content/browser/renderer_host/compositing_iosurface_layer_mac.mm |
| diff --git a/content/browser/renderer_host/compositing_iosurface_layer_mac.mm b/content/browser/renderer_host/compositing_iosurface_layer_mac.mm |
| index 0a06d789b80a98eb34ed97b4443773dfd615f12a..864d7480687f88de629e4aeedf6874e2d14a9bbe 100644 |
| --- a/content/browser/renderer_host/compositing_iosurface_layer_mac.mm |
| +++ b/content/browser/renderer_host/compositing_iosurface_layer_mac.mm |
| @@ -14,6 +14,7 @@ |
| #include "content/browser/renderer_host/compositing_iosurface_mac.h" |
| #include "ui/base/cocoa/animation_utils.h" |
| #include "ui/gfx/size_conversions.h" |
| +#include "ui/gl/gpu_switching_manager.h" |
| @implementation CompositingIOSurfaceLayer |
| @@ -62,13 +63,41 @@ |
| // The remaining methods implement the CAOpenGLLayer interface. |
| +- (CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask { |
| + 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 npix = 0; |
|
Nico
2014/01/30 01:56:23
nit: npix isn't very style guide conforming ;-)
ccameron
2014/01/30 06:37:30
Done. I should stop copy-pasting functions directl
|
| + CGLPixelFormatObj pixel_format = NULL; |
| + CGLError error = CGLChoosePixelFormat(&attribs.front(), &pixel_format, &npix); |
| + if (error != kCGLNoError) { |
| + LOG(ERROR) << "Failed to create pixel format for layer."; |
| + return nil; |
| + } |
| + return pixel_format; |
| +} |
| + |
| +- (void)releaseCGLPixelFormat:(CGLPixelFormatObj)pixelFormat { |
| + CGLReleasePixelFormat(pixelFormat); |
| +} |
| + |
| - (CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat { |
| - if (!renderWidgetHostView_) |
| + if (!renderWidgetHostView_) { |
| + LOG(ERROR) << "Cannot create layer context because there is no host."; |
| return nil; |
| + } |
| context_ = renderWidgetHostView_->compositing_iosurface_context_; |
| - if (!context_) |
| + if (!context_) { |
| + LOG(ERROR) << "Cannot create layer context because host has no context."; |
| return nil; |
| + } |
| return context_->cgl_context(); |
| } |