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

Unified Diff: android_webview/browser/surfaces_instance.cc

Issue 2856913002: Don't submit empty frames in android webview (Closed)
Patch Set: c Created 3 years, 7 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
« no previous file with comments | « android_webview/browser/surfaces_instance.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/browser/surfaces_instance.cc
diff --git a/android_webview/browser/surfaces_instance.cc b/android_webview/browser/surfaces_instance.cc
index c09e9a606a40e7ba6b58e7fc0cb85493660dd18f..b8599fe91175b5e7f1707cb68f7d8cf789bf212a 100644
--- a/android_webview/browser/surfaces_instance.cc
+++ b/android_webview/browser/surfaces_instance.cc
@@ -14,6 +14,7 @@
#include "base/memory/ptr_util.h"
#include "cc/output/renderer_settings.h"
#include "cc/output/texture_mailbox_deleter.h"
+#include "cc/quads/solid_color_draw_quad.h"
#include "cc/quads/surface_draw_quad.h"
#include "cc/scheduler/begin_frame_source.h"
#include "cc/surfaces/compositor_frame_sink_support.h"
@@ -140,8 +141,9 @@ void SurfacesInstance::DrawAndSwap(const gfx::Size& viewport,
frame.render_pass_list.push_back(std::move(render_pass));
frame.metadata.referenced_surfaces = child_ids_;
- if (!root_id_.is_valid()) {
+ if (!root_id_.is_valid() || frame_size != surface_size_) {
root_id_ = local_surface_id_allocator_->GenerateId();
+ surface_size_ = frame_size;
display_->SetLocalSurfaceId(root_id_, 1.f);
}
support_->SubmitCompositorFrame(root_id_, std::move(frame));
@@ -155,7 +157,7 @@ void SurfacesInstance::AddChildId(const cc::SurfaceId& child_id) {
child_ids_.end());
child_ids_.push_back(child_id);
if (root_id_.is_valid())
- SetEmptyRootFrame();
+ SetSolidColorRootFrame();
}
void SurfacesInstance::RemoveChildId(const cc::SurfaceId& child_id) {
@@ -163,16 +165,28 @@ void SurfacesInstance::RemoveChildId(const cc::SurfaceId& child_id) {
DCHECK(itr != child_ids_.end());
child_ids_.erase(itr);
if (root_id_.is_valid())
- SetEmptyRootFrame();
+ SetSolidColorRootFrame();
}
-void SurfacesInstance::SetEmptyRootFrame() {
- cc::CompositorFrame empty_frame;
+void SurfacesInstance::SetSolidColorRootFrame() {
+ DCHECK(!surface_size_.IsEmpty());
+ gfx::Rect rect(surface_size_);
+ std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create();
+ render_pass->SetNew(1, rect, rect, gfx::Transform());
+ cc::SharedQuadState* quad_state =
+ render_pass->CreateAndAppendSharedQuadState();
+ quad_state->SetAll(gfx::Transform(), rect, rect, rect, false, 1.f,
+ SkBlendMode::kSrcOver, 0);
+ cc::SolidColorDrawQuad* solid_quad =
+ render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>();
+ solid_quad->SetNew(quad_state, rect, rect, SK_ColorBLACK, false);
+ cc::CompositorFrame frame;
+ frame.render_pass_list.push_back(std::move(render_pass));
// We draw synchronously, so acknowledge a manual BeginFrame.
- empty_frame.metadata.begin_frame_ack =
+ frame.metadata.begin_frame_ack =
cc::BeginFrameAck::CreateManualAckWithDamage();
- empty_frame.metadata.referenced_surfaces = child_ids_;
- support_->SubmitCompositorFrame(root_id_, std::move(empty_frame));
+ frame.metadata.referenced_surfaces = child_ids_;
+ support_->SubmitCompositorFrame(root_id_, std::move(frame));
}
void SurfacesInstance::DidReceiveCompositorFrameAck(
« no previous file with comments | « android_webview/browser/surfaces_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698