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

Unified Diff: content/browser/android/in_process/synchronous_compositor_factory_impl.cc

Issue 532993002: work-in-progress patch to fix context lost black video (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: block on compositor Created 6 years, 3 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
Index: content/browser/android/in_process/synchronous_compositor_factory_impl.cc
diff --git a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
index b736edb9078b028c6c016c74ff0173a2e969f56f..fbbb91026be0a6d00519a870c982693af0ef4257 100644
--- a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
+++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
@@ -4,6 +4,7 @@
#include "content/browser/android/in_process/synchronous_compositor_factory_impl.h"
+#include "base/observer_list.h"
#include "content/browser/android/in_process/synchronous_compositor_output_surface.h"
#include "content/public/browser/browser_thread.h"
#include "content/renderer/gpu/frame_swap_message_queue.h"
@@ -103,7 +104,9 @@ WrapContextWithAttributes(
context.Pass(), attributes));
}
-class VideoContextProvider
+} // namespace
+
+class SynchronousCompositorFactoryImpl::VideoContextProvider
: public StreamTextureFactorySynchronousImpl::ContextProvider {
public:
VideoContextProvider(
@@ -125,18 +128,32 @@ class VideoContextProvider
return context_provider_->ContextGL();
}
+ virtual void AddObserver(StreamTextureFactoryContextObserver* obs) OVERRIDE {
+ observer_list_.AddObserver(obs);
+ }
+
+ virtual void RemoveObserver(
+ StreamTextureFactoryContextObserver* obs) OVERRIDE {
+ observer_list_.RemoveObserver(obs);
+ }
+
+ void RestoreContext() {
+ FOR_EACH_OBSERVER(StreamTextureFactoryContextObserver,
+ observer_list_,
+ ResetStreamTextureProxy());
+ }
+
private:
friend class base::RefCountedThreadSafe<VideoContextProvider>;
virtual ~VideoContextProvider() {}
scoped_refptr<cc::ContextProvider> context_provider_;
gpu::GLInProcessContext* gl_in_process_context_;
+ ObserverList<StreamTextureFactoryContextObserver> observer_list_;
DISALLOW_COPY_AND_ASSIGN(VideoContextProvider);
};
-} // namespace
-
using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
SynchronousCompositorFactoryImpl::SynchronousCompositorFactoryImpl()
@@ -216,6 +233,13 @@ SynchronousCompositorFactoryImpl::CreateOffscreenGraphicsContext3D(
void SynchronousCompositorFactoryImpl::CompositorInitializedHardwareDraw() {
base::AutoLock lock(num_hardware_compositor_lock_);
num_hardware_compositors_++;
+ if (num_hardware_compositors_ == 1 && main_thread_proxy_) {
+ main_thread_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &SynchronousCompositorFactoryImpl::RestoreContextOnMainThread,
+ base::Unretained(this)));
+ }
}
void SynchronousCompositorFactoryImpl::CompositorReleasedHardwareDraw() {
@@ -224,6 +248,11 @@ void SynchronousCompositorFactoryImpl::CompositorReleasedHardwareDraw() {
num_hardware_compositors_--;
}
+void SynchronousCompositorFactoryImpl::RestoreContextOnMainThread() {
+ if (CanCreateMainThreadContext() && video_context_provider_ )
+ video_context_provider_->RestoreContext();
+}
+
bool SynchronousCompositorFactoryImpl::CanCreateMainThreadContext() {
base::AutoLock lock(num_hardware_compositor_lock_);
return num_hardware_compositors_ > 0;
@@ -231,6 +260,11 @@ bool SynchronousCompositorFactoryImpl::CanCreateMainThreadContext() {
scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>
SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory() {
+ {
+ base::AutoLock lock(num_hardware_compositor_lock_);
+ main_thread_proxy_ = base::MessageLoopProxy::current();
+ }
+
// Always fail creation even if |video_context_provider_| is not NULL.
// This is to avoid synchronous calls that may deadlock. Setting
// |video_context_provider_| to null is also not safe since it makes

Powered by Google App Engine
This is Rietveld 408576698