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

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

Issue 16613002: Hook up android webview synchronous compositor GL init (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: why is gcc so tolerant of errors?! Created 7 years, 6 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/browser/android/in_process/synchronous_compositor_output_surface.cc b/content/browser/android/in_process/synchronous_compositor_output_surface.cc
index b0e2d0e3a4918de3c5470bdce41541f0f433a657..4378aef80da27f666f439152b84e54d5ab002ba4 100644
--- a/content/browser/android/in_process/synchronous_compositor_output_surface.cc
+++ b/content/browser/android/in_process/synchronous_compositor_output_surface.cc
@@ -9,6 +9,7 @@
#include "base/time.h"
#include "cc/output/compositor_frame.h"
#include "cc/output/compositor_frame_ack.h"
+#include "cc/output/context_provider.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"
@@ -34,9 +35,6 @@ namespace {
// TODO(boliu): RenderThreadImpl should create in process contexts as well.
scoped_ptr<WebKit::WebGraphicsContext3D> CreateWebGraphicsContext3D() {
- if (!CommandLine::ForCurrentProcess()->HasSwitch("testing-webview-gl-mode"))
- return scoped_ptr<WebKit::WebGraphicsContext3D>();
-
WebKit::WebGraphicsContext3D::Attributes attributes;
attributes.antialias = false;
attributes.shareResources = true;
@@ -91,7 +89,6 @@ class SynchronousCompositorOutputSurface::SoftwareDevice
SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface(
int routing_id)
: cc::OutputSurface(
- CreateWebGraphicsContext3D(),
scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))),
routing_id_(routing_id),
needs_begin_frame_(false),
@@ -150,10 +147,6 @@ void SynchronousCompositorOutputSurface::SwapBuffers(
did_swap_buffer_ = true;
}
-bool SynchronousCompositorOutputSurface::IsHwReady() {
- return context3d() != NULL;
-}
-
namespace {
void AdjustTransformForClip(gfx::Transform* transform, gfx::Rect clip) {
// The system-provided transform translates us from the screen origin to the
@@ -162,35 +155,20 @@ void AdjustTransformForClip(gfx::Transform* transform, gfx::Rect clip) {
}
} // namespace
-bool SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) {
+bool SynchronousCompositorOutputSurface::InitializeHwDraw() {
DCHECK(CalledOnValidThread());
- DCHECK(canvas);
- DCHECK(!current_sw_canvas_);
- current_sw_canvas_ = canvas;
-
- SkIRect canvas_clip;
- canvas->getClipDeviceBounds(&canvas_clip);
- gfx::Rect clip = gfx::SkIRectToRect(canvas_clip);
-
- gfx::Transform transform(gfx::Transform::kSkipInitialization);
- transform.matrix() = canvas->getTotalMatrix(); // Converts 3x3 matrix to 4x4.
- AdjustTransformForClip(&transform, clip);
-
- surface_size_ = gfx::Size(canvas->getDeviceSize().width(),
- canvas->getDeviceSize().height());
- client_->SetExternalDrawConstraints(transform, clip);
-
- InvokeComposite(clip.size());
+ DCHECK(client_);
+ DCHECK(!context3d_);
- bool finished_draw = current_sw_canvas_ == NULL;
- current_sw_canvas_ = NULL;
- return finished_draw;
+ // TODO(boliu): Get a context provider in constructor and pass here.
+ return InitializeAndSetContext3D(CreateWebGraphicsContext3D().Pass(),
+ scoped_refptr<cc::ContextProvider>());
}
bool SynchronousCompositorOutputSurface::DemandDrawHw(
- gfx::Size surface_size,
- const gfx::Transform& transform,
- gfx::Rect clip) {
+ gfx::Size surface_size,
+ const gfx::Transform& transform,
+ gfx::Rect clip) {
DCHECK(CalledOnValidThread());
DCHECK(client_);
DCHECK(context3d());
@@ -211,9 +189,36 @@ bool SynchronousCompositorOutputSurface::DemandDrawHw(
client_->SetExternalDrawConstraints(adjusted_transform, clip);
InvokeComposite(clip.size());
+ // TODO(boliu): Check if context is lost here.
+
return did_swap_buffer_;
}
+bool SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) {
+ DCHECK(CalledOnValidThread());
+ DCHECK(canvas);
+ DCHECK(!current_sw_canvas_);
+ current_sw_canvas_ = canvas;
+
+ SkIRect canvas_clip;
+ canvas->getClipDeviceBounds(&canvas_clip);
+ gfx::Rect clip = gfx::SkIRectToRect(canvas_clip);
+
+ gfx::Transform transform(gfx::Transform::kSkipInitialization);
+ transform.matrix() = canvas->getTotalMatrix(); // Converts 3x3 matrix to 4x4.
+ AdjustTransformForClip(&transform, clip);
+
+ surface_size_ = gfx::Size(canvas->getDeviceSize().width(),
+ canvas->getDeviceSize().height());
+ client_->SetExternalDrawConstraints(transform, clip);
+
+ InvokeComposite(clip.size());
+
+ bool finished_draw = current_sw_canvas_ == NULL;
+ current_sw_canvas_ = NULL;
+ return finished_draw;
+}
+
void SynchronousCompositorOutputSurface::InvokeComposite(
gfx::Size damage_size) {
client_->SetNeedsRedrawRect(gfx::Rect(damage_size));

Powered by Google App Engine
This is Rietveld 408576698