| Index: ui/compositor/paint_context.cc
|
| diff --git a/ui/compositor/paint_context.cc b/ui/compositor/paint_context.cc
|
| index 54a583d3ea1c1e9e583b5ca5a40aca00f47efa4e..07303f9c96fe56c3390a2c4d0690a5ce07722314 100644
|
| --- a/ui/compositor/paint_context.cc
|
| +++ b/ui/compositor/paint_context.cc
|
| @@ -5,6 +5,9 @@
|
| #include "ui/compositor/paint_context.h"
|
|
|
| #include "ui/gfx/canvas.h"
|
| +#include "ui/gfx/geometry/vector2d_f.h"
|
| +
|
| +#include "base/debug/stack_trace.h"
|
|
|
| namespace ui {
|
|
|
| @@ -14,8 +17,9 @@ PaintContext::PaintContext(cc::DisplayItemList* list,
|
| : list_(list),
|
| owned_recorder_(new cc::PaintRecorder),
|
| recorder_(owned_recorder_.get()),
|
| - device_scale_factor_(device_scale_factor),
|
| - invalidation_(invalidation) {
|
| + invalidation_(
|
| + gfx::ScaleToEnclosingRect(invalidation, device_scale_factor)),
|
| + device_scale_factor_(device_scale_factor) {
|
| #if DCHECK_IS_ON()
|
| root_visited_ = nullptr;
|
| inside_paint_recorder_ = false;
|
| @@ -27,9 +31,9 @@ PaintContext::PaintContext(const PaintContext& other,
|
| : list_(other.list_),
|
| owned_recorder_(nullptr),
|
| recorder_(other.recorder_),
|
| - device_scale_factor_(other.device_scale_factor_),
|
| invalidation_(other.invalidation_),
|
| - offset_(other.offset_ + offset) {
|
| + offset_(other.offset_ + offset),
|
| + device_scale_factor_(other.device_scale_factor_) {
|
| #if DCHECK_IS_ON()
|
| root_visited_ = other.root_visited_;
|
| inside_paint_recorder_ = other.inside_paint_recorder_;
|
| @@ -41,9 +45,9 @@ PaintContext::PaintContext(const PaintContext& other,
|
| : list_(other.list_),
|
| owned_recorder_(nullptr),
|
| recorder_(other.recorder_),
|
| - device_scale_factor_(other.device_scale_factor_),
|
| invalidation_(),
|
| - offset_(other.offset_) {
|
| + offset_(other.offset_),
|
| + device_scale_factor_(other.device_scale_factor_) {
|
| #if DCHECK_IS_ON()
|
| root_visited_ = other.root_visited_;
|
| inside_paint_recorder_ = other.inside_paint_recorder_;
|
| @@ -53,6 +57,52 @@ PaintContext::PaintContext(const PaintContext& other,
|
| PaintContext::~PaintContext() {
|
| }
|
|
|
| +gfx::Vector2dF PaintContext::CanvasScale() const {
|
| + return gfx::Vector2dF(
|
| + (float)(pixel_size_.width()) / size_.width(),
|
| + (float)(pixel_size_.height()) / size_.height());
|
| +}
|
| +
|
| +gfx::Rect PaintContext::GetPixelBounds(const gfx::Rect& child_bounds) const {
|
| + float dsf = device_scale_factor();
|
| +
|
| + int right = child_bounds.x() + child_bounds.width();
|
| + int bottom = child_bounds.y() + child_bounds.height();
|
| +
|
| + int new_x = std::round(child_bounds.x() * dsf);
|
| + int new_y = std::round(child_bounds.y() * dsf);
|
| +
|
| + int new_right;
|
| + int new_bottom;
|
| +
|
| + if (right == size_.width()) {
|
| + new_right = pixel_size_.width();
|
| + } else {
|
| + new_right = std::round(right * dsf);
|
| + }
|
| + if (bottom == size_.height()) {
|
| + new_bottom = pixel_size_.height();
|
| + } else {
|
| + new_bottom = std::round(bottom * dsf);
|
| + }
|
| + return gfx::Rect(new_x, new_y, new_right - new_x, new_bottom - new_y);
|
| +
|
| +}
|
| +
|
| +void PaintContext::UpdateSizeAndDSF(const gfx::Size& pixel_size,
|
| + const gfx::Size& size) {
|
| + pixel_size_ = pixel_size;
|
| + size_ = size;
|
| + /*
|
| + device_scale_factor_x_ = (float)pixel_size.width() / (float)size.width();
|
| + device_scale_factor_y_ = (float)pixel_size.height() / (float)size.height();
|
| + LOG(ERROR) << "UpdateSize:" << device_scale_factor_x_;
|
| + if (device_scale_factor_x_ == 1.25) {
|
| + base::debug::StackTrace().Print();
|
| + }
|
| + */
|
| +}
|
| +
|
| gfx::Rect PaintContext::ToLayerSpaceBounds(
|
| const gfx::Size& size_in_context) const {
|
| return gfx::Rect(size_in_context) + offset_;
|
|
|