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

Side by Side Diff: chrome/renderer/ggl/ggl.cc

Issue 5682008: Make members of Singleton<T> private and only visible to the singleton type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "base/lazy_instance.h"
7 #include "base/ref_counted.h" 8 #include "base/ref_counted.h"
8 #include "base/singleton.h"
9 #include "base/weak_ptr.h" 9 #include "base/weak_ptr.h"
10 #include "chrome/renderer/command_buffer_proxy.h" 10 #include "chrome/renderer/command_buffer_proxy.h"
11 #include "chrome/renderer/ggl/ggl.h" 11 #include "chrome/renderer/ggl/ggl.h"
12 #include "chrome/renderer/gpu_channel_host.h" 12 #include "chrome/renderer/gpu_channel_host.h"
13 #include "chrome/renderer/gpu_video_service_host.h" 13 #include "chrome/renderer/gpu_video_service_host.h"
14 #include "chrome/renderer/media/gles2_video_decode_context.h" 14 #include "chrome/renderer/media/gles2_video_decode_context.h"
15 #include "chrome/renderer/render_widget.h" 15 #include "chrome/renderer/render_widget.h"
16 #include "ipc/ipc_channel_handle.h" 16 #include "ipc/ipc_channel_handle.h"
17 17
18 #if defined(ENABLE_GPU) 18 #if defined(ENABLE_GPU)
(...skipping 22 matching lines...) Expand all
41 gles2::Initialize(); 41 gles2::Initialize();
42 } 42 }
43 43
44 ~GLES2Initializer() { 44 ~GLES2Initializer() {
45 gles2::Terminate(); 45 gles2::Terminate();
46 } 46 }
47 47
48 private: 48 private:
49 DISALLOW_COPY_AND_ASSIGN(GLES2Initializer); 49 DISALLOW_COPY_AND_ASSIGN(GLES2Initializer);
50 }; 50 };
51
52 static base::LazyInstance<GLES2Initializer> g_gles2_initializer(
53 base::LINKER_INITIALIZED);
54
51 } // namespace anonymous 55 } // namespace anonymous
52 56
53 // Manages a GL context. 57 // Manages a GL context.
54 class Context : public base::SupportsWeakPtr<Context> { 58 class Context : public base::SupportsWeakPtr<Context> {
55 public: 59 public:
56 Context(GpuChannelHost* channel, Context* parent); 60 Context(GpuChannelHost* channel, Context* parent);
57 ~Context(); 61 ~Context();
58 62
59 // Initialize a GGL context that can be used in association with a a GPU 63 // Initialize a GGL context that can be used in association with a a GPU
60 // channel acquired from a RenderWidget or RenderView. 64 // channel acquired from a RenderWidget or RenderView.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 int render_view_id, 160 int render_view_id,
157 const gfx::Size& size, 161 const gfx::Size& size,
158 const char* allowed_extensions, 162 const char* allowed_extensions,
159 const int32* attrib_list) { 163 const int32* attrib_list) {
160 DCHECK(size.width() >= 0 && size.height() >= 0); 164 DCHECK(size.width() >= 0 && size.height() >= 0);
161 165
162 if (channel_->state() != GpuChannelHost::kConnected) 166 if (channel_->state() != GpuChannelHost::kConnected)
163 return false; 167 return false;
164 168
165 // Ensure the gles2 library is initialized first in a thread safe way. 169 // Ensure the gles2 library is initialized first in a thread safe way.
166 Singleton<GLES2Initializer>::get(); 170 g_gles2_initializer.Get();
167 171
168 // Allocate a frame buffer ID with respect to the parent. 172 // Allocate a frame buffer ID with respect to the parent.
169 if (parent_.get()) { 173 if (parent_.get()) {
170 // Flush any remaining commands in the parent context to make sure the 174 // Flush any remaining commands in the parent context to make sure the
171 // texture id accounting stays consistent. 175 // texture id accounting stays consistent.
172 int32 token = parent_->gles2_helper_->InsertToken(); 176 int32 token = parent_->gles2_helper_->InsertToken();
173 parent_->gles2_helper_->WaitForToken(token); 177 parent_->gles2_helper_->WaitForToken(token);
174 parent_texture_id_ = parent_->gles2_implementation_->MakeTextureId(); 178 parent_texture_id_ = parent_->gles2_implementation_->MakeTextureId();
175 } 179 }
176 180
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 } 566 }
563 567
564 gpu::gles2::GLES2Implementation* GetImplementation(Context* context) { 568 gpu::gles2::GLES2Implementation* GetImplementation(Context* context) {
565 if (!context) 569 if (!context)
566 return NULL; 570 return NULL;
567 571
568 return context->gles2_implementation(); 572 return context->gles2_implementation();
569 } 573 }
570 574
571 } // namespace ggl 575 } // namespace ggl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698