| Index: content/renderer/android/synchronous_compositor_output_surface.cc
|
| diff --git a/content/renderer/android/synchronous_compositor_output_surface.cc b/content/renderer/android/synchronous_compositor_output_surface.cc
|
| index 87792ea0de59ec588c417e9f71563f15177dcc70..c1f183639470ac7fab554d6a25b401ee5b9f9012 100644
|
| --- a/content/renderer/android/synchronous_compositor_output_surface.cc
|
| +++ b/content/renderer/android/synchronous_compositor_output_surface.cc
|
| @@ -5,23 +5,41 @@
|
| #include "content/renderer/android/synchronous_compositor_output_surface.h"
|
|
|
| #include "base/logging.h"
|
| +#include "base/time.h"
|
| #include "cc/output/output_surface_client.h"
|
| -#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.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/SkPicture.h"
|
| +#include "ui/gfx/transform.h"
|
| +#include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
|
| +
|
| +using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
|
|
|
| namespace content {
|
| +namespace {
|
| +
|
| +// TODO(boliu): RenderThreadImpl should create in process contexts as well.
|
| +scoped_ptr<WebKit::WebGraphicsContext3D> CreateWebGraphicsContext3D() {
|
| + WebKit::WebGraphicsContext3D::Attributes attributes;
|
| + attributes.antialias = false;
|
| + attributes.shareResources = true;
|
| + attributes.noAutomaticFlushes = true;
|
| +
|
| + return scoped_ptr<WebKit::WebGraphicsContext3D>(
|
| + WebGraphicsContext3DInProcessCommandBufferImpl
|
| + ::CreateViewContext(attributes, NULL));
|
| +}
|
| +} // namespace
|
|
|
| SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface(
|
| - int32 routing_id,
|
| - WebGraphicsContext3DCommandBufferImpl* context)
|
| - : cc::OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>(context)),
|
| + int32 routing_id)
|
| + : cc::OutputSurface(CreateWebGraphicsContext3D()),
|
| compositor_client_(NULL),
|
| - routing_id_(routing_id) {
|
| - // WARNING: may be called on any thread.
|
| + routing_id_(routing_id),
|
| + vsync_enabled_(false),
|
| + did_swap_buffer_(false) {
|
| }
|
|
|
| SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {
|
| @@ -40,15 +58,33 @@ bool SynchronousCompositorOutputSurface::BindToClient(
|
| return true;
|
| }
|
|
|
| +void SynchronousCompositorOutputSurface::Reshape(gfx::Size size) {
|
| + // Intentional no-op.
|
| +}
|
| +
|
| void SynchronousCompositorOutputSurface::SendFrameToParentCompositor(
|
| cc::CompositorFrame* frame) {
|
| // Intentional no-op: see http://crbug.com/237006
|
| }
|
|
|
| +void SynchronousCompositorOutputSurface::EnableVSyncNotification(
|
| + bool enable_vsync) {
|
| + DCHECK(CalledOnValidThread());
|
| + vsync_enabled_ = enable_vsync;
|
| + UpdateCompositorClientSettings();
|
| +}
|
| +
|
| +void SynchronousCompositorOutputSurface::SwapBuffers(
|
| + const cc::LatencyInfo& info) {
|
| + context3d()->finish();
|
| + did_swap_buffer_ = true;
|
| +}
|
| +
|
| void SynchronousCompositorOutputSurface::SetClient(
|
| SynchronousCompositorClient* compositor_client) {
|
| DCHECK(CalledOnValidThread());
|
| compositor_client_ = compositor_client;
|
| + UpdateCompositorClientSettings();
|
| }
|
|
|
| bool SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) {
|
| @@ -57,6 +93,30 @@ bool SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) {
|
| return false;
|
| }
|
|
|
| +bool SynchronousCompositorOutputSurface::DemandDrawHw(
|
| + gfx::Size view_size,
|
| + const gfx::Transform& transform,
|
| + gfx::Rect damage_area) {
|
| + DCHECK(CalledOnValidThread());
|
| + DCHECK(client_);
|
| +
|
| + did_swap_buffer_ = false;
|
| +
|
| + // TODO(boliu): This assumes |transform| is identity and |damage_area| is the
|
| + // whole view. Tracking bug to implement this: crbug.com/230463.
|
| + client_->SetNeedsRedrawRect(damage_area);
|
| + if (vsync_enabled_)
|
| + client_->DidVSync(base::TimeTicks::Now());
|
| +
|
| + return did_swap_buffer_;
|
| +}
|
| +
|
| +void SynchronousCompositorOutputSurface::UpdateCompositorClientSettings() {
|
| + if (compositor_client_) {
|
| + compositor_client_->SetContinuousInvalidate(vsync_enabled_);
|
| + }
|
| +}
|
| +
|
| // 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
|
|
|