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

Unified Diff: content/renderer/android/synchronous_compositor_output_surface.cc

Issue 14888002: Android WebView Merged-Thread Hardware Draw (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments 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
« no previous file with comments | « content/renderer/android/synchronous_compositor_output_surface.h ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
no sievers 2013/05/15 23:02:22 Bo, you might want to try if it works replacing th
+ 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
« no previous file with comments | « content/renderer/android/synchronous_compositor_output_surface.h ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698