| OLD | NEW |
| 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 "ui/compositor/test/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/blink/webgraphicscontext3d_impl.h" |
| 10 #include "gpu/command_buffer/client/gles2_lib.h" | 10 #include "gpu/command_buffer/client/gles2_lib.h" |
| 11 #include "third_party/skia/include/gpu/GrContext.h" | 11 #include "third_party/skia/include/gpu/GrContext.h" |
| 12 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | 12 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
| 13 | 13 |
| 14 using gpu_blink::WebGraphicsContext3DImpl; | 14 using gpu_blink::WebGraphicsContext3DImpl; |
| 15 | 15 |
| 16 namespace webkit { | 16 namespace ui { |
| 17 namespace gpu { | |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 // Singleton used to initialize and terminate the gles2 library. | 20 // Singleton used to initialize and terminate the gles2 library. |
| 22 class GLES2Initializer { | 21 class GLES2Initializer { |
| 23 public: | 22 public: |
| 24 GLES2Initializer() { gles2::Initialize(); } | 23 GLES2Initializer() { gles2::Initialize(); } |
| 25 | 24 |
| 26 ~GLES2Initializer() { gles2::Terminate(); } | 25 ~GLES2Initializer() { gles2::Terminate(); } |
| 27 | 26 |
| 28 private: | 27 private: |
| 29 DISALLOW_COPY_AND_ASSIGN(GLES2Initializer); | 28 DISALLOW_COPY_AND_ASSIGN(GLES2Initializer); |
| 30 }; | 29 }; |
| 31 | 30 |
| 32 base::LazyInstance<GLES2Initializer> g_gles2_initializer = | 31 base::LazyInstance<GLES2Initializer> g_gles2_initializer = |
| 33 LAZY_INSTANCE_INITIALIZER; | 32 LAZY_INSTANCE_INITIALIZER; |
| 34 | 33 |
| 35 void BindWebGraphicsContext3DGLContextCallback(const GrGLInterface* interface) { | 34 void BindWebGraphicsContext3DGLContextCallback(const GrGLInterface* interface) { |
| 36 gles2::SetGLContext(reinterpret_cast<WebGraphicsContext3DImpl*>( | 35 gles2::SetGLContext(reinterpret_cast<WebGraphicsContext3DImpl*>( |
| 37 interface->fCallbackData)->GetGLInterface()); | 36 interface->fCallbackData)->GetGLInterface()); |
| 38 } | 37 } |
| 39 | 38 |
| 40 } // namespace anonymous | 39 } // namespace |
| 41 | 40 |
| 42 GrContextForWebGraphicsContext3D::GrContextForWebGraphicsContext3D( | 41 GrContextForWebGraphicsContext3D::GrContextForWebGraphicsContext3D( |
| 43 WebGraphicsContext3DImpl* context3d) { | 42 WebGraphicsContext3DImpl* context3d) { |
| 44 if (!context3d) | 43 if (!context3d) |
| 45 return; | 44 return; |
| 46 | 45 |
| 47 // Ensure the gles2 library is initialized first in a thread safe way. | 46 // Ensure the gles2 library is initialized first in a thread safe way. |
| 48 g_gles2_initializer.Get(); | 47 g_gles2_initializer.Get(); |
| 49 gles2::SetGLContext(context3d->GetGLInterface()); | 48 gles2::SetGLContext(context3d->GetGLInterface()); |
| 50 skia::RefPtr<GrGLInterface> interface = skia::AdoptRef( | 49 skia::RefPtr<GrGLInterface> interface = skia::AdoptRef( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 81 } | 80 } |
| 82 | 81 |
| 83 void GrContextForWebGraphicsContext3D::FreeGpuResources() { | 82 void GrContextForWebGraphicsContext3D::FreeGpuResources() { |
| 84 if (gr_context_) { | 83 if (gr_context_) { |
| 85 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", \ | 84 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", \ |
| 86 TRACE_EVENT_SCOPE_THREAD); | 85 TRACE_EVENT_SCOPE_THREAD); |
| 87 gr_context_->freeGpuResources(); | 86 gr_context_->freeGpuResources(); |
| 88 } | 87 } |
| 89 } | 88 } |
| 90 | 89 |
| 91 } // namespace gpu | 90 } // namespace ui |
| 92 } // namespace webkit | |
| OLD | NEW |