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 "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "gpu/command_buffer/client/gles2_lib.h" | 9 #include "gpu/command_buffer/client/gles2_lib.h" |
10 #include "third_party/skia/include/gpu/GrContext.h" | 10 #include "third_party/skia/include/gpu/GrContext.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 return; | 51 return; |
52 | 52 |
53 interface->fCallback = BindWebGraphicsContext3DGLContextCallback; | 53 interface->fCallback = BindWebGraphicsContext3DGLContextCallback; |
54 interface->fCallbackData = | 54 interface->fCallbackData = |
55 reinterpret_cast<GrGLInterfaceCallbackData>(context3d); | 55 reinterpret_cast<GrGLInterfaceCallbackData>(context3d); |
56 | 56 |
57 gr_context_ = skia::AdoptRef(GrContext::Create( | 57 gr_context_ = skia::AdoptRef(GrContext::Create( |
58 kOpenGL_GrBackend, | 58 kOpenGL_GrBackend, |
59 reinterpret_cast<GrBackendContext>(interface.get()))); | 59 reinterpret_cast<GrBackendContext>(interface.get()))); |
60 if (gr_context_) { | 60 if (gr_context_) { |
61 // The limit of the number of textures we hold in the GrContext's | 61 // The limit of the number of GPU resources we hold in the GrContext's |
62 // bitmap->texture cache. | 62 // GPU cache. |
63 static const int kMaxGaneshTextureCacheCount = 2048; | 63 static const int kMaxGaneshResourceCacheCount = 2048; |
64 // The limit of the bytes allocated toward textures in the GrContext's | 64 // The limit of the bytes allocated toward GPU resources in the GrContext's |
65 // bitmap->texture cache. | 65 // GPU cache. |
66 static const size_t kMaxGaneshTextureCacheBytes = 96 * 1024 * 1024; | 66 static const size_t kMaxGaneshResourceCacheBytes = 96 * 1024 * 1024; |
67 | 67 |
68 gr_context_->setTextureCacheLimits(kMaxGaneshTextureCacheCount, | 68 gr_context_->setResourceCacheLimits(kMaxGaneshResourceCacheCount, |
69 kMaxGaneshTextureCacheBytes); | 69 kMaxGaneshResourceCacheBytes); |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 GrContextForWebGraphicsContext3D::~GrContextForWebGraphicsContext3D() { | 73 GrContextForWebGraphicsContext3D::~GrContextForWebGraphicsContext3D() { |
74 } | 74 } |
75 | 75 |
76 void GrContextForWebGraphicsContext3D::OnLostContext() { | 76 void GrContextForWebGraphicsContext3D::OnLostContext() { |
77 if (gr_context_) | 77 if (gr_context_) |
78 gr_context_->contextDestroyed(); | 78 gr_context_->abandonContext(); |
79 } | 79 } |
80 | 80 |
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 |
OLD | NEW |