diff options
author | tfarina <tfarina@chromium.org> | 2015-01-24 08:00:45 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-24 16:01:41 +0000 |
commit | bca2a0be0924009ef5f8dc0e299c0efbb95a4d67 (patch) | |
tree | bbd961cedbcf8255df1b98119bbd28ac39cd34da /ui/compositor/test/in_process_context_provider.h | |
parent | a95182ddbaa0e0e0a2504a0c4e0954f62cd9791c (diff) | |
download | chromium_src-bca2a0be0924009ef5f8dc0e299c0efbb95a4d67.zip chromium_src-bca2a0be0924009ef5f8dc0e299c0efbb95a4d67.tar.gz chromium_src-bca2a0be0924009ef5f8dc0e299c0efbb95a4d67.tar.bz2 |
ui/compositor: Provide its own 'in process' ContextProvider.
InProcessContextProvider is twin brother of the ContextProviderInProcess
from webkit/common/gpu. We built one here specifically for compositor
in order to remove the dependency on webkit/.
We did that for some reasons: one is that webkit/ abstraction glue is going
away, the second is that compositor can't depend on content, and thus we
couldn't simply move the code into content and make compositor use it.
BUG=338338
TEST=compositor_unittests
R=piman@chromium.org
TBR=reed@google.com (for skia/ext deps addition)
Review URL: https://codereview.chromium.org/853353003
Cr-Commit-Position: refs/heads/master@{#313022}
Diffstat (limited to 'ui/compositor/test/in_process_context_provider.h')
-rw-r--r-- | ui/compositor/test/in_process_context_provider.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/ui/compositor/test/in_process_context_provider.h b/ui/compositor/test/in_process_context_provider.h new file mode 100644 index 0000000..4b63ed4 --- /dev/null +++ b/ui/compositor/test/in_process_context_provider.h @@ -0,0 +1,85 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ +#define WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ + +#include <string> + +#include "base/macros.h" +#include "base/memory/scoped_ptr.h" +#include "base/synchronization/lock.h" +#include "base/threading/thread_checker.h" +#include "cc/output/context_provider.h" +#include "gpu/command_buffer/common/gles2_cmd_utils.h" +#include "skia/ext/refptr.h" +#include "ui/gfx/native_widget_types.h" + +namespace gpu { +class GLInProcessContext; +} + +namespace ui { + +class InProcessContextProvider : public cc::ContextProvider { + public: + static scoped_refptr<InProcessContextProvider> Create( + const gpu::gles2::ContextCreationAttribHelper& attribs, + bool lose_context_when_out_of_memory, + gfx::AcceleratedWidget window, + const std::string& debug_name); + + // Uses default attributes for creating an offscreen context. + static scoped_refptr<InProcessContextProvider> CreateOffscreen( + bool lose_context_when_out_of_memory); + + private: + InProcessContextProvider( + const gpu::gles2::ContextCreationAttribHelper& attribs, + bool lose_context_when_out_of_memory, + gfx::AcceleratedWidget window, + const std::string& debug_name); + ~InProcessContextProvider() override; + + // cc::ContextProvider: + bool BindToCurrentThread() override; + Capabilities ContextCapabilities() override; + gpu::gles2::GLES2Interface* ContextGL() override; + gpu::ContextSupport* ContextSupport() override; + class GrContext* GrContext() override; + bool IsContextLost() override; + void VerifyContexts() override; + void DeleteCachedResources() override; + bool DestroyedOnMainThread() override; + void SetLostContextCallback( + const LostContextCallback& lost_context_callback) override; + void SetMemoryPolicyChangedCallback( + const MemoryPolicyChangedCallback& memory_policy_changed_callback) + override; + + void OnLostContext(); + + base::ThreadChecker main_thread_checker_; + base::ThreadChecker context_thread_checker_; + + scoped_ptr<gpu::GLInProcessContext> context_; + skia::RefPtr<class GrContext> gr_context_; + + gpu::gles2::ContextCreationAttribHelper attribs_; + bool lose_context_when_out_of_memory_; + gfx::AcceleratedWidget window_; + std::string debug_name_; + cc::ContextProvider::Capabilities capabilities_; + + LostContextCallback lost_context_callback_; + + base::Lock destroyed_lock_; + bool destroyed_; + + DISALLOW_COPY_AND_ASSIGN(InProcessContextProvider); +}; + +} // namespace ui + +#endif // WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ |