| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/playback/clip_display_item.h" | 5 #include "cc/playback/clip_display_item.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 canvas->clipRect(gfx::RectToSkRect(clip_rect_), antialias_); | 40 canvas->clipRect(gfx::RectToSkRect(clip_rect_), antialias_); |
| 41 for (size_t i = 0; i < rounded_clip_rects_.size(); ++i) { | 41 for (size_t i = 0; i < rounded_clip_rects_.size(); ++i) { |
| 42 if (rounded_clip_rects_[i].isRect()) { | 42 if (rounded_clip_rects_[i].isRect()) { |
| 43 canvas->clipRect(rounded_clip_rects_[i].rect(), antialias_); | 43 canvas->clipRect(rounded_clip_rects_[i].rect(), antialias_); |
| 44 } else { | 44 } else { |
| 45 canvas->clipRRect(rounded_clip_rects_[i], antialias_); | 45 canvas->clipRRect(rounded_clip_rects_[i], antialias_); |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 void ClipDisplayItem::AsValueInto(const gfx::Rect& visual_rect, | |
| 51 base::trace_event::TracedValue* array) const { | |
| 52 std::string value = base::StringPrintf( | |
| 53 "ClipDisplayItem rect: [%s] visualRect: [%s]", | |
| 54 clip_rect_.ToString().c_str(), visual_rect.ToString().c_str()); | |
| 55 for (const SkRRect& rounded_rect : rounded_clip_rects_) { | |
| 56 base::StringAppendF( | |
| 57 &value, " rounded_rect: [rect: [%s]", | |
| 58 gfx::SkRectToRectF(rounded_rect.rect()).ToString().c_str()); | |
| 59 base::StringAppendF(&value, " radii: ["); | |
| 60 SkVector upper_left_radius = rounded_rect.radii(SkRRect::kUpperLeft_Corner); | |
| 61 base::StringAppendF(&value, "[%f,%f],", upper_left_radius.x(), | |
| 62 upper_left_radius.y()); | |
| 63 SkVector upper_right_radius = | |
| 64 rounded_rect.radii(SkRRect::kUpperRight_Corner); | |
| 65 base::StringAppendF(&value, " [%f,%f],", upper_right_radius.x(), | |
| 66 upper_right_radius.y()); | |
| 67 SkVector lower_right_radius = | |
| 68 rounded_rect.radii(SkRRect::kLowerRight_Corner); | |
| 69 base::StringAppendF(&value, " [%f,%f],", lower_right_radius.x(), | |
| 70 lower_right_radius.y()); | |
| 71 SkVector lower_left_radius = rounded_rect.radii(SkRRect::kLowerLeft_Corner); | |
| 72 base::StringAppendF(&value, " [%f,%f]]", lower_left_radius.x(), | |
| 73 lower_left_radius.y()); | |
| 74 } | |
| 75 array->AppendString(value); | |
| 76 } | |
| 77 | |
| 78 EndClipDisplayItem::EndClipDisplayItem() : DisplayItem(END_CLIP) {} | 50 EndClipDisplayItem::EndClipDisplayItem() : DisplayItem(END_CLIP) {} |
| 79 | 51 |
| 80 EndClipDisplayItem::~EndClipDisplayItem() { | 52 EndClipDisplayItem::~EndClipDisplayItem() { |
| 81 } | 53 } |
| 82 | 54 |
| 83 void EndClipDisplayItem::Raster(SkCanvas* canvas, | 55 void EndClipDisplayItem::Raster(SkCanvas* canvas, |
| 84 SkPicture::AbortCallback* callback) const { | 56 SkPicture::AbortCallback* callback) const { |
| 85 canvas->restore(); | 57 canvas->restore(); |
| 86 } | 58 } |
| 87 | 59 |
| 88 void EndClipDisplayItem::AsValueInto( | |
| 89 const gfx::Rect& visual_rect, | |
| 90 base::trace_event::TracedValue* array) const { | |
| 91 array->AppendString(base::StringPrintf("EndClipDisplayItem visualRect: [%s]", | |
| 92 visual_rect.ToString().c_str())); | |
| 93 } | |
| 94 | |
| 95 } // namespace cc | 60 } // namespace cc |
| OLD | NEW |