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

Unified Diff: content/browser/renderer_host/compositing_iosurface_layer_mac.mm

Issue 142413008: Ensure that CAOpenGLLayer uses the dGPU when appropriate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ca_1_nobackingstore
Patch Set: Fix variable name Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5961611d034ebbef03e7855b5892533219157421 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,42 @@
// 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 number_virtual_screens = 0;
+ CGLPixelFormatObj pixel_format = NULL;
+ CGLError error = CGLChoosePixelFormat(
+ &attribs.front(), &pixel_format, &number_virtual_screens);
+ 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();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698