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

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

Issue 408103004: Mac: Fix bad framerate when capturing tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/compositing_iosurface_context_mac.h" 5 #include "content/browser/renderer_host/compositing_iosurface_context_mac.h"
6 6
7 #include <OpenGL/gl.h> 7 #include <OpenGL/gl.h>
8 #include <OpenGL/OpenGL.h> 8 #include <OpenGL/OpenGL.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 13 matching lines...) Expand all
24 CompositingIOSurfaceContext::Get(int window_number) { 24 CompositingIOSurfaceContext::Get(int window_number) {
25 TRACE_EVENT0("browser", "CompositingIOSurfaceContext::Get"); 25 TRACE_EVENT0("browser", "CompositingIOSurfaceContext::Get");
26 26
27 // Return the context for this window_number, if it exists. 27 // Return the context for this window_number, if it exists.
28 WindowMap::iterator found = window_map()->find(window_number); 28 WindowMap::iterator found = window_map()->find(window_number);
29 if (found != window_map()->end()) { 29 if (found != window_map()->end()) {
30 DCHECK(!found->second->poisoned_); 30 DCHECK(!found->second->poisoned_);
31 return found->second; 31 return found->second;
32 } 32 }
33 33
34 static bool is_vsync_disabled =
35 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync);
36
37 base::ScopedTypeRef<CGLContextObj> cgl_context_strong; 34 base::ScopedTypeRef<CGLContextObj> cgl_context_strong;
38 CGLContextObj cgl_context = NULL; 35 CGLContextObj cgl_context = NULL;
39 CGLError error = kCGLNoError; 36 CGLError error = kCGLNoError;
40 37
41 // Create the pixel format object for the context. 38 // Create the pixel format object for the context.
42 std::vector<CGLPixelFormatAttribute> attribs; 39 std::vector<CGLPixelFormatAttribute> attribs;
43 attribs.push_back(kCGLPFADepthSize); 40 attribs.push_back(kCGLPFADepthSize);
44 attribs.push_back(static_cast<CGLPixelFormatAttribute>(0)); 41 attribs.push_back(static_cast<CGLPixelFormatAttribute>(0));
45 if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) { 42 if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) {
46 attribs.push_back(kCGLPFAAllowOfflineRenderers); 43 attribs.push_back(kCGLPFAAllowOfflineRenderers);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 88 }
92 if (!prepared) { 89 if (!prepared) {
93 LOG(ERROR) << "IOSurface failed to compile/link required shader programs."; 90 LOG(ERROR) << "IOSurface failed to compile/link required shader programs.";
94 return NULL; 91 return NULL;
95 } 92 }
96 93
97 return new CompositingIOSurfaceContext( 94 return new CompositingIOSurfaceContext(
98 window_number, 95 window_number,
99 cgl_context_strong, 96 cgl_context_strong,
100 cgl_context, 97 cgl_context,
101 is_vsync_disabled,
102 shader_program_cache.Pass()); 98 shader_program_cache.Pass());
103 } 99 }
104 100
105 void CompositingIOSurfaceContext::PoisonContextAndSharegroup() { 101 void CompositingIOSurfaceContext::PoisonContextAndSharegroup() {
106 if (poisoned_) 102 if (poisoned_)
107 return; 103 return;
108 104
109 for (WindowMap::iterator it = window_map()->begin(); 105 for (WindowMap::iterator it = window_map()->begin();
110 it != window_map()->end(); 106 it != window_map()->end();
111 ++it) { 107 ++it) {
112 it->second->poisoned_ = true; 108 it->second->poisoned_ = true;
113 } 109 }
114 window_map()->clear(); 110 window_map()->clear();
115 } 111 }
116 112
117 CompositingIOSurfaceContext::CompositingIOSurfaceContext( 113 CompositingIOSurfaceContext::CompositingIOSurfaceContext(
118 int window_number, 114 int window_number,
119 base::ScopedTypeRef<CGLContextObj> cgl_context_strong, 115 base::ScopedTypeRef<CGLContextObj> cgl_context_strong,
120 CGLContextObj cgl_context, 116 CGLContextObj cgl_context,
121 bool is_vsync_disabled,
122 scoped_ptr<CompositingIOSurfaceShaderPrograms> shader_program_cache) 117 scoped_ptr<CompositingIOSurfaceShaderPrograms> shader_program_cache)
123 : window_number_(window_number), 118 : window_number_(window_number),
124 cgl_context_strong_(cgl_context_strong), 119 cgl_context_strong_(cgl_context_strong),
125 cgl_context_(cgl_context), 120 cgl_context_(cgl_context),
126 is_vsync_disabled_(is_vsync_disabled),
127 shader_program_cache_(shader_program_cache.Pass()), 121 shader_program_cache_(shader_program_cache.Pass()),
128 poisoned_(false) { 122 poisoned_(false) {
129 DCHECK(window_map()->find(window_number_) == window_map()->end()); 123 DCHECK(window_map()->find(window_number_) == window_map()->end());
130 window_map()->insert(std::make_pair(window_number_, this)); 124 window_map()->insert(std::make_pair(window_number_, this));
131 125
132 GpuDataManager::GetInstance()->AddObserver(this); 126 GpuDataManager::GetInstance()->AddObserver(this);
133 } 127 }
134 128
135 CompositingIOSurfaceContext::~CompositingIOSurfaceContext() { 129 CompositingIOSurfaceContext::~CompositingIOSurfaceContext() {
136 GpuDataManager::GetInstance()->RemoveObserver(this); 130 GpuDataManager::GetInstance()->RemoveObserver(this);
(...skipping 24 matching lines...) Expand all
161 CompositingIOSurfaceContext::WindowMap* 155 CompositingIOSurfaceContext::WindowMap*
162 CompositingIOSurfaceContext::window_map() { 156 CompositingIOSurfaceContext::window_map() {
163 return window_map_.Pointer(); 157 return window_map_.Pointer();
164 } 158 }
165 159
166 // static 160 // static
167 base::LazyInstance<CompositingIOSurfaceContext::WindowMap> 161 base::LazyInstance<CompositingIOSurfaceContext::WindowMap>
168 CompositingIOSurfaceContext::window_map_; 162 CompositingIOSurfaceContext::window_map_;
169 163
170 } // namespace content 164 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698