| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "android_webview/browser/aw_render_thread_context_provider.h" | 5 #include "android_webview/browser/aw_render_thread_context_provider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // This context is only used for the display compositor, and there are no | 56 // This context is only used for the display compositor, and there are no |
| 57 // uploads done with it at all. We choose a small transfer buffer limit | 57 // uploads done with it at all. We choose a small transfer buffer limit |
| 58 // here, the minimums match the display compositor context for the android | 58 // here, the minimums match the display compositor context for the android |
| 59 // browser. We don't set the max since we expect the transfer buffer to be | 59 // browser. We don't set the max since we expect the transfer buffer to be |
| 60 // relatively unused. | 60 // relatively unused. |
| 61 limits.start_transfer_buffer_size = 64 * 1024; | 61 limits.start_transfer_buffer_size = 64 * 1024; |
| 62 limits.min_transfer_buffer_size = 64 * 1024; | 62 limits.min_transfer_buffer_size = 64 * 1024; |
| 63 | 63 |
| 64 context_.reset(gpu::GLInProcessContext::Create( | 64 context_.reset(gpu::GLInProcessContext::Create( |
| 65 service, surface, surface->IsOffscreen(), gfx::kNullAcceleratedWidget, | 65 service, surface, surface->IsOffscreen(), gfx::kNullAcceleratedWidget, |
| 66 nullptr /* share_context */, attributes, limits, nullptr, nullptr)); | 66 nullptr /* share_context */, attributes, limits, nullptr, nullptr, |
| 67 nullptr)); |
| 67 | 68 |
| 68 context_->GetImplementation()->SetLostContextCallback(base::Bind( | 69 context_->GetImplementation()->SetLostContextCallback(base::Bind( |
| 69 &AwRenderThreadContextProvider::OnLostContext, base::Unretained(this))); | 70 &AwRenderThreadContextProvider::OnLostContext, base::Unretained(this))); |
| 70 | 71 |
| 71 cache_controller_.reset( | 72 cache_controller_.reset( |
| 72 new cc::ContextCacheController(context_->GetImplementation())); | 73 new cc::ContextCacheController(context_->GetImplementation(), nullptr)); |
| 73 } | 74 } |
| 74 | 75 |
| 75 AwRenderThreadContextProvider::~AwRenderThreadContextProvider() { | 76 AwRenderThreadContextProvider::~AwRenderThreadContextProvider() { |
| 76 DCHECK(main_thread_checker_.CalledOnValidThread()); | 77 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 77 if (gr_context_) | 78 if (gr_context_) |
| 78 gr_context_->releaseResourcesAndAbandonContext(); | 79 gr_context_->releaseResourcesAndAbandonContext(); |
| 79 } | 80 } |
| 80 | 81 |
| 81 uint32_t AwRenderThreadContextProvider::GetCopyTextureInternalFormat() { | 82 uint32_t AwRenderThreadContextProvider::GetCopyTextureInternalFormat() { |
| 82 // The attributes used in the constructor included an alpha channel. | 83 // The attributes used in the constructor included an alpha channel. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 void AwRenderThreadContextProvider::OnLostContext() { | 149 void AwRenderThreadContextProvider::OnLostContext() { |
| 149 DCHECK(main_thread_checker_.CalledOnValidThread()); | 150 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 150 | 151 |
| 151 if (!lost_context_callback_.is_null()) | 152 if (!lost_context_callback_.is_null()) |
| 152 lost_context_callback_.Run(); | 153 lost_context_callback_.Run(); |
| 153 if (gr_context_) | 154 if (gr_context_) |
| 154 gr_context_->abandonContext(); | 155 gr_context_->abandonContext(); |
| 155 } | 156 } |
| 156 | 157 |
| 157 } // namespace android_webview | 158 } // namespace android_webview |
| OLD | NEW |