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/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.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" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 if (!interface) | 52 if (!interface) |
53 return; | 53 return; |
54 | 54 |
55 interface->fCallback = BindWebGraphicsContext3DGLContextCallback; | 55 interface->fCallback = BindWebGraphicsContext3DGLContextCallback; |
56 interface->fCallbackData = | 56 interface->fCallbackData = |
57 reinterpret_cast<GrGLInterfaceCallbackData>(context3d); | 57 reinterpret_cast<GrGLInterfaceCallbackData>(context3d); |
58 | 58 |
59 gr_context_ = skia::AdoptRef(GrContext::Create( | 59 gr_context_ = skia::AdoptRef(GrContext::Create( |
60 kOpenGL_GrBackend, | 60 kOpenGL_GrBackend, |
61 reinterpret_cast<GrBackendContext>(interface.get()))); | 61 reinterpret_cast<GrBackendContext>(interface.get()))); |
62 if (gr_context_) { | |
63 // The limit of the number of GPU resources we hold in the GrContext's | |
64 // GPU cache. | |
65 static const int kMaxGaneshResourceCacheCount = 2048; | |
66 // The limit of the bytes allocated toward GPU resources in the GrContext's | |
67 // GPU cache. | |
68 static const size_t kMaxGaneshResourceCacheBytes = 96 * 1024 * 1024; | |
69 | |
70 gr_context_->setResourceCacheLimits(kMaxGaneshResourceCacheCount, | |
71 kMaxGaneshResourceCacheBytes); | |
vmiura
2015/04/02 19:12:34
I'm not sure it's OK to remove this initialization
sohanjg
2015/04/08 09:00:31
Acknowledged.
Added it back.
| |
72 } | |
73 } | 62 } |
74 | 63 |
75 GrContextForWebGraphicsContext3D::~GrContextForWebGraphicsContext3D() { | 64 GrContextForWebGraphicsContext3D::~GrContextForWebGraphicsContext3D() { |
76 } | 65 } |
77 | 66 |
78 void GrContextForWebGraphicsContext3D::OnLostContext() { | 67 void GrContextForWebGraphicsContext3D::OnLostContext() { |
79 if (gr_context_) | 68 if (gr_context_) |
80 gr_context_->abandonContext(); | 69 gr_context_->abandonContext(); |
81 } | 70 } |
82 | 71 |
83 void GrContextForWebGraphicsContext3D::FreeGpuResources() { | 72 void GrContextForWebGraphicsContext3D::FreeGpuResources() { |
84 if (gr_context_) { | 73 if (gr_context_) { |
85 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", \ | 74 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", \ |
86 TRACE_EVENT_SCOPE_THREAD); | 75 TRACE_EVENT_SCOPE_THREAD); |
87 gr_context_->freeGpuResources(); | 76 gr_context_->freeGpuResources(); |
88 } | 77 } |
89 } | 78 } |
90 | 79 |
91 } // namespace gpu | 80 } // namespace gpu |
92 } // namespace webkit | 81 } // namespace webkit |
OLD | NEW |