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

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

Issue 16119003: Move SynchronousCompositor into content/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment, check Created 7 years, 7 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_output_surface.cc
diff --git a/content/renderer/android/synchronous_compositor_output_surface.cc b/content/browser/android/in_process/synchronous_compositor_output_surface.cc
similarity index 82%
rename from content/renderer/android/synchronous_compositor_output_surface.cc
rename to content/browser/android/in_process/synchronous_compositor_output_surface.cc
index 8b06c1fce65a619f37916df42381373dbf3908e5..6b6ab4638cd6424b9f52209d88513397f92d07cc 100644
--- a/content/renderer/android/synchronous_compositor_output_surface.cc
+++ b/content/browser/android/in_process/synchronous_compositor_output_surface.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/renderer/android/synchronous_compositor_output_surface.h"
+#include "content/browser/android/in_process/synchronous_compositor_output_surface.h"
#include "base/command_line.h"
#include "base/logging.h"
@@ -11,10 +11,11 @@
#include "cc/output/compositor_frame_ack.h"
#include "cc/output/output_surface_client.h"
#include "cc/output/software_output_device.h"
+#include "content/browser/android/in_process/synchronous_compositor_impl.h"
#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_switches.h"
#include "content/public/renderer/android/synchronous_compositor_client.h"
-#include "content/public/renderer/content_renderer_client.h"
#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkDevice.h"
@@ -87,22 +88,24 @@ class SynchronousCompositorOutputSurface::SoftwareDevice
};
SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface(
- int32 routing_id)
- : cc::OutputSurface(CreateWebGraphicsContext3D(),
- scoped_ptr<cc::SoftwareOutputDevice>(
- new SoftwareDevice(this))),
- compositor_client_(NULL),
+ int routing_id)
+ : cc::OutputSurface(
+ CreateWebGraphicsContext3D(),
+ scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))),
routing_id_(routing_id),
needs_begin_frame_(false),
did_swap_buffer_(false),
current_sw_canvas_(NULL) {
capabilities_.deferred_gl_initialization = true;
+ // Cannot call out to GetDelegate() here as the output surface is not
+ // constructed on the correct thread.
}
SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {
DCHECK(CalledOnValidThread());
- if (compositor_client_)
- compositor_client_->DidDestroyCompositor(this);
+ SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate();
+ if (delegate)
+ delegate->DidDestroySynchronousOutputSurface(this);
}
bool SynchronousCompositorOutputSurface::ForcedDrawToSoftwareDevice() const {
@@ -114,8 +117,9 @@ bool SynchronousCompositorOutputSurface::BindToClient(
DCHECK(CalledOnValidThread());
if (!cc::OutputSurface::BindToClient(surface_client))
return false;
- GetContentClient()->renderer()->DidCreateSynchronousCompositor(routing_id_,
- this);
+ SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate();
+ if (delegate)
+ delegate->DidBindOutputSurface(this);
return true;
}
@@ -134,7 +138,9 @@ void SynchronousCompositorOutputSurface::SetNeedsBeginFrame(
bool enable) {
DCHECK(CalledOnValidThread());
needs_begin_frame_ = enable;
- UpdateCompositorClientSettings();
+ SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate();
+ if (delegate)
+ delegate->SetContinuousInvalidate(needs_begin_frame_);
}
void SynchronousCompositorOutputSurface::SwapBuffers(
@@ -143,13 +149,6 @@ void SynchronousCompositorOutputSurface::SwapBuffers(
did_swap_buffer_ = true;
}
-void SynchronousCompositorOutputSurface::SetClient(
- SynchronousCompositorClient* compositor_client) {
- DCHECK(CalledOnValidThread());
- compositor_client_ = compositor_client;
- UpdateCompositorClientSettings();
-}
-
bool SynchronousCompositorOutputSurface::IsHwReady() {
return context3d() != NULL;
}
@@ -202,19 +201,16 @@ void SynchronousCompositorOutputSurface::InvokeComposite(
client_->BeginFrame(base::TimeTicks::Now());
}
-void SynchronousCompositorOutputSurface::UpdateCompositorClientSettings() {
- if (compositor_client_) {
- compositor_client_->SetContinuousInvalidate(needs_begin_frame_);
- }
-}
-
// Not using base::NonThreadSafe as we want to enforce a more exacting threading
-// requirement: SynchronousCompositorOutputSurface() must only be used by
-// embedders that supply their own compositor loop via
-// OverrideCompositorMessageLoop().
+// requirement: SynchronousCompositorOutputSurface() must only be used on the UI
+// thread.
bool SynchronousCompositorOutputSurface::CalledOnValidThread() const {
- return base::MessageLoop::current() && (base::MessageLoop::current() ==
- GetContentClient()->renderer()->OverrideCompositorMessageLoop());
+ return BrowserThread::CurrentlyOn(BrowserThread::UI);
+}
+
+SynchronousCompositorOutputSurfaceDelegate*
+SynchronousCompositorOutputSurface::GetDelegate() {
+ return SynchronousCompositorImpl::FromRoutingID(routing_id_);
}
} // namespace content
« no previous file with comments | « content/browser/android/in_process/synchronous_compositor_output_surface.h ('k') | content/browser/browser_main_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698