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

Side by Side Diff: ui/accelerated_widget_mac/io_surface_context.mm

Issue 2721553004: Remove auto raw pointer deduction from non-linux specific code. (Closed)
Patch Set: rebase Created 3 years, 9 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
« no previous file with comments | « ui/accelerated_widget_mac/ca_renderer_layer_tree.mm ('k') | no next file » | 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) 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 "ui/accelerated_widget_mac/io_surface_context.h" 5 #include "ui/accelerated_widget_mac/io_surface_context.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/logging.h" 12 #include "base/logging.h"
13 #include "base/trace_event/trace_event.h" 13 #include "base/trace_event/trace_event.h"
14 #include "ui/gl/gl_switches.h" 14 #include "ui/gl/gl_switches.h"
15 #include "ui/gl/gpu_switching_manager.h" 15 #include "ui/gl/gpu_switching_manager.h"
16 16
17 namespace ui { 17 namespace ui {
18 18
19 namespace { 19 namespace {
20 20
21 // The global map from window number and window ordering to context data. 21 // The global map from window number and window ordering to context data.
22 using TypeMap = std::map<IOSurfaceContext::Type, IOSurfaceContext*>; 22 using TypeMap = std::map<IOSurfaceContext::Type, IOSurfaceContext*>;
23 23
24 TypeMap* GetTypeMap() { 24 TypeMap* GetTypeMap() {
25 static auto type_map = new TypeMap(); 25 static auto* type_map = new TypeMap();
26 return type_map; 26 return type_map;
27 } 27 }
28 28
29 } // namespace 29 } // namespace
30 30
31 // static 31 // static
32 scoped_refptr<IOSurfaceContext> 32 scoped_refptr<IOSurfaceContext>
33 IOSurfaceContext::Get(Type type) { 33 IOSurfaceContext::Get(Type type) {
34 TRACE_EVENT0("browser", "IOSurfaceContext::Get"); 34 TRACE_EVENT0("browser", "IOSurfaceContext::Get");
35 35
36 // Return the context for this type, if it exists. 36 // Return the context for this type, if it exists.
37 auto type_map = GetTypeMap(); 37 auto* type_map = GetTypeMap();
38 TypeMap::iterator found = type_map->find(type); 38 TypeMap::iterator found = type_map->find(type);
39 if (found != type_map->end()) { 39 if (found != type_map->end()) {
40 DCHECK(!found->second->poisoned_); 40 DCHECK(!found->second->poisoned_);
41 return found->second; 41 return found->second;
42 } 42 }
43 43
44 base::ScopedTypeRef<CGLContextObj> cgl_context; 44 base::ScopedTypeRef<CGLContextObj> cgl_context;
45 CGLError error = kCGLNoError; 45 CGLError error = kCGLNoError;
46 46
47 // Create the pixel format object for the context. 47 // Create the pixel format object for the context.
(...skipping 25 matching lines...) Expand all
73 return NULL; 73 return NULL;
74 } 74 }
75 75
76 return new IOSurfaceContext(type, cgl_context); 76 return new IOSurfaceContext(type, cgl_context);
77 } 77 }
78 78
79 void IOSurfaceContext::PoisonContextAndSharegroup() { 79 void IOSurfaceContext::PoisonContextAndSharegroup() {
80 if (poisoned_) 80 if (poisoned_)
81 return; 81 return;
82 82
83 auto type_map = GetTypeMap(); 83 auto* type_map = GetTypeMap();
84 for (TypeMap::iterator it = type_map->begin(); it != type_map->end(); ++it) { 84 for (TypeMap::iterator it = type_map->begin(); it != type_map->end(); ++it) {
85 it->second->poisoned_ = true; 85 it->second->poisoned_ = true;
86 } 86 }
87 type_map->clear(); 87 type_map->clear();
88 } 88 }
89 89
90 IOSurfaceContext::IOSurfaceContext( 90 IOSurfaceContext::IOSurfaceContext(
91 Type type, base::ScopedTypeRef<CGLContextObj> cgl_context) 91 Type type, base::ScopedTypeRef<CGLContextObj> cgl_context)
92 : type_(type), cgl_context_(cgl_context), poisoned_(false) { 92 : type_(type), cgl_context_(cgl_context), poisoned_(false) {
93 auto type_map = GetTypeMap(); 93 auto* type_map = GetTypeMap();
94 DCHECK(type_map->find(type_) == type_map->end()); 94 DCHECK(type_map->find(type_) == type_map->end());
95 type_map->insert(std::make_pair(type_, this)); 95 type_map->insert(std::make_pair(type_, this));
96 96
97 ui::GpuSwitchingManager::GetInstance()->AddObserver(this); 97 ui::GpuSwitchingManager::GetInstance()->AddObserver(this);
98 } 98 }
99 99
100 IOSurfaceContext::~IOSurfaceContext() { 100 IOSurfaceContext::~IOSurfaceContext() {
101 ui::GpuSwitchingManager::GetInstance()->RemoveObserver(this); 101 ui::GpuSwitchingManager::GetInstance()->RemoveObserver(this);
102 102
103 auto type_map = GetTypeMap(); 103 auto* type_map = GetTypeMap();
104 if (!poisoned_) { 104 if (!poisoned_) {
105 DCHECK(type_map->find(type_) != type_map->end()); 105 DCHECK(type_map->find(type_) != type_map->end());
106 DCHECK(type_map->find(type_)->second == this); 106 DCHECK(type_map->find(type_)->second == this);
107 type_map->erase(type_); 107 type_map->erase(type_);
108 } else { 108 } else {
109 TypeMap::const_iterator found = type_map->find(type_); 109 TypeMap::const_iterator found = type_map->find(type_);
110 if (found != type_map->end()) 110 if (found != type_map->end())
111 DCHECK(found->second != this); 111 DCHECK(found->second != this);
112 } 112 }
113 } 113 }
114 114
115 void IOSurfaceContext::OnGpuSwitched() { 115 void IOSurfaceContext::OnGpuSwitched() {
116 // Recreate all browser-side GL contexts whenever the GPU switches. If this 116 // Recreate all browser-side GL contexts whenever the GPU switches. If this
117 // is not done, performance will suffer. 117 // is not done, performance will suffer.
118 // http://crbug.com/361493 118 // http://crbug.com/361493
119 PoisonContextAndSharegroup(); 119 PoisonContextAndSharegroup();
120 } 120 }
121 121
122 } // namespace ui 122 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accelerated_widget_mac/ca_renderer_layer_tree.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698