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

Side by Side Diff: ui/gl/gl_context_cgl.cc

Issue 1420533009: Cleanup GpuMemoryManager and helpers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more cleanup. Created 5 years, 1 month 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
« no previous file with comments | « ui/gl/gl_context_cgl.h ('k') | ui/gl/gl_context_egl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/gl/gl_context_cgl.h" 5 #include "ui/gl/gl_context_cgl.h"
6 6
7 #include <OpenGL/CGLRenderers.h> 7 #include <OpenGL/CGLRenderers.h>
8 #include <OpenGL/CGLTypes.h> 8 #include <OpenGL/CGLTypes.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 } 252 }
253 253
254 void* GLContextCGL::GetHandle() { 254 void* GLContextCGL::GetHandle() {
255 return context_; 255 return context_;
256 } 256 }
257 257
258 void GLContextCGL::OnSetSwapInterval(int interval) { 258 void GLContextCGL::OnSetSwapInterval(int interval) {
259 DCHECK(IsCurrent(nullptr)); 259 DCHECK(IsCurrent(nullptr));
260 } 260 }
261 261
262 bool GLContextCGL::GetTotalGpuMemory(size_t* bytes) {
263 DCHECK(bytes);
264 *bytes = 0;
265
266 CGLContextObj context = reinterpret_cast<CGLContextObj>(context_);
267 if (!context)
268 return false;
269
270 // Retrieve the current renderer ID
271 GLint current_renderer_id = 0;
272 if (CGLGetParameter(context,
273 kCGLCPCurrentRendererID,
274 &current_renderer_id) != kCGLNoError)
275 return false;
276
277 // Iterate through the list of all renderers
278 GLuint display_mask = static_cast<GLuint>(-1);
279 CGLRendererInfoObj renderer_info = nullptr;
280 GLint num_renderers = 0;
281 if (CGLQueryRendererInfo(display_mask,
282 &renderer_info,
283 &num_renderers) != kCGLNoError)
284 return false;
285
286 scoped_ptr<CGLRendererInfoObj,
287 CGLRendererInfoObjDeleter> scoper(&renderer_info);
288
289 for (GLint renderer_index = 0;
290 renderer_index < num_renderers;
291 ++renderer_index) {
292 // Skip this if this renderer is not the current renderer.
293 GLint renderer_id = 0;
294 if (CGLDescribeRenderer(renderer_info,
295 renderer_index,
296 kCGLRPRendererID,
297 &renderer_id) != kCGLNoError)
298 continue;
299 if (renderer_id != current_renderer_id)
300 continue;
301 // Retrieve the video memory for the renderer.
302 GLint video_memory = 0;
303 if (CGLDescribeRenderer(renderer_info,
304 renderer_index,
305 kCGLRPVideoMemory,
306 &video_memory) != kCGLNoError)
307 continue;
308 *bytes = video_memory;
309 return true;
310 }
311
312 return false;
313 }
314
315 void GLContextCGL::SetSafeToForceGpuSwitch() { 262 void GLContextCGL::SetSafeToForceGpuSwitch() {
316 safe_to_force_gpu_switch_ = true; 263 safe_to_force_gpu_switch_ = true;
317 } 264 }
318 265
319 266
320 GLContextCGL::~GLContextCGL() { 267 GLContextCGL::~GLContextCGL() {
321 Destroy(); 268 Destroy();
322 } 269 }
323 270
324 GpuPreference GLContextCGL::GetGpuPreference() { 271 GpuPreference GLContextCGL::GetGpuPreference() {
325 return gpu_preference_; 272 return gpu_preference_;
326 } 273 }
327 274
328 } // namespace gfx 275 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_context_cgl.h ('k') | ui/gl/gl_context_egl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698