Commit 335d3a8a authored by ericrk's avatar ericrk Committed by Commit bot

Remove SetDrawViewport

This change removes SetDrawViewport, instead tracking the current window
viewport in DirectRenderer.

Review URL: https://codereview.chromium.org/1035863002

Cr-Commit-Position: refs/heads/master@{#322615}
parent 8320f3c2
......@@ -108,11 +108,10 @@ void DirectRenderer::InitializeViewport(DrawingFrame* frame,
window_rect.y(),
window_rect.width(),
window_rect.height());
SetDrawViewport(window_rect);
current_draw_rect_ = draw_rect;
current_viewport_rect_ = viewport_rect;
current_surface_size_ = surface_size;
current_window_space_viewport_ = window_rect;
}
gfx::Rect DirectRenderer::MoveFromDrawToWindowSpace(
......
......@@ -115,7 +115,6 @@ class CC_EXPORT DirectRenderer : public Renderer {
virtual bool BindFramebufferToTexture(DrawingFrame* frame,
const ScopedResource* resource,
const gfx::Rect& target_rect) = 0;
virtual void SetDrawViewport(const gfx::Rect& window_space_viewport) = 0;
virtual void SetScissorTestRect(const gfx::Rect& scissor_rect) = 0;
virtual void PrepareSurfaceForPass(
DrawingFrame* frame,
......@@ -146,13 +145,14 @@ class CC_EXPORT DirectRenderer : public Renderer {
scoped_ptr<OverlayProcessor> overlay_processor_;
// For use in coordinate conversion, this stores the output rect, viewport
// rect (= unflipped version of glViewport rect), and the size of target
// framebuffer. During a draw, this stores the values for the current render
// pass; in between draws, they retain the values for the root render pass of
// the last draw.
// rect (= unflipped version of glViewport rect), the size of target
// framebuffer, and the current window space viewport. During a draw, this
// stores the values for the current render pass; in between draws, they
// retain the values for the root render pass of the last draw.
gfx::Rect current_draw_rect_;
gfx::Rect current_viewport_rect_;
gfx::Size current_surface_size_;
gfx::Rect current_window_space_viewport_;
private:
gfx::Vector2d enlarge_pass_texture_amount_;
......
......@@ -417,6 +417,8 @@ void GLRenderer::PrepareSurfaceForPass(
DrawingFrame* frame,
SurfaceInitializationMode initialization_mode,
const gfx::Rect& render_pass_scissor) {
SetViewport();
switch (initialization_mode) {
case SURFACE_INITIALIZATION_MODE_PRESERVE:
EnsureScissorTestDisabled();
......@@ -1222,10 +1224,12 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
GLC(gl_, gl_->Uniform3fv(locations.edge, 8, edge));
if (locations.viewport != -1) {
float viewport[4] = {static_cast<float>(viewport_.x()),
static_cast<float>(viewport_.y()),
static_cast<float>(viewport_.width()),
static_cast<float>(viewport_.height()), };
float viewport[4] = {
static_cast<float>(current_window_space_viewport_.x()),
static_cast<float>(current_window_space_viewport_.y()),
static_cast<float>(current_window_space_viewport_.width()),
static_cast<float>(current_window_space_viewport_.height()),
};
GLC(gl_, gl_->Uniform4fv(locations.viewport, 1, viewport));
}
......@@ -1610,10 +1614,12 @@ void GLRenderer::DrawSolidColorQuad(const DrawingFrame* frame,
(SkColorGetB(color) * (1.0f / 255.0f)) * alpha,
alpha));
if (use_aa) {
float viewport[4] = {static_cast<float>(viewport_.x()),
static_cast<float>(viewport_.y()),
static_cast<float>(viewport_.width()),
static_cast<float>(viewport_.height()), };
float viewport[4] = {
static_cast<float>(current_window_space_viewport_.x()),
static_cast<float>(current_window_space_viewport_.y()),
static_cast<float>(current_window_space_viewport_.width()),
static_cast<float>(current_window_space_viewport_.height()),
};
GLC(gl_, gl_->Uniform4fv(uniforms.viewport_location, 1, viewport));
GLC(gl_, gl_->Uniform3fv(uniforms.edge_location, 8, edge));
}
......@@ -1777,10 +1783,10 @@ void GLRenderer::DrawContentQuadAA(const DrawingFrame* frame,
GLC(gl_, gl_->Uniform1i(uniforms.sampler_location, 0));
float viewport[4] = {
static_cast<float>(viewport_.x()),
static_cast<float>(viewport_.y()),
static_cast<float>(viewport_.width()),
static_cast<float>(viewport_.height()),
static_cast<float>(current_window_space_viewport_.x()),
static_cast<float>(current_window_space_viewport_.y()),
static_cast<float>(current_window_space_viewport_.width()),
static_cast<float>(current_window_space_viewport_.height()),
};
GLC(gl_, gl_->Uniform4fv(uniforms.viewport_location, 1, viewport));
GLC(gl_, gl_->Uniform3fv(uniforms.edge_location, 8, edge));
......@@ -2968,13 +2974,11 @@ void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) {
scissor_rect_needs_reset_ = false;
}
void GLRenderer::SetDrawViewport(const gfx::Rect& window_space_viewport) {
viewport_ = window_space_viewport;
GLC(gl_,
gl_->Viewport(window_space_viewport.x(),
window_space_viewport.y(),
window_space_viewport.width(),
window_space_viewport.height()));
void GLRenderer::SetViewport() {
GLC(gl_, gl_->Viewport(current_window_space_viewport_.x(),
current_window_space_viewport_.y(),
current_window_space_viewport_.width(),
current_window_space_viewport_.height()));
}
void GLRenderer::InitializeSharedObjects() {
......@@ -3519,6 +3523,11 @@ void GLRenderer::RestoreGLState() {
void GLRenderer::RestoreFramebuffer(DrawingFrame* frame) {
UseRenderPass(frame, frame->current_render_pass);
// Call SetViewport directly, rather than through PrepareSurfaceForPass.
// PrepareSurfaceForPass also clears the surface, which is not desired when
// restoring.
SetViewport();
}
bool GLRenderer::IsContextLost() {
......
......@@ -108,7 +108,6 @@ class CC_EXPORT GLRenderer : public DirectRenderer {
bool BindFramebufferToTexture(DrawingFrame* frame,
const ScopedResource* resource,
const gfx::Rect& target_rect) override;
void SetDrawViewport(const gfx::Rect& window_space_viewport) override;
void SetScissorTestRect(const gfx::Rect& scissor_rect) override;
void PrepareSurfaceForPass(DrawingFrame* frame,
SurfaceInitializationMode initialization_mode,
......@@ -151,6 +150,7 @@ class CC_EXPORT GLRenderer : public DirectRenderer {
void DiscardPixels();
void ClearFramebuffer(DrawingFrame* frame);
void SetViewport();
void DrawCheckerboardQuad(const DrawingFrame* frame,
const CheckerboardDrawQuad* quad,
......@@ -487,7 +487,6 @@ class CC_EXPORT GLRenderer : public DirectRenderer {
gfx::Rect swap_buffer_rect_;
gfx::Rect scissor_rect_;
gfx::Rect viewport_;
bool is_backbuffer_discarded_;
bool is_using_bind_uniform_;
bool is_scissor_enabled_;
......
......@@ -229,9 +229,6 @@ void SoftwareRenderer::PrepareSurfaceForPass(
}
}
void SoftwareRenderer::SetDrawViewport(
const gfx::Rect& window_space_viewport) {}
bool SoftwareRenderer::IsSoftwareResource(
ResourceProvider::ResourceId resource_id) const {
switch (resource_provider_->GetResourceType(resource_id)) {
......
......@@ -46,7 +46,6 @@ class CC_EXPORT SoftwareRenderer : public DirectRenderer {
bool BindFramebufferToTexture(DrawingFrame* frame,
const ScopedResource* texture,
const gfx::Rect& target_rect) override;
void SetDrawViewport(const gfx::Rect& window_space_viewport) override;
void SetScissorTestRect(const gfx::Rect& scissor_rect) override;
void PrepareSurfaceForPass(DrawingFrame* frame,
SurfaceInitializationMode initialization_mode,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment