#include "content/browser/android/in_process/synchronous_compositor_impl.h"
#include "content/browser/gpu/compositor_util.h"
#include "content/public/browser/browser_thread.h"
+#include "content/renderer/gpu/frame_swap_message_queue.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/common/gpu_memory_allocation.h"
#include "third_party/skia/include/core/SkCanvas.h"
};
SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface(
- int routing_id)
+ int routing_id,
+ scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue)
: cc::OutputSurface(
scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))),
routing_id_(routing_id),
invoking_composite_(false),
current_sw_canvas_(NULL),
memory_policy_(0),
- output_surface_client_(NULL) {
+ output_surface_client_(NULL),
+ frame_swap_message_queue_(frame_swap_message_queue) {
capabilities_.deferred_gl_initialization = true;
capabilities_.draw_and_swap_full_viewport_every_frame = true;
capabilities_.adjust_deadline_for_parent = false;
delegate->DidDestroySynchronousOutputSurface(this);
}
-bool SynchronousCompositorOutputSurface::ForcedDrawToSoftwareDevice() const {
- // |current_sw_canvas_| indicates we're in a DemandDrawSw call. In addition
- // |invoking_composite_| == false indicates an attempt to draw outside of
- // the synchronous compositor's control: force it into SW path and hence to
- // the null canvas (and will log a warning there).
- return current_sw_canvas_ != NULL || !invoking_composite_;
-}
-
bool SynchronousCompositorOutputSurface::BindToClient(
cc::OutputSurfaceClient* surface_client) {
DCHECK(CalledOnValidThread());
gfx::Size surface_size,
const gfx::Transform& transform,
gfx::Rect viewport,
- gfx::Rect clip) {
+ gfx::Rect clip,
+ gfx::Rect viewport_rect_for_tile_priority,
+ const gfx::Transform& transform_for_tile_priority) {
DCHECK(CalledOnValidThread());
DCHECK(HasClient());
DCHECK(context_provider_);
surface_size_ = surface_size;
- InvokeComposite(transform, viewport, clip, true);
+ InvokeComposite(transform,
+ viewport,
+ clip,
+ viewport_rect_for_tile_priority,
+ transform_for_tile_priority,
+ true);
return frame_holder_.Pass();
}
surface_size_ = gfx::Size(canvas->getDeviceSize().width(),
canvas->getDeviceSize().height());
- InvokeComposite(transform, clip, clip, false);
+ // Resourceless software draw does not need viewport_for_tiling.
+ gfx::Rect empty;
+ InvokeComposite(transform, clip, clip, empty, gfx::Transform(), false);
return frame_holder_.Pass();
}
const gfx::Transform& transform,
gfx::Rect viewport,
gfx::Rect clip,
- bool valid_for_tile_management) {
+ gfx::Rect viewport_rect_for_tile_priority,
+ gfx::Transform transform_for_tile_priority,
+ bool hardware_draw) {
DCHECK(!invoking_composite_);
DCHECK(!frame_holder_.get());
base::AutoReset<bool> invoking_composite_resetter(&invoking_composite_, true);
gfx::Transform adjusted_transform = transform;
AdjustTransform(&adjusted_transform, viewport);
- SetExternalDrawConstraints(
- adjusted_transform, viewport, clip, valid_for_tile_management);
+ SetExternalDrawConstraints(adjusted_transform,
+ viewport,
+ clip,
+ viewport_rect_for_tile_priority,
+ transform_for_tile_priority,
+ !hardware_draw);
SetNeedsRedrawRect(gfx::Rect(viewport.size()));
client_->BeginFrame(cc::BeginFrameArgs::CreateForSynchronousCompositor());
// After software draws (which might move the viewport arbitrarily), restore
// the previous hardware viewport to allow CC's tile manager to prioritize
// properly.
- if (valid_for_tile_management) {
+ if (hardware_draw) {
cached_hw_transform_ = adjusted_transform;
cached_hw_viewport_ = viewport;
cached_hw_clip_ = clip;
+ cached_hw_viewport_rect_for_tile_priority_ =
+ viewport_rect_for_tile_priority;
+ cached_hw_transform_for_tile_priority_ = transform_for_tile_priority;
} else {
- SetExternalDrawConstraints(
- cached_hw_transform_, cached_hw_viewport_, cached_hw_clip_, true);
+ bool resourceless_software_draw = false;
+ SetExternalDrawConstraints(cached_hw_transform_,
+ cached_hw_viewport_,
+ cached_hw_clip_,
+ cached_hw_viewport_rect_for_tile_priority_,
+ cached_hw_transform_for_tile_priority_,
+ resourceless_software_draw);
}
if (frame_holder_.get())
output_surface_client_->SetMemoryPolicy(memory_policy_);
}
+void SynchronousCompositorOutputSurface::GetMessagesToDeliver(
+ ScopedVector<IPC::Message>* messages) {
+ DCHECK(CalledOnValidThread());
+ scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope =
+ frame_swap_message_queue_->AcquireSendMessageScope();
+ frame_swap_message_queue_->DrainMessages(messages);
+}
+
// Not using base::NonThreadSafe as we want to enforce a more exacting threading
// requirement: SynchronousCompositorOutputSurface() must only be used on the UI
// thread.