diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-03 13:42:47 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-15 10:27:51 +0000 |
commit | 8c5c43c7b138c9b4b0bf56d946e61d3bbc111bec (patch) | |
tree | d29d987c4d7b173cf853279b79a51598f104b403 /chromium/cc/layers/picture_image_layer.cc | |
parent | 830c9e163d31a9180fadca926b3e1d7dfffb5021 (diff) |
BASELINE: Update Chromium to 66.0.3359.156
Change-Id: I0c9831ad39911a086b6377b16f995ad75a51e441
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'chromium/cc/layers/picture_image_layer.cc')
-rw-r--r-- | chromium/cc/layers/picture_image_layer.cc | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/chromium/cc/layers/picture_image_layer.cc b/chromium/cc/layers/picture_image_layer.cc index b0c06b84cae..203a8a612d1 100644 --- a/chromium/cc/layers/picture_image_layer.cc +++ b/chromium/cc/layers/picture_image_layer.cc @@ -35,15 +35,21 @@ bool PictureImageLayer::HasDrawableContent() const { return image_ && PictureLayer::HasDrawableContent(); } -void PictureImageLayer::SetImage(PaintImage image) { +void PictureImageLayer::SetImage(PaintImage image, + const SkMatrix& matrix, + bool uses_width_as_height) { // SetImage() currently gets called whenever there is any // style change that affects the layer even if that change doesn't // affect the actual contents of the image (e.g. a CSS animation). // With this check in place we avoid unecessary texture uploads. - if (image_ == image) + if (image_ == image && matrix_ == matrix && + uses_width_as_height_ == uses_width_as_height) { return; + } image_ = std::move(image); + matrix_ = matrix; + uses_width_as_height_ = uses_width_as_height; UpdateDrawsContent(HasDrawableContent()); SetNeedsDisplay(); } @@ -59,29 +65,40 @@ scoped_refptr<DisplayItemList> PictureImageLayer::PaintContentsToDisplayList( DCHECK_GT(image_.height(), 0); DCHECK(layer_tree_host()); - float content_to_layer_scale_x = - static_cast<float>(bounds().width()) / image_.width(); + int width = uses_width_as_height_ ? image_.height() : image_.width(); + int height = uses_width_as_height_ ? image_.width() : image_.height(); + + float content_to_layer_scale_x = static_cast<float>(bounds().width()) / width; float content_to_layer_scale_y = - static_cast<float>(bounds().height()) / image_.height(); + static_cast<float>(bounds().height()) / height; + bool has_scale = !MathUtil::IsWithinEpsilon(content_to_layer_scale_x, 1.f) || !MathUtil::IsWithinEpsilon(content_to_layer_scale_y, 1.f); + bool needs_save = has_scale || !matrix_.isIdentity(); auto display_list = base::MakeRefCounted<DisplayItemList>(); display_list->StartPaint(); - if (has_scale) { + + if (needs_save) display_list->push<SaveOp>(); + + if (has_scale) { display_list->push<ScaleOp>(content_to_layer_scale_x, content_to_layer_scale_y); } + if (!matrix_.isIdentity()) + display_list->push<ConcatOp>(matrix_); + // Because Android WebView resourceless software draw mode rasters directly // to the root canvas, this draw must use the SkBlendMode::kSrcOver so that // transparent images blend correctly. display_list->push<DrawImageOp>(image_, 0.f, 0.f, nullptr); - if (has_scale) + if (needs_save) display_list->push<RestoreOp>(); + display_list->EndPaintOfUnpaired(PaintableRegion()); display_list->Finalize(); return display_list; |