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

Unified Diff: cc/layers/surface_layer_impl.cc

Issue 2495373003: Match html canvas which is transferred to OffscreenCanvas to CSS style (Closed)
Patch Set: fix basedd on feedback Created 4 years 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/layers/surface_layer_impl.cc
diff --git a/cc/layers/surface_layer_impl.cc b/cc/layers/surface_layer_impl.cc
index 2289a29326f449746f68eb7ddff19fd3a0ba58bf..38767154066a01bdfbe9973c0ecd5eeeef5d9484 100644
--- a/cc/layers/surface_layer_impl.cc
+++ b/cc/layers/surface_layer_impl.cc
@@ -16,7 +16,7 @@
namespace cc {
SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id)
- : LayerImpl(tree_impl, id), surface_scale_(0.f) {
+ : LayerImpl(tree_impl, id) {
layer_tree_impl()->AddSurfaceLayer(this);
}
@@ -53,6 +53,14 @@ void SurfaceLayerImpl::SetSurfaceSize(const gfx::Size& size) {
NoteLayerPropertyChanged();
}
+void SurfaceLayerImpl::SetStretchContentToFillBounds(bool is_scaling_needed) {
danakj 2016/12/15 16:13:14 nitto
+ if (stretch_content_to_fill_bounds_ == is_scaling_needed)
+ return;
+
+ stretch_content_to_fill_bounds_ = is_scaling_needed;
+ NoteLayerPropertyChanged();
+}
+
void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) {
LayerImpl::PushPropertiesTo(layer);
SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer);
@@ -60,6 +68,7 @@ void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) {
layer_impl->SetSurfaceId(surface_id_);
layer_impl->SetSurfaceSize(surface_size_);
layer_impl->SetSurfaceScale(surface_scale_);
+ layer_impl->SetStretchContentToFillBounds(stretch_content_to_fill_bounds_);
}
void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass,
@@ -68,7 +77,20 @@ void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass,
SharedQuadState* shared_quad_state =
render_pass->CreateAndAppendSharedQuadState();
- PopulateScaledSharedQuadState(shared_quad_state, surface_scale_);
+
+ if (stretch_content_to_fill_bounds_) {
+ // It is possible that the surface size and its layer bounds are changed
danakj 2016/12/15 16:13:14 I think this could be more clear on its intent. Wh
danakj 2016/12/16 14:30:44 "Strecthes" => "Stretches"
+ // changed differently on width and height. In this case, we apply a
+ // corresponding transform on the shared_quad_state.
+ float scale_x =
+ static_cast<float>(surface_size_.width()) / bounds().width();
+ float scale_y =
+ static_cast<float>(surface_size_.height()) / bounds().height();
+ PopulateScaledSharedQuadState(shared_quad_state, scale_x, scale_y);
+ } else {
+ PopulateScaledSharedQuadState(shared_quad_state, surface_scale_,
+ surface_scale_);
+ }
if (!surface_id_.is_valid())
return;
@@ -77,6 +99,7 @@ void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass,
gfx::Rect visible_quad_rect =
draw_properties().occlusion_in_content_space.GetUnoccludedContentRect(
quad_rect);
+
if (visible_quad_rect.IsEmpty())
return;
SurfaceDrawQuad* quad =

Powered by Google App Engine
This is Rietveld 408576698