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)); |