| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/float_clip_display_item.h" | 5 #include "cc/playback/float_clip_display_item.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/trace_event/trace_event_argument.h" | 8 #include "base/trace_event/trace_event_argument.h" |
| 9 #include "cc/proto/display_item.pb.h" |
| 10 #include "cc/proto/gfx_conversions.h" |
| 9 #include "third_party/skia/include/core/SkCanvas.h" | 11 #include "third_party/skia/include/core/SkCanvas.h" |
| 10 #include "ui/gfx/skia_util.h" | 12 #include "ui/gfx/skia_util.h" |
| 11 | 13 |
| 12 namespace cc { | 14 namespace cc { |
| 13 | 15 |
| 14 FloatClipDisplayItem::FloatClipDisplayItem() { | 16 FloatClipDisplayItem::FloatClipDisplayItem() { |
| 15 } | 17 } |
| 16 | 18 |
| 17 FloatClipDisplayItem::~FloatClipDisplayItem() { | 19 FloatClipDisplayItem::~FloatClipDisplayItem() { |
| 18 } | 20 } |
| 19 | 21 |
| 20 void FloatClipDisplayItem::SetNew(const gfx::RectF& clip_rect) { | 22 void FloatClipDisplayItem::SetNew(const gfx::RectF& clip_rect) { |
| 21 clip_rect_ = clip_rect; | 23 clip_rect_ = clip_rect; |
| 22 | 24 |
| 23 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */, | 25 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */, |
| 24 0 /* external_memory_usage */); | 26 0 /* external_memory_usage */); |
| 25 } | 27 } |
| 26 | 28 |
| 29 void FloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) { |
| 30 proto->set_type(proto::DisplayItem::Type_FloatClip); |
| 31 |
| 32 proto::FloatClipDisplayItem* details = proto->mutable_details_float_clip(); |
| 33 RectFToProto(clip_rect_, details->mutable_clip_rect()); |
| 34 } |
| 35 |
| 36 void FloatClipDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { |
| 37 DCHECK_EQ(proto::DisplayItem::Type_FloatClip, proto.type()); |
| 38 |
| 39 const proto::FloatClipDisplayItem& details = proto.details_float_clip(); |
| 40 gfx::RectF clip_rect = ProtoToRectF(details.clip_rect()); |
| 41 |
| 42 SetNew(clip_rect); |
| 43 } |
| 44 |
| 27 void FloatClipDisplayItem::Raster(SkCanvas* canvas, | 45 void FloatClipDisplayItem::Raster(SkCanvas* canvas, |
| 28 const gfx::Rect& canvas_target_playback_rect, | 46 const gfx::Rect& canvas_target_playback_rect, |
| 29 SkPicture::AbortCallback* callback) const { | 47 SkPicture::AbortCallback* callback) const { |
| 30 canvas->save(); | 48 canvas->save(); |
| 31 canvas->clipRect(gfx::RectFToSkRect(clip_rect_)); | 49 canvas->clipRect(gfx::RectFToSkRect(clip_rect_)); |
| 32 } | 50 } |
| 33 | 51 |
| 34 void FloatClipDisplayItem::ProcessForBounds( | 52 void FloatClipDisplayItem::ProcessForBounds( |
| 35 DisplayItemListBoundsCalculator* calculator) const { | 53 DisplayItemListBoundsCalculator* calculator) const { |
| 36 calculator->AddStartingDisplayItem(); | 54 calculator->AddStartingDisplayItem(); |
| 37 } | 55 } |
| 38 | 56 |
| 39 void FloatClipDisplayItem::AsValueInto( | 57 void FloatClipDisplayItem::AsValueInto( |
| 40 base::trace_event::TracedValue* array) const { | 58 base::trace_event::TracedValue* array) const { |
| 41 array->AppendString(base::StringPrintf("FloatClipDisplayItem rect: [%s]", | 59 array->AppendString(base::StringPrintf("FloatClipDisplayItem rect: [%s]", |
| 42 clip_rect_.ToString().c_str())); | 60 clip_rect_.ToString().c_str())); |
| 43 } | 61 } |
| 44 | 62 |
| 45 EndFloatClipDisplayItem::EndFloatClipDisplayItem() { | 63 EndFloatClipDisplayItem::EndFloatClipDisplayItem() { |
| 46 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, | 64 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, |
| 47 0 /* external_memory_usage */); | 65 0 /* external_memory_usage */); |
| 48 } | 66 } |
| 49 | 67 |
| 50 EndFloatClipDisplayItem::~EndFloatClipDisplayItem() { | 68 EndFloatClipDisplayItem::~EndFloatClipDisplayItem() { |
| 51 } | 69 } |
| 52 | 70 |
| 71 void EndFloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) { |
| 72 proto->set_type(proto::DisplayItem::Type_EndFloatClip); |
| 73 } |
| 74 |
| 75 void EndFloatClipDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { |
| 76 DCHECK_EQ(proto::DisplayItem::Type_EndFloatClip, proto.type()); |
| 77 } |
| 78 |
| 53 void EndFloatClipDisplayItem::Raster( | 79 void EndFloatClipDisplayItem::Raster( |
| 54 SkCanvas* canvas, | 80 SkCanvas* canvas, |
| 55 const gfx::Rect& canvas_target_playback_rect, | 81 const gfx::Rect& canvas_target_playback_rect, |
| 56 SkPicture::AbortCallback* callback) const { | 82 SkPicture::AbortCallback* callback) const { |
| 57 canvas->restore(); | 83 canvas->restore(); |
| 58 } | 84 } |
| 59 | 85 |
| 60 void EndFloatClipDisplayItem::ProcessForBounds( | 86 void EndFloatClipDisplayItem::ProcessForBounds( |
| 61 DisplayItemListBoundsCalculator* calculator) const { | 87 DisplayItemListBoundsCalculator* calculator) const { |
| 62 calculator->AddEndingDisplayItem(); | 88 calculator->AddEndingDisplayItem(); |
| 63 } | 89 } |
| 64 | 90 |
| 65 void EndFloatClipDisplayItem::AsValueInto( | 91 void EndFloatClipDisplayItem::AsValueInto( |
| 66 base::trace_event::TracedValue* array) const { | 92 base::trace_event::TracedValue* array) const { |
| 67 array->AppendString("EndFloatClipDisplayItem"); | 93 array->AppendString("EndFloatClipDisplayItem"); |
| 68 } | 94 } |
| 69 | 95 |
| 70 } // namespace cc | 96 } // namespace cc |
| OLD | NEW |