| Index: ui/compositor/clip_transform_recorder.cc
|
| diff --git a/ui/compositor/clip_transform_recorder.cc b/ui/compositor/clip_transform_recorder.cc
|
| index ddc70d15ea2a32f65cf4adc839555bf9e51abee2..4c74129fdbebba5ca17ba83466d8f8c6c1f4d01e 100644
|
| --- a/ui/compositor/clip_transform_recorder.cc
|
| +++ b/ui/compositor/clip_transform_recorder.cc
|
| @@ -11,32 +11,40 @@
|
| #include "cc/playback/transform_display_item.h"
|
| #include "ui/compositor/paint_context.h"
|
| #include "ui/gfx/canvas.h"
|
| +#include "ui/gfx/geometry/rect.h"
|
| #include "ui/gfx/path.h"
|
|
|
| namespace ui {
|
|
|
| -ClipTransformRecorder::ClipTransformRecorder(const PaintContext& context)
|
| - : context_(context), num_closers_(0) {
|
| -}
|
| +ClipTransformRecorder::ClipTransformRecorder(const PaintContext& context,
|
| + const gfx::Size& layer_size)
|
| + : context_(context),
|
| + layer_bounds_(context.ToLayerSpaceBounds(layer_size)),
|
| + num_closers_(0) {}
|
|
|
| ClipTransformRecorder::~ClipTransformRecorder() {
|
| for (size_t i = 0; i < num_closers_; ++i) {
|
| switch (closers_[i]) {
|
| case CLIP_RECT:
|
| - context_.list_->CreateAndAppendItem<cc::EndClipDisplayItem>();
|
| + context_.list_->CreateAndAppendItem<cc::EndClipDisplayItem>(
|
| + layer_bounds_);
|
| break;
|
| case CLIP_PATH:
|
| - context_.list_->CreateAndAppendItem<cc::EndClipPathDisplayItem>();
|
| + context_.list_->CreateAndAppendItem<cc::EndClipPathDisplayItem>(
|
| + layer_bounds_);
|
| break;
|
| case TRANSFORM:
|
| - context_.list_->CreateAndAppendItem<cc::EndTransformDisplayItem>();
|
| + context_.list_->CreateAndAppendItem<cc::EndTransformDisplayItem>(
|
| + layer_bounds_);
|
| break;
|
| }
|
| }
|
| }
|
|
|
| void ClipTransformRecorder::ClipRect(const gfx::Rect& clip_rect) {
|
| - auto* item = context_.list_->CreateAndAppendItem<cc::ClipDisplayItem>();
|
| + gfx::Rect clip_in_layer_space = clip_rect + context_.offset_;
|
| + auto* item = context_.list_->CreateAndAppendItem<cc::ClipDisplayItem>(
|
| + clip_in_layer_space);
|
| item->SetNew(clip_rect, std::vector<SkRRect>());
|
| DCHECK_LT(num_closers_, arraysize(closers_));
|
| closers_[num_closers_++] = CLIP_RECT;
|
| @@ -44,7 +52,9 @@ void ClipTransformRecorder::ClipRect(const gfx::Rect& clip_rect) {
|
|
|
| void ClipTransformRecorder::ClipPath(const gfx::Path& clip_path) {
|
| bool anti_alias = false;
|
| - auto* item = context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>();
|
| + // As a further optimization, consider passing a more granular visual rect.
|
| + auto* item = context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>(
|
| + layer_bounds_);
|
| item->SetNew(clip_path, SkRegion::kIntersect_Op, anti_alias);
|
| DCHECK_LT(num_closers_, arraysize(closers_));
|
| closers_[num_closers_++] = CLIP_PATH;
|
| @@ -53,14 +63,17 @@ void ClipTransformRecorder::ClipPath(const gfx::Path& clip_path) {
|
| void ClipTransformRecorder::ClipPathWithAntiAliasing(
|
| const gfx::Path& clip_path) {
|
| bool anti_alias = true;
|
| - auto* item = context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>();
|
| + // As a further optimization, consider passing a more granular visual rect.
|
| + auto* item = context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>(
|
| + layer_bounds_);
|
| item->SetNew(clip_path, SkRegion::kIntersect_Op, anti_alias);
|
| DCHECK_LT(num_closers_, arraysize(closers_));
|
| closers_[num_closers_++] = CLIP_PATH;
|
| }
|
|
|
| void ClipTransformRecorder::Transform(const gfx::Transform& transform) {
|
| - auto* item = context_.list_->CreateAndAppendItem<cc::TransformDisplayItem>();
|
| + auto* item = context_.list_->CreateAndAppendItem<cc::TransformDisplayItem>(
|
| + layer_bounds_);
|
| item->SetNew(transform);
|
| DCHECK_LT(num_closers_, arraysize(closers_));
|
| closers_[num_closers_++] = TRANSFORM;
|
|
|