| 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 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/trace_event/trace_event_argument.h" | 13 #include "base/trace_event/trace_event_argument.h" |
| 14 #include "cc/proto/display_item.pb.h" | 14 #include "cc/proto/display_item.pb.h" |
| 15 #include "cc/proto/gfx_conversions.h" | 15 #include "cc/proto/gfx_conversions.h" |
| 16 #include "cc/proto/skia_conversions.h" | 16 #include "cc/proto/skia_conversions.h" |
| 17 #include "third_party/skia/include/core/SkCanvas.h" | |
| 18 #include "ui/gfx/skia_util.h" | 17 #include "ui/gfx/skia_util.h" |
| 19 | 18 |
| 20 namespace cc { | 19 namespace cc { |
| 21 class ImageSerializationProcessor; | 20 class ImageSerializationProcessor; |
| 22 | 21 |
| 23 ClipDisplayItem::ClipDisplayItem(const gfx::Rect& clip_rect, | 22 ClipDisplayItem::ClipDisplayItem(const gfx::Rect& clip_rect, |
| 24 const std::vector<SkRRect>& rounded_clip_rects, | 23 const std::vector<SkRRect>& rounded_clip_rects, |
| 25 bool antialias) | 24 bool antialias) |
| 26 : DisplayItem(CLIP) { | 25 : DisplayItem(CLIP) { |
| 27 SetNew(clip_rect, rounded_clip_rects, antialias); | 26 SetNew(clip_rect, rounded_clip_rects, antialias); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 57 | 56 |
| 58 proto::ClipDisplayItem* details = proto->mutable_clip_item(); | 57 proto::ClipDisplayItem* details = proto->mutable_clip_item(); |
| 59 RectToProto(clip_rect_, details->mutable_clip_rect()); | 58 RectToProto(clip_rect_, details->mutable_clip_rect()); |
| 60 DCHECK_EQ(0, details->rounded_rects_size()); | 59 DCHECK_EQ(0, details->rounded_rects_size()); |
| 61 for (const auto& rrect : rounded_clip_rects_) { | 60 for (const auto& rrect : rounded_clip_rects_) { |
| 62 SkRRectToProto(rrect, details->add_rounded_rects()); | 61 SkRRectToProto(rrect, details->add_rounded_rects()); |
| 63 } | 62 } |
| 64 details->set_antialias(antialias_); | 63 details->set_antialias(antialias_); |
| 65 } | 64 } |
| 66 | 65 |
| 67 void ClipDisplayItem::Raster(SkCanvas* canvas, | 66 void ClipDisplayItem::Raster(PaintCanvas* canvas, |
| 68 SkPicture::AbortCallback* callback) const { | 67 PaintRecord::AbortCallback* callback) const { |
| 69 canvas->save(); | 68 canvas->save(); |
| 70 canvas->clipRect(gfx::RectToSkRect(clip_rect_), antialias_); | 69 canvas->clipRect(gfx::RectToSkRect(clip_rect_), antialias_); |
| 71 for (size_t i = 0; i < rounded_clip_rects_.size(); ++i) { | 70 for (size_t i = 0; i < rounded_clip_rects_.size(); ++i) { |
| 72 if (rounded_clip_rects_[i].isRect()) { | 71 if (rounded_clip_rects_[i].isRect()) { |
| 73 canvas->clipRect(rounded_clip_rects_[i].rect(), antialias_); | 72 canvas->clipRect(rounded_clip_rects_[i].rect(), antialias_); |
| 74 } else { | 73 } else { |
| 75 canvas->clipRRect(rounded_clip_rects_[i], antialias_); | 74 canvas->clipRRect(rounded_clip_rects_[i], antialias_); |
| 76 } | 75 } |
| 77 } | 76 } |
| 78 } | 77 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 DCHECK_EQ(proto::DisplayItem::Type_EndClip, proto.type()); | 111 DCHECK_EQ(proto::DisplayItem::Type_EndClip, proto.type()); |
| 113 } | 112 } |
| 114 | 113 |
| 115 EndClipDisplayItem::~EndClipDisplayItem() { | 114 EndClipDisplayItem::~EndClipDisplayItem() { |
| 116 } | 115 } |
| 117 | 116 |
| 118 void EndClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 117 void EndClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
| 119 proto->set_type(proto::DisplayItem::Type_EndClip); | 118 proto->set_type(proto::DisplayItem::Type_EndClip); |
| 120 } | 119 } |
| 121 | 120 |
| 122 void EndClipDisplayItem::Raster(SkCanvas* canvas, | 121 void EndClipDisplayItem::Raster(PaintCanvas* canvas, |
| 123 SkPicture::AbortCallback* callback) const { | 122 PaintRecord::AbortCallback* callback) const { |
| 124 canvas->restore(); | 123 canvas->restore(); |
| 125 } | 124 } |
| 126 | 125 |
| 127 void EndClipDisplayItem::AsValueInto( | 126 void EndClipDisplayItem::AsValueInto( |
| 128 const gfx::Rect& visual_rect, | 127 const gfx::Rect& visual_rect, |
| 129 base::trace_event::TracedValue* array) const { | 128 base::trace_event::TracedValue* array) const { |
| 130 array->AppendString(base::StringPrintf("EndClipDisplayItem visualRect: [%s]", | 129 array->AppendString(base::StringPrintf("EndClipDisplayItem visualRect: [%s]", |
| 131 visual_rect.ToString().c_str())); | 130 visual_rect.ToString().c_str())); |
| 132 } | 131 } |
| 133 | 132 |
| 134 } // namespace cc | 133 } // namespace cc |
| OLD | NEW |