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

Unified Diff: ui/compositor/clip_transform_recorder.cc

Issue 1133923002: ui: Replace std::vector with a simple array in ClipTransformRecorder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months 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
« no previous file with comments | « ui/compositor/clip_transform_recorder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/clip_transform_recorder.cc
diff --git a/ui/compositor/clip_transform_recorder.cc b/ui/compositor/clip_transform_recorder.cc
index d5687b2101bebd35a1d06c0bb10b89f1b49c693e..042a41b45b7c9456476920bde088f7ba1bfe8306 100644
--- a/ui/compositor/clip_transform_recorder.cc
+++ b/ui/compositor/clip_transform_recorder.cc
@@ -4,6 +4,7 @@
#include "ui/compositor/clip_transform_recorder.h"
+#include "base/logging.h"
#include "cc/resources/clip_display_item.h"
#include "cc/resources/clip_path_display_item.h"
#include "cc/resources/display_item_list.h"
@@ -15,13 +16,13 @@
namespace ui {
ClipTransformRecorder::ClipTransformRecorder(const PaintContext& context)
- : context_(context) {
+ : context_(context), num_closers_(0) {
}
ClipTransformRecorder::~ClipTransformRecorder() {
if (context_.list_) {
- for (Closer c : closers_) {
- switch (c) {
+ for (size_t i = 0; i < num_closers_; ++i) {
+ switch (closers_[i]) {
case CLIP_RECT:
context_.list_->CreateAndAppendItem<cc::EndClipDisplayItem>();
break;
@@ -33,7 +34,7 @@ ClipTransformRecorder::~ClipTransformRecorder() {
break;
}
}
- } else if (!closers_.empty()) {
+ } else if (num_closers_) {
context_.canvas_->Restore();
}
}
@@ -43,11 +44,12 @@ void ClipTransformRecorder::ClipRect(const gfx::Rect& clip_rect) {
auto* item = context_.list_->CreateAndAppendItem<cc::ClipDisplayItem>();
item->SetNew(clip_rect, std::vector<SkRRect>());
} else {
- if (closers_.empty())
+ if (!num_closers_)
context_.canvas_->Save();
context_.canvas_->ClipRect(clip_rect);
}
- closers_.push_back(CLIP_RECT);
+ DCHECK_LT(num_closers_, arraysize(closers_));
sky 2015/05/09 15:02:34 nit: maybe inline this in the header, eg: void ad
danakj 2015/05/10 03:13:16 I did that at first but I kinda dislike dchecks in
+ closers_[num_closers_++] = CLIP_RECT;
}
void ClipTransformRecorder::ClipPath(const gfx::Path& clip_path) {
@@ -56,11 +58,12 @@ void ClipTransformRecorder::ClipPath(const gfx::Path& clip_path) {
auto* item = context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>();
item->SetNew(clip_path, SkRegion::kIntersect_Op, anti_alias);
} else {
- if (closers_.empty())
+ if (!num_closers_)
context_.canvas_->Save();
context_.canvas_->ClipPath(clip_path, anti_alias);
}
- closers_.push_back(CLIP_PATH);
+ DCHECK_LT(num_closers_, arraysize(closers_));
+ closers_[num_closers_++] = CLIP_PATH;
}
void ClipTransformRecorder::ClipPathWithAntiAliasing(
@@ -70,11 +73,12 @@ void ClipTransformRecorder::ClipPathWithAntiAliasing(
auto* item = context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>();
item->SetNew(clip_path, SkRegion::kIntersect_Op, anti_alias);
} else {
- if (closers_.empty())
+ if (!num_closers_)
context_.canvas_->Save();
context_.canvas_->ClipPath(clip_path, anti_alias);
}
- closers_.push_back(CLIP_PATH);
+ DCHECK_LT(num_closers_, arraysize(closers_));
+ closers_[num_closers_++] = CLIP_PATH;
}
void ClipTransformRecorder::Transform(const gfx::Transform& transform) {
@@ -83,11 +87,12 @@ void ClipTransformRecorder::Transform(const gfx::Transform& transform) {
context_.list_->CreateAndAppendItem<cc::TransformDisplayItem>();
item->SetNew(transform);
} else {
- if (closers_.empty())
+ if (!num_closers_)
context_.canvas_->Save();
context_.canvas_->Transform(transform);
}
- closers_.push_back(TRANSFORM);
+ DCHECK_LT(num_closers_, arraysize(closers_));
+ closers_[num_closers_++] = TRANSFORM;
}
} // namespace ui
« no previous file with comments | « ui/compositor/clip_transform_recorder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698