Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(797)

Unified Diff: webkit/common/gpu/context_provider_in_process.cc

Issue 20185002: ContextProvider in OutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: contextprovider: don't access Context3d() in OutputSurface contructors, it's not bound yet Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/common/gpu/context_provider_in_process.h ('k') | webkit/common/gpu/managed_memory_policy_convert.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/common/gpu/context_provider_in_process.cc
diff --git a/webkit/common/gpu/context_provider_in_process.cc b/webkit/common/gpu/context_provider_in_process.cc
index 1e42ab04d6bf2dfeae5aeb7d1056ef2b7b38bb44..9b4352fc0f0bb10ff3ee7c21f9ed43ade270433c 100644
--- a/webkit/common/gpu/context_provider_in_process.cc
+++ b/webkit/common/gpu/context_provider_in_process.cc
@@ -6,8 +6,9 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
+#include "cc/output/managed_memory_policy.h"
#include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h"
-#include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
+#include "webkit/common/gpu/managed_memory_policy_convert.h"
namespace webkit {
namespace gpu {
@@ -32,6 +33,27 @@ class ContextProviderInProcess::LostContextCallbackProxy
ContextProviderInProcess* provider_;
};
+class ContextProviderInProcess::SwapBuffersCompleteCallbackProxy
+ : public WebKit::WebGraphicsContext3D::
+ WebGraphicsSwapBuffersCompleteCallbackCHROMIUM {
+ public:
+ explicit SwapBuffersCompleteCallbackProxy(ContextProviderInProcess* provider)
+ : provider_(provider) {
+ provider_->context3d_->setSwapBuffersCompleteCallbackCHROMIUM(this);
+ }
+
+ virtual ~SwapBuffersCompleteCallbackProxy() {
+ provider_->context3d_->setSwapBuffersCompleteCallbackCHROMIUM(NULL);
+ }
+
+ virtual void onSwapBuffersComplete() {
+ provider_->OnSwapBuffersComplete();
+ }
+
+ private:
+ ContextProviderInProcess* provider_;
+};
+
class ContextProviderInProcess::MemoryAllocationCallbackProxy
: public WebKit::WebGraphicsContext3D::
WebGraphicsMemoryAllocationChangedCallbackCHROMIUM {
@@ -46,8 +68,8 @@ class ContextProviderInProcess::MemoryAllocationCallbackProxy
}
virtual void onMemoryAllocationChanged(
- WebKit::WebGraphicsMemoryAllocation alloc) {
- provider_->OnMemoryAllocationChanged(!!alloc.gpuResourceSizeInBytes);
+ WebKit::WebGraphicsMemoryAllocation allocation) {
+ provider_->OnMemoryAllocationChanged(allocation);
}
private:
@@ -117,10 +139,15 @@ bool ContextProviderInProcess::BindToCurrentThread() {
return false;
lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this));
+ swap_buffers_complete_callback_proxy_.reset(
+ new SwapBuffersCompleteCallbackProxy(this));
+ memory_allocation_callback_proxy_.reset(
+ new MemoryAllocationCallbackProxy(this));
return true;
}
-WebKit::WebGraphicsContext3D* ContextProviderInProcess::Context3d() {
+webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl*
+ContextProviderInProcess::Context3d() {
DCHECK(context3d_);
DCHECK(lost_context_callback_proxy_); // Is bound to thread.
DCHECK(context_thread_checker_.CalledOnValidThread());
@@ -138,8 +165,6 @@ class GrContext* ContextProviderInProcess::GrContext() {
gr_context_.reset(
new webkit::gpu::GrContextForWebGraphicsContext3D(context3d_.get()));
- memory_allocation_callback_proxy_.reset(
- new MemoryAllocationCallbackProxy(this));
return gr_context_->get();
}
@@ -164,6 +189,33 @@ void ContextProviderInProcess::OnLostContext() {
base::ResetAndReturn(&lost_context_callback_).Run();
}
+void ContextProviderInProcess::OnSwapBuffersComplete() {
+ DCHECK(context_thread_checker_.CalledOnValidThread());
+ if (!swap_buffers_complete_callback_.is_null())
+ swap_buffers_complete_callback_.Run();
+}
+
+void ContextProviderInProcess::OnMemoryAllocationChanged(
+ const WebKit::WebGraphicsMemoryAllocation& allocation) {
+ DCHECK(context_thread_checker_.CalledOnValidThread());
+
+ if (gr_context_) {
+ bool nonzero_allocation = !!allocation.gpuResourceSizeInBytes;
+ gr_context_->SetMemoryLimit(nonzero_allocation);
+ }
+
+ if (memory_policy_changed_callback_.is_null())
+ return;
+
+ bool discard_backbuffer_when_not_visible;
+ cc::ManagedMemoryPolicy policy =
+ ManagedMemoryPolicyConvert::Convert(allocation,
+ &discard_backbuffer_when_not_visible);
+
+ memory_policy_changed_callback_.Run(
+ policy, discard_backbuffer_when_not_visible);
+}
+
bool ContextProviderInProcess::DestroyedOnMainThread() {
DCHECK(main_thread_checker_.CalledOnValidThread());
@@ -174,15 +226,25 @@ bool ContextProviderInProcess::DestroyedOnMainThread() {
void ContextProviderInProcess::SetLostContextCallback(
const LostContextCallback& lost_context_callback) {
DCHECK(context_thread_checker_.CalledOnValidThread());
- DCHECK(lost_context_callback_.is_null());
+ DCHECK(lost_context_callback_.is_null() ||
+ lost_context_callback.is_null());
lost_context_callback_ = lost_context_callback;
}
-void ContextProviderInProcess::OnMemoryAllocationChanged(
- bool nonzero_allocation) {
+void ContextProviderInProcess::SetSwapBuffersCompleteCallback(
+ const SwapBuffersCompleteCallback& swap_buffers_complete_callback) {
DCHECK(context_thread_checker_.CalledOnValidThread());
- if (gr_context_)
- gr_context_->SetMemoryLimit(nonzero_allocation);
+ DCHECK(swap_buffers_complete_callback_.is_null() ||
+ swap_buffers_complete_callback.is_null());
+ swap_buffers_complete_callback_ = swap_buffers_complete_callback;
+}
+
+void ContextProviderInProcess::SetMemoryPolicyChangedCallback(
+ const MemoryPolicyChangedCallback& memory_policy_changed_callback) {
+ DCHECK(context_thread_checker_.CalledOnValidThread());
+ DCHECK(memory_policy_changed_callback_.is_null() ||
+ memory_policy_changed_callback.is_null());
+ memory_policy_changed_callback_ = memory_policy_changed_callback;
}
} // namespace gpu
« no previous file with comments | « webkit/common/gpu/context_provider_in_process.h ('k') | webkit/common/gpu/managed_memory_policy_convert.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698