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

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

Issue 478483002: Remove code used by --disable-delegated-renderer on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 4 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
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "content/browser/renderer_host/compositing_iosurface_shader_programs_ma c.h"
15 #include "content/browser/gpu/gpu_data_manager_impl.h" 14 #include "content/browser/gpu/gpu_data_manager_impl.h"
16 #include "ui/base/ui_base_switches.h" 15 #include "ui/base/ui_base_switches.h"
17 #include "ui/gl/gl_switches.h" 16 #include "ui/gl/gl_switches.h"
18 #include "ui/gl/gpu_switching_manager.h" 17 #include "ui/gl/gpu_switching_manager.h"
19 18
20 namespace content { 19 namespace content {
21 20
22 // static 21 // static
23 scoped_refptr<CompositingIOSurfaceContext> 22 scoped_refptr<CompositingIOSurfaceContext>
24 CompositingIOSurfaceContext::Get(int window_number) { 23 CompositingIOSurfaceContext::Get(int window_number) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 pixel_format, share_context, cgl_context_strong.InitializeInto()); 62 pixel_format, share_context, cgl_context_strong.InitializeInto());
64 if (error != kCGLNoError) { 63 if (error != kCGLNoError) {
65 LOG(ERROR) << "Failed to create context object."; 64 LOG(ERROR) << "Failed to create context object.";
66 return NULL; 65 return NULL;
67 } 66 }
68 cgl_context = cgl_context_strong; 67 cgl_context = cgl_context_strong;
69 68
70 // Note that VSync is ignored because CoreAnimation will automatically 69 // Note that VSync is ignored because CoreAnimation will automatically
71 // rate limit draws. 70 // rate limit draws.
72 71
73 // Prepare the shader program cache. Precompile the shader programs
74 // needed to draw the IO Surface for non-offscreen contexts.
75 bool prepared = false;
76 scoped_ptr<CompositingIOSurfaceShaderPrograms> shader_program_cache;
77 {
78 gfx::ScopedCGLSetCurrentContext scoped_set_current_context(cgl_context);
79 shader_program_cache.reset(new CompositingIOSurfaceShaderPrograms());
80 if (window_number == kOffscreenContextWindowNumber) {
81 prepared = true;
82 } else {
83 prepared = (
84 shader_program_cache->UseBlitProgram() &&
85 shader_program_cache->UseSolidWhiteProgram());
86 }
87 glUseProgram(0u);
88 }
89 if (!prepared) {
90 LOG(ERROR) << "IOSurface failed to compile/link required shader programs.";
91 return NULL;
92 }
93
94 return new CompositingIOSurfaceContext( 72 return new CompositingIOSurfaceContext(
95 window_number, 73 window_number,
96 cgl_context_strong, 74 cgl_context_strong,
97 cgl_context, 75 cgl_context);
98 shader_program_cache.Pass());
99 } 76 }
100 77
101 void CompositingIOSurfaceContext::PoisonContextAndSharegroup() { 78 void CompositingIOSurfaceContext::PoisonContextAndSharegroup() {
102 if (poisoned_) 79 if (poisoned_)
103 return; 80 return;
104 81
105 for (WindowMap::iterator it = window_map()->begin(); 82 for (WindowMap::iterator it = window_map()->begin();
106 it != window_map()->end(); 83 it != window_map()->end();
107 ++it) { 84 ++it) {
108 it->second->poisoned_ = true; 85 it->second->poisoned_ = true;
109 } 86 }
110 window_map()->clear(); 87 window_map()->clear();
111 } 88 }
112 89
113 CompositingIOSurfaceContext::CompositingIOSurfaceContext( 90 CompositingIOSurfaceContext::CompositingIOSurfaceContext(
114 int window_number, 91 int window_number,
115 base::ScopedTypeRef<CGLContextObj> cgl_context_strong, 92 base::ScopedTypeRef<CGLContextObj> cgl_context_strong,
116 CGLContextObj cgl_context, 93 CGLContextObj cgl_context)
117 scoped_ptr<CompositingIOSurfaceShaderPrograms> shader_program_cache)
118 : window_number_(window_number), 94 : window_number_(window_number),
119 cgl_context_strong_(cgl_context_strong), 95 cgl_context_strong_(cgl_context_strong),
120 cgl_context_(cgl_context), 96 cgl_context_(cgl_context),
121 shader_program_cache_(shader_program_cache.Pass()),
122 poisoned_(false) { 97 poisoned_(false) {
123 DCHECK(window_map()->find(window_number_) == window_map()->end()); 98 DCHECK(window_map()->find(window_number_) == window_map()->end());
124 window_map()->insert(std::make_pair(window_number_, this)); 99 window_map()->insert(std::make_pair(window_number_, this));
125 100
126 GpuDataManager::GetInstance()->AddObserver(this); 101 GpuDataManager::GetInstance()->AddObserver(this);
127 } 102 }
128 103
129 CompositingIOSurfaceContext::~CompositingIOSurfaceContext() { 104 CompositingIOSurfaceContext::~CompositingIOSurfaceContext() {
130 GpuDataManager::GetInstance()->RemoveObserver(this); 105 GpuDataManager::GetInstance()->RemoveObserver(this);
131 106
132 {
133 gfx::ScopedCGLSetCurrentContext scoped_set_current_context(cgl_context_);
134 shader_program_cache_->Reset();
135 }
136 if (!poisoned_) { 107 if (!poisoned_) {
137 DCHECK(window_map()->find(window_number_) != window_map()->end()); 108 DCHECK(window_map()->find(window_number_) != window_map()->end());
138 DCHECK(window_map()->find(window_number_)->second == this); 109 DCHECK(window_map()->find(window_number_)->second == this);
139 window_map()->erase(window_number_); 110 window_map()->erase(window_number_);
140 } else { 111 } else {
141 WindowMap::const_iterator found = window_map()->find(window_number_); 112 WindowMap::const_iterator found = window_map()->find(window_number_);
142 if (found != window_map()->end()) 113 if (found != window_map()->end())
143 DCHECK(found->second != this); 114 DCHECK(found->second != this);
144 } 115 }
145 } 116 }
146 117
147 void CompositingIOSurfaceContext::OnGpuSwitching() { 118 void CompositingIOSurfaceContext::OnGpuSwitching() {
148 // Recreate all browser-side GL contexts whenever the GPU switches. If this 119 // Recreate all browser-side GL contexts whenever the GPU switches. If this
149 // is not done, performance will suffer. 120 // is not done, performance will suffer.
150 // http://crbug.com/361493 121 // http://crbug.com/361493
151 PoisonContextAndSharegroup(); 122 PoisonContextAndSharegroup();
152 } 123 }
153 124
154 // static 125 // static
155 CompositingIOSurfaceContext::WindowMap* 126 CompositingIOSurfaceContext::WindowMap*
156 CompositingIOSurfaceContext::window_map() { 127 CompositingIOSurfaceContext::window_map() {
157 return window_map_.Pointer(); 128 return window_map_.Pointer();
158 } 129 }
159 130
160 // static 131 // static
161 base::LazyInstance<CompositingIOSurfaceContext::WindowMap> 132 base::LazyInstance<CompositingIOSurfaceContext::WindowMap>
162 CompositingIOSurfaceContext::window_map_; 133 CompositingIOSurfaceContext::window_map_;
163 134
164 } // namespace content 135 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698