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

Unified Diff: cc/resources/clip_display_item.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 | « cc/resources/clip_display_item.h ('k') | cc/resources/display_item.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/clip_display_item.cc
diff --git a/cc/resources/clip_display_item.cc b/cc/resources/clip_display_item.cc
new file mode 100644
index 0000000000000000000000000000000000000000..731c6059122df0930ce340ad894ad464a5242175
--- /dev/null
+++ b/cc/resources/clip_display_item.cc
@@ -0,0 +1,74 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/resources/clip_display_item.h"
+
+#include "third_party/skia/include/core/SkCanvas.h"
+
+namespace cc {
+
+ClipDisplayItem::ClipDisplayItem(gfx::Rect clip_rect,
+ const std::vector<SkRRect>& rounded_clip_rects)
+ : clip_rect_(clip_rect), rounded_clip_rects_(rounded_clip_rects) {
+}
+
+ClipDisplayItem::~ClipDisplayItem() {
+}
+
+void ClipDisplayItem::Raster(SkCanvas* canvas,
+ SkDrawPictureCallback* callback) const {
+ canvas->save();
+ canvas->clipRect(SkRect::MakeXYWH(clip_rect_.x(), clip_rect_.y(),
+ clip_rect_.width(), clip_rect_.height()));
+ for (size_t i = 0; i < rounded_clip_rects_.size(); ++i) {
+ if (rounded_clip_rects_[i].isRect()) {
+ canvas->clipRect(rounded_clip_rects_[i].rect());
+ } else {
+ bool antialiased = true;
+ canvas->clipRRect(rounded_clip_rects_[i], SkRegion::kIntersect_Op,
+ antialiased);
+ }
+ }
+}
+
+bool ClipDisplayItem::IsSuitableForGpuRasterization() const {
+ return true;
+}
+
+int ClipDisplayItem::ApproximateOpCount() const {
+ return 1;
+}
+
+size_t ClipDisplayItem::PictureMemoryUsage() const {
+ size_t total_size = sizeof(gfx::Rect);
+ for (size_t i = 0; i < rounded_clip_rects_.size(); ++i) {
+ total_size += sizeof(rounded_clip_rects_[i]);
+ }
+ return total_size;
+}
+
+EndClipDisplayItem::EndClipDisplayItem() {
+}
+
+EndClipDisplayItem::~EndClipDisplayItem() {
+}
+
+void EndClipDisplayItem::Raster(SkCanvas* canvas,
+ SkDrawPictureCallback* callback) const {
+ canvas->restore();
+}
+
+bool EndClipDisplayItem::IsSuitableForGpuRasterization() const {
+ return true;
+}
+
+int EndClipDisplayItem::ApproximateOpCount() const {
+ return 0;
+}
+
+size_t EndClipDisplayItem::PictureMemoryUsage() const {
+ return 0;
+}
+
+} // namespace cc
« no previous file with comments | « cc/resources/clip_display_item.h ('k') | cc/resources/display_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698