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

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 Created 4 years, 1 month 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..3f35e78ace14d1066b519d1c52317c8b25e3b3bd 100644
--- a/cc/layers/surface_layer_impl.cc
+++ b/cc/layers/surface_layer_impl.cc
@@ -16,7 +16,9 @@
namespace cc {
SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id)
- : LayerImpl(tree_impl, id), surface_scale_(0.f) {
+ : LayerImpl(tree_impl, id),
+ surface_scale_(0.f),
danakj 2016/11/28 22:26:22 can you move both of these to the .h
xlai (Olivia) 2016/12/13 17:29:18 Done.
+ scale_layer_bounds_with_surface_size_(false) {
layer_tree_impl()->AddSurfaceLayer(this);
}
@@ -53,6 +55,14 @@ void SurfaceLayerImpl::SetSurfaceSize(const gfx::Size& size) {
NoteLayerPropertyChanged();
}
+void SurfaceLayerImpl::SetScaleLayerBoundsWithSurfaceSize(
+ bool is_scaling_needed) {
+ if (scale_layer_bounds_with_surface_size_ == is_scaling_needed)
+ return;
+
+ scale_layer_bounds_with_surface_size_ = is_scaling_needed;
danakj 2016/11/28 22:26:22 You should NoteLayerPropertyChanged() when somethi
xlai (Olivia) 2016/12/13 17:29:18 Done.
+}
+
void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) {
LayerImpl::PushPropertiesTo(layer);
SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer);
@@ -60,6 +70,8 @@ void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) {
layer_impl->SetSurfaceId(surface_id_);
layer_impl->SetSurfaceSize(surface_size_);
layer_impl->SetSurfaceScale(surface_scale_);
+ layer_impl->SetScaleLayerBoundsWithSurfaceSize(
+ scale_layer_bounds_with_surface_size_);
}
void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass,
@@ -68,7 +80,18 @@ void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass,
SharedQuadState* shared_quad_state =
render_pass->CreateAndAppendSharedQuadState();
- PopulateScaledSharedQuadState(shared_quad_state, surface_scale_);
+
+ if (scale_layer_bounds_with_surface_size_) {
+ // When a DOM element's size in CSS style is changed and it is using
danakj 2016/11/28 22:26:22 DOM and CSS are foreign concepts to cc/ so can you
xlai (Olivia) 2016/12/13 17:29:18 Done.
+ // SurfaceLayer, it is possible that its layer bounds and surface_size
+ // are changed differently on width and height. In this case, we apply a
+ // corresponding transform on the shared_quad_state.
+ float scale_x = ((float)surface_size_.width()) / bounds().width();
danakj 2016/11/28 22:26:22 static_cast, not c-style cast
xlai (Olivia) 2016/12/13 17:29:18 Done.
+ float scale_y = ((float)surface_size_.height()) / bounds().height();
+ PopulateScaledSharedQuadState(shared_quad_state, scale_x, scale_y);
+ } else {
+ PopulateScaledSharedQuadState(shared_quad_state, surface_scale_);
+ }
if (!surface_id_.is_valid())
return;
@@ -77,6 +100,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