| 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/filter_display_item.h" | 5 #include "cc/playback/filter_display_item.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
| 11 #include "cc/output/render_surface_filters.h" | 11 #include "cc/output/render_surface_filters.h" |
| 12 #include "cc/proto/display_item.pb.h" | 12 #include "cc/proto/display_item.pb.h" |
| 13 #include "cc/proto/gfx_conversions.h" | 13 #include "cc/proto/gfx_conversions.h" |
| 14 #include "skia/ext/cdl_canvas.h" |
| 15 #include "skia/ext/cdl_paint.h" |
| 14 #include "third_party/skia/include/core/SkCanvas.h" | 16 #include "third_party/skia/include/core/SkCanvas.h" |
| 15 #include "third_party/skia/include/core/SkImageFilter.h" | 17 #include "third_party/skia/include/core/SkImageFilter.h" |
| 16 #include "third_party/skia/include/core/SkPaint.h" | 18 #include "third_party/skia/include/core/SkPaint.h" |
| 17 #include "third_party/skia/include/core/SkRefCnt.h" | 19 #include "third_party/skia/include/core/SkRefCnt.h" |
| 18 #include "ui/gfx/skia_util.h" | 20 #include "ui/gfx/skia_util.h" |
| 19 | 21 |
| 20 namespace cc { | 22 namespace cc { |
| 21 | 23 |
| 22 FilterDisplayItem::FilterDisplayItem(const FilterOperations& filters, | 24 FilterDisplayItem::FilterDisplayItem(const FilterOperations& filters, |
| 23 const gfx::RectF& bounds, | 25 const gfx::RectF& bounds, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 49 | 51 |
| 50 void FilterDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 52 void FilterDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
| 51 proto->set_type(proto::DisplayItem::Type_Filter); | 53 proto->set_type(proto::DisplayItem::Type_Filter); |
| 52 | 54 |
| 53 proto::FilterDisplayItem* details = proto->mutable_filter_item(); | 55 proto::FilterDisplayItem* details = proto->mutable_filter_item(); |
| 54 RectFToProto(bounds_, details->mutable_bounds()); | 56 RectFToProto(bounds_, details->mutable_bounds()); |
| 55 | 57 |
| 56 // TODO(dtrainor): Support serializing FilterOperations (crbug.com/541321). | 58 // TODO(dtrainor): Support serializing FilterOperations (crbug.com/541321). |
| 57 } | 59 } |
| 58 | 60 |
| 59 void FilterDisplayItem::Raster(SkCanvas* canvas, | 61 void FilterDisplayItem::Raster(CdlCanvas* canvas, |
| 60 SkPicture::AbortCallback* callback) const { | 62 SkPicture::AbortCallback* callback) const { |
| 61 canvas->save(); | 63 canvas->save(); |
| 62 canvas->translate(origin_.x(), origin_.y()); | 64 canvas->translate(origin_.x(), origin_.y()); |
| 63 | 65 |
| 64 sk_sp<SkImageFilter> image_filter = RenderSurfaceFilters::BuildImageFilter( | 66 sk_sp<SkImageFilter> image_filter = RenderSurfaceFilters::BuildImageFilter( |
| 65 filters_, gfx::SizeF(bounds_.width(), bounds_.height())); | 67 filters_, gfx::SizeF(bounds_.width(), bounds_.height())); |
| 66 SkRect boundaries = RectFToSkRect(bounds_); | 68 SkRect boundaries = RectFToSkRect(bounds_); |
| 67 boundaries.offset(-origin_.x(), -origin_.y()); | 69 boundaries.offset(-origin_.x(), -origin_.y()); |
| 68 | 70 |
| 69 SkPaint paint; | 71 CdlPaint paint; |
| 70 paint.setBlendMode(SkBlendMode::kSrcOver); | 72 paint.setBlendMode(SkBlendMode::kSrcOver); |
| 71 paint.setImageFilter(std::move(image_filter)); | 73 paint.setImageFilter(std::move(image_filter)); |
| 72 canvas->saveLayer(&boundaries, &paint); | 74 canvas->saveLayer(&boundaries, &paint); |
| 73 | 75 |
| 74 canvas->translate(-origin_.x(), -origin_.y()); | 76 canvas->translate(-origin_.x(), -origin_.y()); |
| 75 } | 77 } |
| 76 | 78 |
| 77 void FilterDisplayItem::AsValueInto( | 79 void FilterDisplayItem::AsValueInto( |
| 78 const gfx::Rect& visual_rect, | 80 const gfx::Rect& visual_rect, |
| 79 base::trace_event::TracedValue* array) const { | 81 base::trace_event::TracedValue* array) const { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 93 EndFilterDisplayItem::EndFilterDisplayItem(const proto::DisplayItem& proto) { | 95 EndFilterDisplayItem::EndFilterDisplayItem(const proto::DisplayItem& proto) { |
| 94 DCHECK_EQ(proto::DisplayItem::Type_EndFilter, proto.type()); | 96 DCHECK_EQ(proto::DisplayItem::Type_EndFilter, proto.type()); |
| 95 } | 97 } |
| 96 | 98 |
| 97 EndFilterDisplayItem::~EndFilterDisplayItem() {} | 99 EndFilterDisplayItem::~EndFilterDisplayItem() {} |
| 98 | 100 |
| 99 void EndFilterDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 101 void EndFilterDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
| 100 proto->set_type(proto::DisplayItem::Type_EndFilter); | 102 proto->set_type(proto::DisplayItem::Type_EndFilter); |
| 101 } | 103 } |
| 102 | 104 |
| 103 void EndFilterDisplayItem::Raster(SkCanvas* canvas, | 105 void EndFilterDisplayItem::Raster(CdlCanvas* canvas, |
| 104 SkPicture::AbortCallback* callback) const { | 106 SkPicture::AbortCallback* callback) const { |
| 105 canvas->restore(); | 107 canvas->restore(); |
| 106 canvas->restore(); | 108 canvas->restore(); |
| 107 } | 109 } |
| 108 | 110 |
| 109 void EndFilterDisplayItem::AsValueInto( | 111 void EndFilterDisplayItem::AsValueInto( |
| 110 const gfx::Rect& visual_rect, | 112 const gfx::Rect& visual_rect, |
| 111 base::trace_event::TracedValue* array) const { | 113 base::trace_event::TracedValue* array) const { |
| 112 array->AppendString( | 114 array->AppendString( |
| 113 base::StringPrintf("EndFilterDisplayItem visualRect: [%s]", | 115 base::StringPrintf("EndFilterDisplayItem visualRect: [%s]", |
| 114 visual_rect.ToString().c_str())); | 116 visual_rect.ToString().c_str())); |
| 115 } | 117 } |
| 116 | 118 |
| 117 size_t EndFilterDisplayItem::ExternalMemoryUsage() const { | 119 size_t EndFilterDisplayItem::ExternalMemoryUsage() const { |
| 118 return 0; | 120 return 0; |
| 119 } | 121 } |
| 120 | 122 |
| 121 } // namespace cc | 123 } // namespace cc |
| OLD | NEW |