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

Side by Side Diff: webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc

Issue 802113002: Revert "Revert of Extract WebGraphicsContext3DImpl from webkit/common/gpu. (patchset #12 id:220001 … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE Created 6 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
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 "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" 5 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "gpu/blink/webgraphicscontext3d_impl.h"
9 #include "gpu/command_buffer/client/gles2_lib.h" 10 #include "gpu/command_buffer/client/gles2_lib.h"
10 #include "third_party/skia/include/gpu/GrContext.h" 11 #include "third_party/skia/include/gpu/GrContext.h"
11 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" 12 #include "third_party/skia/include/gpu/gl/GrGLInterface.h"
12 #include "webkit/common/gpu/webgraphicscontext3d_impl.h"
13 13
14 namespace webkit { 14 namespace webkit {
15 namespace gpu { 15 namespace gpu {
16 16
17 namespace { 17 namespace {
18 18
19 // Singleton used to initialize and terminate the gles2 library. 19 // Singleton used to initialize and terminate the gles2 library.
20 class GLES2Initializer { 20 class GLES2Initializer {
21 public: 21 public:
22 GLES2Initializer() { gles2::Initialize(); } 22 GLES2Initializer() { gles2::Initialize(); }
23 23
24 ~GLES2Initializer() { gles2::Terminate(); } 24 ~GLES2Initializer() { gles2::Terminate(); }
25 25
26 private: 26 private:
27 DISALLOW_COPY_AND_ASSIGN(GLES2Initializer); 27 DISALLOW_COPY_AND_ASSIGN(GLES2Initializer);
28 }; 28 };
29 29
30 base::LazyInstance<GLES2Initializer> g_gles2_initializer = 30 base::LazyInstance<GLES2Initializer> g_gles2_initializer =
31 LAZY_INSTANCE_INITIALIZER; 31 LAZY_INSTANCE_INITIALIZER;
32 32
33 void BindWebGraphicsContext3DGLContextCallback(const GrGLInterface* interface) { 33 void BindWebGraphicsContext3DGLContextCallback(const GrGLInterface* interface) {
34 gles2::SetGLContext(reinterpret_cast<WebGraphicsContext3DImpl*>( 34 gles2::SetGLContext(reinterpret_cast<gpu_blink::WebGraphicsContext3DImpl*>(
35 interface->fCallbackData)->GetGLInterface()); 35 interface->fCallbackData)->GetGLInterface());
36 } 36 }
37 37
38 } // namespace anonymous 38 } // namespace
39 39
40 GrContextForWebGraphicsContext3D::GrContextForWebGraphicsContext3D( 40 GrContextForWebGraphicsContext3D::GrContextForWebGraphicsContext3D(
41 WebGraphicsContext3DImpl* context3d) { 41 gpu_blink::WebGraphicsContext3DImpl* context3d) {
42 if (!context3d) 42 if (!context3d)
43 return; 43 return;
44 44
45 // Ensure the gles2 library is initialized first in a thread safe way. 45 // Ensure the gles2 library is initialized first in a thread safe way.
46 g_gles2_initializer.Get(); 46 g_gles2_initializer.Get();
47 gles2::SetGLContext(context3d->GetGLInterface()); 47 gles2::SetGLContext(context3d->GetGLInterface());
48 skia::RefPtr<GrGLInterface> interface = skia::AdoptRef( 48 skia::RefPtr<GrGLInterface> interface = skia::AdoptRef(
49 context3d->createGrGLInterface()); 49 context3d->createGrGLInterface());
50 if (!interface) 50 if (!interface)
51 return; 51 return;
(...skipping 29 matching lines...) Expand all
81 void GrContextForWebGraphicsContext3D::FreeGpuResources() { 81 void GrContextForWebGraphicsContext3D::FreeGpuResources() {
82 if (gr_context_) { 82 if (gr_context_) {
83 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", \ 83 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", \
84 TRACE_EVENT_SCOPE_THREAD); 84 TRACE_EVENT_SCOPE_THREAD);
85 gr_context_->freeGpuResources(); 85 gr_context_->freeGpuResources();
86 } 86 }
87 } 87 }
88 88
89 } // namespace gpu 89 } // namespace gpu
90 } // namespace webkit 90 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/common/gpu/grcontext_for_webgraphicscontext3d.h ('k') | webkit/common/gpu/webgraphicscontext3d_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698