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 "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 "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 8 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
9 #include "third_party/skia/include/gpu/GrContext.h" | 9 #include "third_party/skia/include/gpu/GrContext.h" |
10 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | 10 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
11 | 11 |
12 namespace webkit { | 12 namespace webkit { |
13 namespace gpu { | 13 namespace gpu { |
14 | 14 |
15 static void BindWebGraphicsContext3DGLContextCallback( | 15 static void BindWebGraphicsContext3DGLContextCallback( |
16 const GrGLInterface* interface) { | 16 const GrGLInterface* interface) { |
17 #if GR_GL_PER_GL_FUNC_CALLBACK | |
18 reinterpret_cast<blink::WebGraphicsContext3D*>( | 17 reinterpret_cast<blink::WebGraphicsContext3D*>( |
19 interface->fCallbackData)->makeContextCurrent(); | 18 interface->fCallbackData)->makeContextCurrent(); |
20 #endif | |
21 } | 19 } |
22 | 20 |
23 GrContextForWebGraphicsContext3D::GrContextForWebGraphicsContext3D( | 21 GrContextForWebGraphicsContext3D::GrContextForWebGraphicsContext3D( |
24 blink::WebGraphicsContext3D* context3d) { | 22 blink::WebGraphicsContext3D* context3d) { |
25 if (!context3d) | 23 if (!context3d) |
26 return; | 24 return; |
27 | 25 |
28 skia::RefPtr<GrGLInterface> interface = skia::AdoptRef( | 26 skia::RefPtr<GrGLInterface> interface = skia::AdoptRef( |
29 context3d->createGrGLInterface()); | 27 context3d->createGrGLInterface()); |
30 if (!interface) | 28 if (!interface) |
31 return; | 29 return; |
32 | 30 |
33 #if GR_GL_PER_GL_FUNC_CALLBACK | |
34 interface->fCallback = BindWebGraphicsContext3DGLContextCallback; | 31 interface->fCallback = BindWebGraphicsContext3DGLContextCallback; |
35 interface->fCallbackData = | 32 interface->fCallbackData = |
36 reinterpret_cast<GrGLInterfaceCallbackData>(context3d); | 33 reinterpret_cast<GrGLInterfaceCallbackData>(context3d); |
37 #endif | |
38 | 34 |
39 gr_context_ = skia::AdoptRef(GrContext::Create( | 35 gr_context_ = skia::AdoptRef(GrContext::Create( |
40 kOpenGL_GrBackend, | 36 kOpenGL_GrBackend, |
41 reinterpret_cast<GrBackendContext>(interface.get()))); | 37 reinterpret_cast<GrBackendContext>(interface.get()))); |
42 if (!gr_context_) | 38 if (!gr_context_) |
43 return; | 39 return; |
44 | 40 |
45 bool nonzero_allocation = true; | 41 bool nonzero_allocation = true; |
46 SetMemoryLimit(nonzero_allocation); | 42 SetMemoryLimit(nonzero_allocation); |
47 } | 43 } |
(...skipping 20 matching lines...) Expand all Loading... |
68 } else { | 64 } else { |
69 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", \ | 65 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", \ |
70 TRACE_EVENT_SCOPE_THREAD); | 66 TRACE_EVENT_SCOPE_THREAD); |
71 gr_context_->freeGpuResources(); | 67 gr_context_->freeGpuResources(); |
72 gr_context_->setTextureCacheLimits(0, 0); | 68 gr_context_->setTextureCacheLimits(0, 0); |
73 } | 69 } |
74 } | 70 } |
75 | 71 |
76 } // namespace gpu | 72 } // namespace gpu |
77 } // namespace webkit | 73 } // namespace webkit |
OLD | NEW |