| 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 25 matching lines...) Expand all Loading... |
| 36 kOpenGL_GrBackend, | 36 kOpenGL_GrBackend, |
| 37 reinterpret_cast<GrBackendContext>(interface.get()))); | 37 reinterpret_cast<GrBackendContext>(interface.get()))); |
| 38 if (!gr_context_) | 38 if (!gr_context_) |
| 39 return; | 39 return; |
| 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 } |
| 47 |
| 48 void GrContextForWebGraphicsContext3D::OnLostContext() { |
| 46 if (gr_context_) | 49 if (gr_context_) |
| 47 gr_context_->contextDestroyed(); | 50 gr_context_->contextLost(); |
| 48 } | 51 } |
| 49 | 52 |
| 50 void GrContextForWebGraphicsContext3D::SetMemoryLimit(bool nonzero_allocation) { | 53 void GrContextForWebGraphicsContext3D::SetMemoryLimit(bool nonzero_allocation) { |
| 51 if (!gr_context_) | 54 if (!gr_context_) |
| 52 return; | 55 return; |
| 53 | 56 |
| 54 if (nonzero_allocation) { | 57 if (nonzero_allocation) { |
| 55 // 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 |
| 56 // bitmap->texture cache. | 59 // bitmap->texture cache. |
| 57 static const int kMaxGaneshTextureCacheCount = 2048; | 60 static const int kMaxGaneshTextureCacheCount = 2048; |
| 58 // 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 |
| 59 // bitmap->texture cache. | 62 // bitmap->texture cache. |
| 60 static const size_t kMaxGaneshTextureCacheBytes = 96 * 1024 * 1024; | 63 static const size_t kMaxGaneshTextureCacheBytes = 96 * 1024 * 1024; |
| 61 | 64 |
| 62 gr_context_->setTextureCacheLimits( | 65 gr_context_->setTextureCacheLimits( |
| 63 kMaxGaneshTextureCacheCount, kMaxGaneshTextureCacheBytes); | 66 kMaxGaneshTextureCacheCount, kMaxGaneshTextureCacheBytes); |
| 64 } else { | 67 } else { |
| 65 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", \ | 68 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", \ |
| 66 TRACE_EVENT_SCOPE_THREAD); | 69 TRACE_EVENT_SCOPE_THREAD); |
| 67 gr_context_->freeGpuResources(); | 70 gr_context_->freeGpuResources(); |
| 68 gr_context_->setTextureCacheLimits(0, 0); | 71 gr_context_->setTextureCacheLimits(0, 0); |
| 69 } | 72 } |
| 70 } | 73 } |
| 71 | 74 |
| 72 } // namespace gpu | 75 } // namespace gpu |
| 73 } // namespace webkit | 76 } // namespace webkit |
| OLD | NEW |