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

Unified Diff: cc/output/direct_renderer.cc

Issue 15579002: Implement transform/clip support for Android WebView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add tests 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: cc/output/direct_renderer.cc
diff --git a/cc/output/direct_renderer.cc b/cc/output/direct_renderer.cc
index e2c17b8a7cdb320d480f5b4905c49bc848a8982b..52498aedcd8f1e8fd8d427e1e2bdfeee9427b150 100644
--- a/cc/output/direct_renderer.cc
+++ b/cc/output/direct_renderer.cc
@@ -82,6 +82,7 @@ void DirectRenderer::QuadRectTransform(gfx::Transform* quad_rect_transform,
// static
void DirectRenderer::InitializeMatrices(DrawingFrame* frame,
gfx::Rect draw_rect,
+ gfx::Rect window_rect,
bool flip_y) {
if (flip_y) {
frame->projection_matrix = OrthoProjectionMatrix(draw_rect.x(),
@@ -94,19 +95,26 @@ void DirectRenderer::InitializeMatrices(DrawingFrame* frame,
draw_rect.y(),
draw_rect.bottom());
}
- frame->window_matrix =
- window_matrix(0, 0, draw_rect.width(), draw_rect.height());
+
+ frame->window_matrix = window_matrix(window_rect.x(),
+ window_rect.y(),
+ window_rect.width(),
+ window_rect.height());
frame->flipped_y = flip_y;
}
-// static
gfx::Rect DirectRenderer::MoveScissorToWindowSpace(
const DrawingFrame* frame, const gfx::RectF& scissor_rect) {
gfx::Rect scissor_rect_in_canvas_space = gfx::ToEnclosingRect(scissor_rect);
- // The scissor coordinates must be supplied in viewport space so we need to
+ // The scissor coordinates must be supplied in window space so we need to
// offset by the relative position of the top left corner of the current
// render pass.
gfx::Rect framebuffer_output_rect = frame->current_render_pass->output_rect;
+ if (!frame->current_texture) {
+ framebuffer_output_rect = gfx::Rect(output_surface_->SurfaceSize());
+ scissor_rect_in_canvas_space.Offset(client_->DeviceViewport().x(),
+ client_->DeviceViewport().y());
+ }
scissor_rect_in_canvas_space.set_x(
scissor_rect_in_canvas_space.x() - framebuffer_output_rect.x());
if (frame->flipped_y && !frame->current_texture) {
@@ -121,8 +129,10 @@ gfx::Rect DirectRenderer::MoveScissorToWindowSpace(
}
DirectRenderer::DirectRenderer(RendererClient* client,
+ OutputSurface* output_surface,
ResourceProvider* resource_provider)
: Renderer(client),
+ output_surface_(output_surface),
resource_provider_(resource_provider) {}
DirectRenderer::~DirectRenderer() {}
@@ -197,7 +207,13 @@ void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order) {
frame.root_damage_rect =
Capabilities().using_partial_swap && client_->AllowPartialSwap() ?
root_render_pass->damage_rect : root_render_pass->output_rect;
- frame.root_damage_rect.Intersect(gfx::Rect(ViewportSize()));
+ frame.root_damage_rect.Intersect(gfx::Rect(client_->DeviceViewport().size()));
+
+ // Only reshape when we know we are going to draw. Otherwise, the reshape
+ // can leave the window at the wrong size if we never draw and the proper
+ // viewport size is never set.
+ output_surface_->Reshape(client_->DeviceViewport().size(),
enne (OOO) 2013/06/04 17:26:03 Should this only happen if the device viewport has
aelias_OOO_until_Jul13 2013/06/04 17:54:20 I added a check within OutputSurface itself not to
+ client_->DeviceScaleFactor());
BeginDrawingFrame(&frame);
for (size_t i = 0; i < render_passes_in_draw_order->size(); ++i) {
@@ -327,8 +343,16 @@ bool DirectRenderer::UseRenderPass(DrawingFrame* frame,
if (render_pass == frame->root_render_pass) {
BindFramebufferToOutputSurface(frame);
- InitializeMatrices(frame, render_pass->output_rect, FlippedFramebuffer());
- SetDrawViewportSize(render_pass->output_rect.size());
+ gfx::Rect viewport = client_->DeviceViewport();
+ if (FlippedFramebuffer())
+ viewport.set_y(output_surface_->SurfaceSize().height() -
+ viewport.bottom());
+ InitializeMatrices(
+ frame,
+ render_pass->output_rect,
+ viewport,
+ FlippedFramebuffer());
+ SetDrawViewport(viewport);
return true;
}

Powered by Google App Engine
This is Rietveld 408576698