From 32e9a43a6a6623fc02129a9e6f9e3ec7533036be Mon Sep 17 00:00:00 2001 From: Kalyan Kondapally Date: Tue, 13 Feb 2018 02:39:53 -0800 Subject: [PATCH] Partial revert of "ff92a05232c5c56c63b99865dd149c4c9bcf59de" Jira: None. Test: "Rendering Layer outside Damaged Region" warnings are not seen when compositor trace is enabled. Signed-off-by: Kalyan Kondapally --- common/compositor/compositor.cpp | 3 ++- common/compositor/nativesurface.cpp | 17 +++++++++++++++++ common/compositor/nativesurface.h | 5 +++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/common/compositor/compositor.cpp b/common/compositor/compositor.cpp index 92632bf..a4b518c 100644 --- a/common/compositor/compositor.cpp +++ b/common/compositor/compositor.cpp @@ -98,7 +98,8 @@ bool Compositor::Draw(DisplayPlaneStateList &comp_planes, bool regions_empty = comp_regions.empty(); NativeSurface *surface = plane.GetOffScreenTarget(); if (!regions_empty && - (surface->ClearSurface() || surface->IsPartialClear())) { + (surface->ClearSurface() || surface->IsPartialClear() || + surface->IsSurfaceDamageChanged())) { plane.ResetCompositionRegion(); regions_empty = true; } diff --git a/common/compositor/nativesurface.cpp b/common/compositor/nativesurface.cpp index 3914bcf..47bfbb1 100644 --- a/common/compositor/nativesurface.cpp +++ b/common/compositor/nativesurface.cpp @@ -72,6 +72,9 @@ void NativeSurface::SetNativeFence(int32_t fd) { void NativeSurface::SetClearSurface(ClearType clear_surface) { if (clear_surface_ != clear_surface) { clear_surface_ = clear_surface; + if (clear_surface_ == kFullClear) { + damage_changed_ = true; + } } } @@ -83,11 +86,16 @@ void NativeSurface::SetSurfaceAge(int value) { surface_age_ = value; } +bool NativeSurface::IsSurfaceDamageChanged() const { + return damage_changed_; +} + void NativeSurface::SetPlaneTarget(const DisplayPlaneState &plane, uint32_t gpu_fd) { const HwcRect &display_rect = plane.GetDisplayFrame(); surface_damage_ = display_rect; clear_surface_ = kFullClear; + damage_changed_ = true; surface_age_ = 0; if (layer_.GetBuffer()->GetFb() == 0) { layer_.GetBuffer()->CreateFrameBuffer(gpu_fd); @@ -106,6 +114,7 @@ void NativeSurface::UpdateSurfaceDamage( const HwcRect ¤tsurface_damage) { if (surface_damage_.empty()) { surface_damage_ = currentsurface_damage; + damage_changed_ = true; return; } @@ -113,11 +122,19 @@ void NativeSurface::UpdateSurfaceDamage( return; } + HwcRect temp = surface_damage_; CalculateRect(currentsurface_damage, surface_damage_); + if (!damage_changed_) { + damage_changed_ = true; + if (temp == surface_damage_) { + damage_changed_ = false; + } + } } void NativeSurface::ResetDamage() { surface_damage_ = HwcRect(0, 0, 0, 0); + damage_changed_ = false; } void NativeSurface::InitializeLayer(HWCNativeHandle native_handle) { diff --git a/common/compositor/nativesurface.h b/common/compositor/nativesurface.h index 8e03598..7a1c63d 100644 --- a/common/compositor/nativesurface.h +++ b/common/compositor/nativesurface.h @@ -112,6 +112,10 @@ class NativeSurface { // Applies rotation transform to this surface. void SetTransform(uint32_t transform); + // Returns true in case damage of this surface has changed + // compared to previous frame. + bool IsSurfaceDamageChanged() const; + protected: OverlayLayer layer_; ResourceManager* resource_manager_; @@ -123,6 +127,7 @@ class NativeSurface { int height_; ClearType clear_surface_; int surface_age_; + bool damage_changed_ = true; HwcRect surface_damage_; }; -- 2.11.0