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

Unified Diff: ui/compositor/clip_transform_recorder.cc

Issue 1423653005: Further plumb visual rect into cc:DisplayItemList. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: De-static const rect in test. Created 5 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: 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)
danakj 2015/11/17 22:14:33 IIRC when we'd talked about this, we discussed "la
wkorman 2015/11/17 23:43:04 Done.
+ : 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_;
danakj 2015/11/17 22:14:33 also i'd prefer adding a PaintContext method to co
danakj 2015/11/17 22:14:33 similar to this (with or without _space, but maybe
wkorman 2015/11/17 23:43:05 Added and made use of PaintContext::ToLayerSpaceRe
+ 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;

Powered by Google App Engine
This is Rietveld 408576698