Index: cc/test/test_context_provider.cc |
diff --git a/cc/test/test_context_provider.cc b/cc/test/test_context_provider.cc |
index 2634aff5cb567bf4757caefef8c23a8219b7f07a..be27b19a8d8e19c2ce373e2e68c8d92468543740 100644 |
--- a/cc/test/test_context_provider.cc |
+++ b/cc/test/test_context_provider.cc |
@@ -14,6 +14,7 @@ |
#include "base/callback_helpers.h" |
#include "base/logging.h" |
#include "base/memory/ptr_util.h" |
+#include "cc/output/context_cache_controller.h" |
#include "cc/test/test_gles2_interface.h" |
#include "cc/test/test_web_graphics_context_3d.h" |
#include "third_party/skia/include/gpu/GrContext.h" |
@@ -23,17 +24,23 @@ namespace cc { |
// static |
scoped_refptr<TestContextProvider> TestContextProvider::Create() { |
- return new TestContextProvider(base::MakeUnique<TestContextSupport>(), |
- base::MakeUnique<TestGLES2Interface>(), |
- TestWebGraphicsContext3D::Create()); |
+ auto support = base::MakeUnique<TestContextSupport>(); |
+ auto cache_controller = |
+ base::MakeUnique<ContextCacheController>(support.get()); |
+ return new TestContextProvider( |
+ std::move(support), base::MakeUnique<TestGLES2Interface>(), |
+ TestWebGraphicsContext3D::Create(), std::move(cache_controller)); |
} |
// static |
scoped_refptr<TestContextProvider> TestContextProvider::CreateWorker() { |
+ auto support = base::MakeUnique<TestContextSupport>(); |
+ auto cache_controller = |
+ base::MakeUnique<ContextCacheController>(support.get()); |
scoped_refptr<TestContextProvider> worker_context_provider( |
- new TestContextProvider(base::MakeUnique<TestContextSupport>(), |
- base::MakeUnique<TestGLES2Interface>(), |
- TestWebGraphicsContext3D::Create())); |
+ new TestContextProvider( |
+ std::move(support), base::MakeUnique<TestGLES2Interface>(), |
+ TestWebGraphicsContext3D::Create(), std::move(cache_controller))); |
// Worker contexts are bound to the thread they are created on. |
if (!worker_context_provider->BindToCurrentThread()) |
return nullptr; |
@@ -44,18 +51,24 @@ scoped_refptr<TestContextProvider> TestContextProvider::CreateWorker() { |
scoped_refptr<TestContextProvider> TestContextProvider::Create( |
std::unique_ptr<TestWebGraphicsContext3D> context) { |
DCHECK(context); |
- return new TestContextProvider(base::MakeUnique<TestContextSupport>(), |
- base::MakeUnique<TestGLES2Interface>(), |
- std::move(context)); |
+ auto support = base::MakeUnique<TestContextSupport>(); |
+ auto cache_controller = |
+ base::MakeUnique<ContextCacheController>(support.get()); |
+ return new TestContextProvider( |
+ std::move(support), base::MakeUnique<TestGLES2Interface>(), |
+ std::move(context), std::move(cache_controller)); |
} |
// static |
scoped_refptr<TestContextProvider> TestContextProvider::Create( |
std::unique_ptr<TestGLES2Interface> gl) { |
DCHECK(gl); |
- return new TestContextProvider(base::MakeUnique<TestContextSupport>(), |
- std::move(gl), |
- TestWebGraphicsContext3D::Create()); |
+ auto support = base::MakeUnique<TestContextSupport>(); |
+ auto cache_controller = |
+ base::MakeUnique<ContextCacheController>(support.get()); |
+ return new TestContextProvider(std::move(support), std::move(gl), |
+ TestWebGraphicsContext3D::Create(), |
+ std::move(cache_controller)); |
} |
// static |
@@ -64,18 +77,35 @@ scoped_refptr<TestContextProvider> TestContextProvider::Create( |
std::unique_ptr<TestContextSupport> support) { |
DCHECK(context); |
DCHECK(support); |
- return new TestContextProvider(std::move(support), |
- base::MakeUnique<TestGLES2Interface>(), |
- std::move(context)); |
+ auto cache_controller = |
+ base::MakeUnique<ContextCacheController>(support.get()); |
+ return new TestContextProvider( |
+ std::move(support), base::MakeUnique<TestGLES2Interface>(), |
+ std::move(context), std::move(cache_controller)); |
+} |
+ |
+// static |
+scoped_refptr<TestContextProvider> TestContextProvider::Create( |
+ std::unique_ptr<TestWebGraphicsContext3D> context, |
+ std::unique_ptr<TestContextSupport> support, |
+ std::unique_ptr<ContextCacheController> cache_controller) { |
+ DCHECK(context); |
+ DCHECK(support); |
+ DCHECK(cache_controller); |
+ return new TestContextProvider( |
+ std::move(support), base::MakeUnique<TestGLES2Interface>(), |
+ std::move(context), std::move(cache_controller)); |
} |
TestContextProvider::TestContextProvider( |
std::unique_ptr<TestContextSupport> support, |
std::unique_ptr<TestGLES2Interface> gl, |
- std::unique_ptr<TestWebGraphicsContext3D> context) |
+ std::unique_ptr<TestWebGraphicsContext3D> context, |
+ std::unique_ptr<ContextCacheController> cache_controller) |
: support_(std::move(support)), |
context3d_(std::move(context)), |
context_gl_(std::move(gl)), |
+ cache_controller_(std::move(cache_controller)), |
weak_ptr_factory_(this) { |
DCHECK(main_thread_checker_.CalledOnValidThread()); |
DCHECK(context3d_); |
@@ -143,6 +173,8 @@ class GrContext* TestContextProvider::GrContext() { |
kOpenGL_GrBackend, |
reinterpret_cast<GrBackendContext>(gl_interface.get()))); |
+ cache_controller_->SetGrContext(gr_context_.get()); |
+ |
// If GlContext is already lost, also abandon the new GrContext. |
if (ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR) |
gr_context_->abandonContext(); |
@@ -150,6 +182,11 @@ class GrContext* TestContextProvider::GrContext() { |
return gr_context_.get(); |
} |
+ContextCacheController* TestContextProvider::CacheController() { |
+ DCHECK(context_thread_checker_.CalledOnValidThread()); |
+ return cache_controller_.get(); |
+} |
+ |
void TestContextProvider::InvalidateGrContext(uint32_t state) { |
DCHECK(bound_); |
DCHECK(context_thread_checker_.CalledOnValidThread()); |
@@ -162,9 +199,6 @@ base::Lock* TestContextProvider::GetLock() { |
return &context_lock_; |
} |
-void TestContextProvider::DeleteCachedResources() { |
-} |
- |
void TestContextProvider::OnLostContext() { |
DCHECK(context_thread_checker_.CalledOnValidThread()); |
if (!lost_context_callback_.is_null()) |