| Index: cc/output/gl_renderer.cc
|
| diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
|
| index 5d5afdf1b2edbcc668e8818cb7ddcdfe0cd748c9..0b8631b8878d020f536c034c3d754e9e7c4ad6ad 100644
|
| --- a/cc/output/gl_renderer.cc
|
| +++ b/cc/output/gl_renderer.cc
|
| @@ -566,25 +566,30 @@ void GLRenderer::DoDrawQuad(const DrawQuad* quad,
|
| FlushTextureQuadCache(SHARED_BINDING);
|
| }
|
|
|
| + bool was_drawn = false;
|
| switch (quad->material) {
|
| case DrawQuad::INVALID:
|
| NOTREACHED();
|
| break;
|
| case DrawQuad::DEBUG_BORDER:
|
| DrawDebugBorderQuad(DebugBorderDrawQuad::MaterialCast(quad));
|
| + was_drawn = true;
|
| break;
|
| case DrawQuad::PICTURE_CONTENT:
|
| // PictureDrawQuad should only be used for resourceless software draws.
|
| NOTREACHED();
|
| break;
|
| case DrawQuad::RENDER_PASS:
|
| - DrawRenderPassQuad(RenderPassDrawQuad::MaterialCast(quad), clip_region);
|
| + was_drawn = DrawRenderPassQuad(RenderPassDrawQuad::MaterialCast(quad),
|
| + clip_region);
|
| break;
|
| case DrawQuad::SOLID_COLOR:
|
| - DrawSolidColorQuad(SolidColorDrawQuad::MaterialCast(quad), clip_region);
|
| + was_drawn = DrawSolidColorQuad(SolidColorDrawQuad::MaterialCast(quad),
|
| + clip_region);
|
| break;
|
| case DrawQuad::STREAM_VIDEO_CONTENT:
|
| - DrawStreamVideoQuad(StreamVideoDrawQuad::MaterialCast(quad), clip_region);
|
| + was_drawn = DrawStreamVideoQuad(StreamVideoDrawQuad::MaterialCast(quad),
|
| + clip_region);
|
| break;
|
| case DrawQuad::SURFACE_CONTENT:
|
| // Surface content should be fully resolved to other quad types before
|
| @@ -592,15 +597,19 @@ void GLRenderer::DoDrawQuad(const DrawQuad* quad,
|
| NOTREACHED();
|
| break;
|
| case DrawQuad::TEXTURE_CONTENT:
|
| - EnqueueTextureQuad(TextureDrawQuad::MaterialCast(quad), clip_region);
|
| + was_drawn =
|
| + EnqueueTextureQuad(TextureDrawQuad::MaterialCast(quad), clip_region);
|
| break;
|
| case DrawQuad::TILED_CONTENT:
|
| - DrawTileQuad(TileDrawQuad::MaterialCast(quad), clip_region);
|
| + was_drawn = DrawTileQuad(TileDrawQuad::MaterialCast(quad), clip_region);
|
| break;
|
| case DrawQuad::YUV_VIDEO_CONTENT:
|
| - DrawYUVVideoQuad(YUVVideoDrawQuad::MaterialCast(quad), clip_region);
|
| + was_drawn =
|
| + DrawYUVVideoQuad(YUVVideoDrawQuad::MaterialCast(quad), clip_region);
|
| break;
|
| }
|
| + if (was_drawn)
|
| + area_drawn_ += quad->visible_rect.size().GetArea();
|
| }
|
|
|
| // This function does not handle 3D sorting right now, since the debug border
|
| @@ -1033,7 +1042,7 @@ const TileDrawQuad* GLRenderer::CanPassBeDrawnDirectly(const RenderPass* pass) {
|
| return tile_quad;
|
| }
|
|
|
| -void GLRenderer::DrawRenderPassQuad(const RenderPassDrawQuad* quad,
|
| +bool GLRenderer::DrawRenderPassQuad(const RenderPassDrawQuad* quad,
|
| const gfx::QuadF* clip_region) {
|
| auto bypass = render_pass_bypass_quads_.find(quad->render_pass_id);
|
| DrawRenderPassDrawQuadParams params;
|
| @@ -1053,7 +1062,7 @@ void GLRenderer::DrawRenderPassQuad(const RenderPassDrawQuad* quad,
|
| // texture coords and let the projection matrix naturallyd o it.
|
| params.flip_texture = false;
|
| params.contents_texture = &tile_resource;
|
| - DrawRenderPassQuadInternal(¶ms);
|
| + return DrawRenderPassQuadInternal(¶ms);
|
| } else {
|
| ScopedResource* contents_texture =
|
| render_pass_textures_[quad->render_pass_id].get();
|
| @@ -1063,19 +1072,19 @@ void GLRenderer::DrawRenderPassQuad(const RenderPassDrawQuad* quad,
|
| // render pass, it needs to an extra flip to be oriented correctly.
|
| params.flip_texture = true;
|
| params.contents_texture = contents_texture;
|
| - DrawRenderPassQuadInternal(¶ms);
|
| + return DrawRenderPassQuadInternal(¶ms);
|
| }
|
| }
|
|
|
| -void GLRenderer::DrawRenderPassQuadInternal(
|
| +bool GLRenderer::DrawRenderPassQuadInternal(
|
| DrawRenderPassDrawQuadParams* params) {
|
| params->quad_to_target_transform =
|
| params->quad->shared_quad_state->quad_to_target_transform;
|
| if (!InitializeRPDQParameters(params))
|
| - return;
|
| + return false;
|
| UpdateRPDQShadersForBlending(params);
|
| if (!UpdateRPDQWithSkiaFilters(params))
|
| - return;
|
| + return false;
|
| UseRenderPass(current_frame()->current_render_pass);
|
| SetViewport();
|
| UpdateRPDQTexturesForSampling(params);
|
| @@ -1083,6 +1092,7 @@ void GLRenderer::DrawRenderPassQuadInternal(
|
| ChooseRPDQProgram(params);
|
| UpdateRPDQUniforms(params);
|
| DrawRPDQ(*params);
|
| + return true;
|
| }
|
|
|
| bool GLRenderer::InitializeRPDQParameters(
|
| @@ -1724,7 +1734,7 @@ void GLRenderer::SetupRenderPassQuadForClippingAndAntialiasing(
|
| *local_quad = MapQuadToLocalSpace(device_transform, device_quad);
|
| }
|
|
|
| -void GLRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad,
|
| +bool GLRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad,
|
| const gfx::QuadF* clip_region) {
|
| gfx::Rect tile_rect = quad->visible_rect;
|
|
|
| @@ -1735,14 +1745,14 @@ void GLRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad,
|
| // Early out if alpha is small enough that quad doesn't contribute to output.
|
| if (alpha < std::numeric_limits<float>::epsilon() &&
|
| quad->ShouldDrawWithBlending())
|
| - return;
|
| + return false;
|
|
|
| gfx::Transform device_transform =
|
| current_frame()->window_matrix * current_frame()->projection_matrix *
|
| quad->shared_quad_state->quad_to_target_transform;
|
| device_transform.FlattenTo2d();
|
| if (!device_transform.IsInvertible())
|
| - return;
|
| + return false;
|
|
|
| auto local_quad = gfx::QuadF(gfx::RectF(tile_rect));
|
|
|
| @@ -1808,14 +1818,15 @@ void GLRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad,
|
| quad->shared_quad_state->quad_to_target_transform);
|
| gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
|
| }
|
| + return true;
|
| }
|
|
|
| -void GLRenderer::DrawTileQuad(const TileDrawQuad* quad,
|
| +bool GLRenderer::DrawTileQuad(const TileDrawQuad* quad,
|
| const gfx::QuadF* clip_region) {
|
| - DrawContentQuad(quad, quad->resource_id(), clip_region);
|
| + return DrawContentQuad(quad, quad->resource_id(), clip_region);
|
| }
|
|
|
| -void GLRenderer::DrawContentQuad(const ContentDrawQuadBase* quad,
|
| +bool GLRenderer::DrawContentQuad(const ContentDrawQuadBase* quad,
|
| ResourceId resource_id,
|
| const gfx::QuadF* clip_region) {
|
| gfx::Transform device_transform =
|
| @@ -1841,19 +1852,18 @@ void GLRenderer::DrawContentQuad(const ContentDrawQuadBase* quad,
|
| // similar to the way DrawContentQuadNoAA works and then consider
|
| // combining DrawContentQuadAA and DrawContentQuadNoAA into one method.
|
| if (use_aa)
|
| - DrawContentQuadAA(quad, resource_id, device_transform, device_layer_quad,
|
| - clip_region);
|
| - else
|
| - DrawContentQuadNoAA(quad, resource_id, clip_region);
|
| + return DrawContentQuadAA(quad, resource_id, device_transform,
|
| + device_layer_quad, clip_region);
|
| + return DrawContentQuadNoAA(quad, resource_id, clip_region);
|
| }
|
|
|
| -void GLRenderer::DrawContentQuadAA(const ContentDrawQuadBase* quad,
|
| +bool GLRenderer::DrawContentQuadAA(const ContentDrawQuadBase* quad,
|
| ResourceId resource_id,
|
| const gfx::Transform& device_transform,
|
| const gfx::QuadF& aa_quad,
|
| const gfx::QuadF* clip_region) {
|
| if (!device_transform.IsInvertible())
|
| - return;
|
| + return false;
|
|
|
| gfx::Rect tile_rect = quad->visible_rect;
|
|
|
| @@ -1953,9 +1963,10 @@ void GLRenderer::DrawContentQuadAA(const ContentDrawQuadBase* quad,
|
| DrawQuadGeometry(current_frame()->projection_matrix,
|
| quad->shared_quad_state->quad_to_target_transform,
|
| centered_rect);
|
| + return true;
|
| }
|
|
|
| -void GLRenderer::DrawContentQuadNoAA(const ContentDrawQuadBase* quad,
|
| +bool GLRenderer::DrawContentQuadNoAA(const ContentDrawQuadBase* quad,
|
| ResourceId resource_id,
|
| const gfx::QuadF* clip_region) {
|
| gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional(
|
| @@ -2048,9 +2059,10 @@ void GLRenderer::DrawContentQuadNoAA(const ContentDrawQuadBase* quad,
|
| quad->shared_quad_state->quad_to_target_transform);
|
|
|
| gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
|
| + return true;
|
| }
|
|
|
| -void GLRenderer::DrawYUVVideoQuad(const YUVVideoDrawQuad* quad,
|
| +bool GLRenderer::DrawYUVVideoQuad(const YUVVideoDrawQuad* quad,
|
| const gfx::QuadF* clip_region) {
|
| SetBlendEnabled(quad->ShouldDrawWithBlending());
|
|
|
| @@ -2215,9 +2227,10 @@ void GLRenderer::DrawYUVVideoQuad(const YUVVideoDrawQuad* quad,
|
| quad->shared_quad_state->quad_to_target_transform, tile_rect,
|
| region_quad, uvs);
|
| }
|
| + return true;
|
| }
|
|
|
| -void GLRenderer::DrawStreamVideoQuad(const StreamVideoDrawQuad* quad,
|
| +bool GLRenderer::DrawStreamVideoQuad(const StreamVideoDrawQuad* quad,
|
| const gfx::QuadF* clip_region) {
|
| SetBlendEnabled(quad->ShouldDrawWithBlending());
|
|
|
| @@ -2258,6 +2271,7 @@ void GLRenderer::DrawStreamVideoQuad(const StreamVideoDrawQuad* quad,
|
| quad->shared_quad_state->quad_to_target_transform,
|
| gfx::RectF(quad->rect), region_quad, uvs);
|
| }
|
| + return true;
|
| }
|
|
|
| void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) {
|
| @@ -2352,7 +2366,7 @@ void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) {
|
| }
|
| }
|
|
|
| -void GLRenderer::EnqueueTextureQuad(const TextureDrawQuad* quad,
|
| +bool GLRenderer::EnqueueTextureQuad(const TextureDrawQuad* quad,
|
| const gfx::QuadF* clip_region) {
|
| // If we have a clip_region then we have to render the next quad
|
| // with dynamic geometry, therefore we must flush all pending
|
| @@ -2443,10 +2457,17 @@ void GLRenderer::EnqueueTextureQuad(const TextureDrawQuad* quad,
|
| uv[7] = scaled_region.p4().y() + 0.5f;
|
| PrepareGeometry(CLIPPED_BINDING);
|
| clipped_geometry_->InitializeCustomQuadWithUVs(scaled_region, uv);
|
| + if (draw_cache_.is_empty)
|
| + return false;
|
| FlushTextureQuadCache(CLIPPED_BINDING);
|
| } else if (gl_composited_texture_quad_border_) {
|
| + if (draw_cache_.is_empty)
|
| + return false;
|
| FlushTextureQuadCache(SHARED_BINDING);
|
| + } else {
|
| + return false;
|
| }
|
| + return true;
|
| }
|
|
|
| void GLRenderer::FinishDrawingFrame() {
|
| @@ -2475,6 +2496,12 @@ void GLRenderer::FinishDrawingFrame() {
|
|
|
| void GLRenderer::FinishDrawingQuadList() {
|
| FlushTextureQuadCache(SHARED_BINDING);
|
| + size_t area_total = surface_size_for_swap_buffers().GetArea();
|
| + if (area_total) {
|
| + LOG(ERROR) << "Total drawn: " << area_drawn_ << " vs. " << area_total
|
| + << " = " << static_cast<float>(area_drawn_) / area_total;
|
| + }
|
| + area_drawn_ = 0;
|
| }
|
|
|
| void GLRenderer::SetEnableDCLayers(bool enable) {
|
|
|