| Index: ui/compositor/paint_context.h
|
| diff --git a/ui/compositor/paint_context.h b/ui/compositor/paint_context.h
|
| index bc17c50f46bd3b00cee3ce9e83229b04704d12a9..1e58269b51fe5b89c71563589d6ec1d2e9db226f 100644
|
| --- a/ui/compositor/paint_context.h
|
| +++ b/ui/compositor/paint_context.h
|
| @@ -25,14 +25,29 @@ class TransformRecorder;
|
|
|
| class COMPOSITOR_EXPORT PaintContext {
|
| public:
|
| - // Construct a PaintContext that may only re-paint the area in the
|
| - // |invalidation|.
|
| + enum class ScaleType {
|
| + // Scales the context by the default dsf. Use this if you dont want any form
|
| + // of distortion during scaling.
|
| + SCALE_TO_SCALE_FACTOR = 0,
|
| +
|
| + // Scales the context based on the effective dsf. This may lead to minor
|
| + // distortion during scaling.
|
| + SCALE_TO_FIT
|
| + };
|
| +
|
| + // Construct a PaintContext of given size that may only re-paint the area in
|
| + // the |invalidation|.
|
| PaintContext(cc::DisplayItemList* list,
|
| float device_scale_factor,
|
| - const gfx::Rect& invalidation);
|
| + const gfx::Rect& invalidation,
|
| + const gfx::Size& size);
|
|
|
| - // Clone a PaintContext with an additional |offset|.
|
| - PaintContext(const PaintContext& other, const gfx::Vector2d& offset);
|
| + // Clone a PaintContext with different |bounds| that has some offset from its
|
| + // parent.
|
| + PaintContext(const PaintContext& other,
|
| + const gfx::Rect& bounds,
|
| + const gfx::Rect& parent_bounds,
|
| + ScaleType scale_type);
|
|
|
| // Clone a PaintContext that has no consideration for invalidation.
|
| enum CloneWithoutInvalidation {
|
| @@ -42,16 +57,16 @@ class COMPOSITOR_EXPORT PaintContext {
|
|
|
| ~PaintContext();
|
|
|
| - // When true, IsRectInvalid() can be called, otherwise its result would be
|
| + // When true, ShouldRepaint() can be called, otherwise its result would be
|
| // invalid.
|
| - bool CanCheckInvalid() const { return !invalidation_.IsEmpty(); }
|
| -
|
| - // When true, the |bounds| touches an invalidated area, so should be
|
| - // re-painted. When false, re-painting can be skipped. Bounds should be in
|
| - // the local space with offsets up to the painting root in the PaintContext.
|
| - bool IsRectInvalid(const gfx::Rect& bounds) const {
|
| - DCHECK(CanCheckInvalid());
|
| - return invalidation_.Intersects(bounds + offset_);
|
| + bool CanCheckRepaint() const { return !invalidation_.IsEmpty(); }
|
| +
|
| + // When true, the |paint_recording_bounds_| touches an invalidated area, so
|
| + // should be re-painted. When false, re-painting can be skipped.
|
| + bool ShouldRepaint() const {
|
| + DCHECK(CanCheckRepaint());
|
| + return invalidation_.Intersects(gfx::Rect(paint_recording_size()) +
|
| + offset_);
|
| }
|
|
|
| #if DCHECK_IS_ON()
|
| @@ -65,6 +80,19 @@ class COMPOSITOR_EXPORT PaintContext {
|
|
|
| const gfx::Rect& InvalidationForTesting() const { return invalidation_; }
|
|
|
| + bool IsPixelCanvas() const;
|
| +
|
| + const gfx::Size& paint_recording_size() const {
|
| + return paint_recording_bounds_.size();
|
| + }
|
| + const gfx::Rect& paint_recording_bounds() const {
|
| + return paint_recording_bounds_;
|
| + }
|
| +
|
| + // A tranform that converts a given cooridinate from local DIP coordinates to
|
| + // the parent paint recording coordinates.
|
| + gfx::Transform TransformToParentRecordingSpace() const;
|
| +
|
| private:
|
| // The Recorder classes need access to the internal canvas and friends, but we
|
| // don't want to expose them on this class so that people must go through the
|
| @@ -84,16 +112,39 @@ class COMPOSITOR_EXPORT PaintContext {
|
| // Returns the given rect translated by the layer space offset.
|
| gfx::Rect ToLayerSpaceRect(const gfx::Rect& rect) const;
|
|
|
| + // Given the DIP |size|, this function updates the paint recording scales.
|
| + void ComputePaintRecordingScales(const gfx::Size& size);
|
| +
|
| + // Scales the |child_bounds| to its recording bounds based on the
|
| + // |device_scale_factor_|. The recording bounds are snapped to the
|
| + // |parent bound|'s right and/or bottom edge if required.
|
| + // This function returns |child_bounds| as is if pixel canvas is disabled.
|
| + gfx::Rect GetSnappedRecordingBounds(const gfx::Rect& parent_bounds,
|
| + const gfx::Rect& child_bounds) const;
|
| +
|
| cc::DisplayItemList* list_;
|
| // The device scale of the frame being painted. Used to determine which bitmap
|
| // resources to use in the frame.
|
| float device_scale_factor_;
|
| + // The scale at which the paint commands are recorded at. Due to the decimal
|
| + // rounding during scaling operations, the effective paint recording scale may
|
| + // end up being slightly different between the x and y axis.
|
| + float paint_recording_scale_x_;
|
| + float paint_recording_scale_y_;
|
| // Invalidation in the space of the paint root (ie the space of the layer
|
| - // backing the paint taking place).
|
| + // backing the paint taking place). This is in pixel size if pixel canvas is
|
| + // enabled.
|
| gfx::Rect invalidation_;
|
| + // Paint Recording bounds for this paint context. The offset is relative to
|
| + // its parent paint context. To get offset relative to the paint root, use
|
| + // |offset_|.
|
| + const gfx::Rect paint_recording_bounds_;
|
| // Offset from the PaintContext to the space of the paint root and the
|
| - // |invalidation_|.
|
| + // |invalidation_|. This is in pixels if pixel canvas is enabled.
|
| gfx::Vector2d offset_;
|
| + // The |scale_type| tells the context how it needs to perform scaling when
|
| + // pixel canvas is enabled.
|
| + ScaleType scale_type_ = ScaleType::SCALE_TO_SCALE_FACTOR;
|
|
|
| #if DCHECK_IS_ON()
|
| // Used to verify that the |invalidation_| is only used to compare against
|
|
|