| 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 "gpu/skia_bindings/grcontext_for_gles2_interface.h" | 5 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "gpu/command_buffer/client/gles2_interface.h" | 15 #include "gpu/command_buffer/client/gles2_interface.h" |
| 16 #include "gpu/command_buffer/common/capabilities.h" |
| 16 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" | 17 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" |
| 17 #include "third_party/skia/include/gpu/GrContext.h" | 18 #include "third_party/skia/include/gpu/GrContext.h" |
| 18 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | 19 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
| 19 | 20 |
| 20 namespace skia_bindings { | 21 namespace skia_bindings { |
| 21 | 22 |
| 22 GrContextForGLES2Interface::GrContextForGLES2Interface( | 23 GrContextForGLES2Interface::GrContextForGLES2Interface( |
| 23 gpu::gles2::GLES2Interface* gl) { | 24 gpu::gles2::GLES2Interface* gl, |
| 25 const gpu::Capabilities& capabilities) { |
| 26 GrContextOptions options; |
| 27 options.fAvoidStencilBuffers = capabilities.avoid_stencil_buffers; |
| 24 sk_sp<GrGLInterface> interface( | 28 sk_sp<GrGLInterface> interface( |
| 25 skia_bindings::CreateGLES2InterfaceBindings(gl)); | 29 skia_bindings::CreateGLES2InterfaceBindings(gl)); |
| 26 gr_context_ = sk_sp<GrContext>( | 30 gr_context_ = sk_sp<GrContext>(GrContext::Create( |
| 27 GrContext::Create(kOpenGL_GrBackend, | 31 kOpenGL_GrBackend, |
| 28 // GrContext takes ownership of |interface|. | 32 // GrContext takes ownership of |interface|. |
| 29 reinterpret_cast<GrBackendContext>(interface.get()))); | 33 reinterpret_cast<GrBackendContext>(interface.get()), options)); |
| 30 if (gr_context_) { | 34 if (gr_context_) { |
| 31 // The limit of the number of GPU resources we hold in the GrContext's | 35 // The limit of the number of GPU resources we hold in the GrContext's |
| 32 // GPU cache. | 36 // GPU cache. |
| 33 static const int kMaxGaneshResourceCacheCount = 16384; | 37 static const int kMaxGaneshResourceCacheCount = 16384; |
| 34 // The limit of the bytes allocated toward GPU resources in the GrContext's | 38 // The limit of the bytes allocated toward GPU resources in the GrContext's |
| 35 // GPU cache. | 39 // GPU cache. |
| 36 static const size_t kMaxLowEndGaneshResourceCacheBytes = 48 * 1024 * 1024; | 40 static const size_t kMaxLowEndGaneshResourceCacheBytes = 48 * 1024 * 1024; |
| 37 static const size_t kMaxGaneshResourceCacheBytes = 96 * 1024 * 1024; | 41 static const size_t kMaxGaneshResourceCacheBytes = 96 * 1024 * 1024; |
| 38 static const size_t kMaxHighEndGaneshResourceCacheBytes = 256 * 1024 * 1024; | 42 static const size_t kMaxHighEndGaneshResourceCacheBytes = 256 * 1024 * 1024; |
| 39 static const int64_t kHighEndMemoryThreshold = (int64_t)4096 * 1024 * 1024; | 43 static const int64_t kHighEndMemoryThreshold = (int64_t)4096 * 1024 * 1024; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 75 |
| 72 void GrContextForGLES2Interface::FreeGpuResources() { | 76 void GrContextForGLES2Interface::FreeGpuResources() { |
| 73 if (gr_context_) { | 77 if (gr_context_) { |
| 74 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", | 78 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", |
| 75 TRACE_EVENT_SCOPE_THREAD); | 79 TRACE_EVENT_SCOPE_THREAD); |
| 76 gr_context_->freeGpuResources(); | 80 gr_context_->freeGpuResources(); |
| 77 } | 81 } |
| 78 } | 82 } |
| 79 | 83 |
| 80 } // namespace skia_bindings | 84 } // namespace skia_bindings |
| OLD | NEW |