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" |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 bool nonzero_allocation = true; | 41 bool nonzero_allocation = true; |
42 SetMemoryLimit(nonzero_allocation); | 42 SetMemoryLimit(nonzero_allocation); |
43 } | 43 } |
44 | 44 |
45 GrContextForWebGraphicsContext3D::~GrContextForWebGraphicsContext3D() { | 45 GrContextForWebGraphicsContext3D::~GrContextForWebGraphicsContext3D() { |
46 } | 46 } |
47 | 47 |
48 void GrContextForWebGraphicsContext3D::OnLostContext() { | 48 void GrContextForWebGraphicsContext3D::OnLostContext() { |
49 if (gr_context_) | 49 if (gr_context_) |
50 gr_context_->contextLost(); | 50 gr_context_->contextDestroyed(); |
51 } | 51 } |
52 | 52 |
53 void GrContextForWebGraphicsContext3D::SetMemoryLimit(bool nonzero_allocation) { | 53 void GrContextForWebGraphicsContext3D::SetMemoryLimit(bool nonzero_allocation) { |
54 if (!gr_context_) | 54 if (!gr_context_) |
55 return; | 55 return; |
56 | 56 |
57 if (nonzero_allocation) { | 57 if (nonzero_allocation) { |
58 // The limit of the number of textures we hold in the GrContext's | 58 // The limit of the number of textures we hold in the GrContext's |
59 // bitmap->texture cache. | 59 // bitmap->texture cache. |
60 static const int kMaxGaneshTextureCacheCount = 2048; | 60 static const int kMaxGaneshTextureCacheCount = 2048; |
61 // The limit of the bytes allocated toward textures in the GrContext's | 61 // The limit of the bytes allocated toward textures in the GrContext's |
62 // bitmap->texture cache. | 62 // bitmap->texture cache. |
63 static const size_t kMaxGaneshTextureCacheBytes = 96 * 1024 * 1024; | 63 static const size_t kMaxGaneshTextureCacheBytes = 96 * 1024 * 1024; |
64 | 64 |
65 gr_context_->setTextureCacheLimits( | 65 gr_context_->setTextureCacheLimits( |
66 kMaxGaneshTextureCacheCount, kMaxGaneshTextureCacheBytes); | 66 kMaxGaneshTextureCacheCount, kMaxGaneshTextureCacheBytes); |
67 } else { | 67 } else { |
68 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", \ | 68 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", \ |
69 TRACE_EVENT_SCOPE_THREAD); | 69 TRACE_EVENT_SCOPE_THREAD); |
70 gr_context_->freeGpuResources(); | 70 gr_context_->freeGpuResources(); |
71 gr_context_->setTextureCacheLimits(0, 0); | 71 gr_context_->setTextureCacheLimits(0, 0); |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 } // namespace gpu | 75 } // namespace gpu |
76 } // namespace webkit | 76 } // namespace webkit |
OLD | NEW |