Chromium Code Reviews| Index: ui/views/view.cc |
| diff --git a/ui/views/view.cc b/ui/views/view.cc |
| index 04e49767a18b046322e02ce6eaeb31bf79d374eb..8da3689d5509096759372f68e470b7bb5aeefdcb 100644 |
| --- a/ui/views/view.cc |
| +++ b/ui/views/view.cc |
| @@ -17,7 +17,6 @@ |
| #include "base/trace_event/trace_event.h" |
| #include "cc/resources/display_item_list.h" |
| #include "cc/resources/drawing_display_item.h" |
| -#include "third_party/skia/include/core/SkPictureRecorder.h" |
| #include "third_party/skia/include/core/SkRect.h" |
| #include "ui/accessibility/ax_enums.h" |
| #include "ui/base/cursor/cursor.h" |
| @@ -26,6 +25,7 @@ |
| #include "ui/compositor/dip_util.h" |
| #include "ui/compositor/layer.h" |
| #include "ui/compositor/layer_animator.h" |
| +#include "ui/compositor/paint_recorder.h" |
| #include "ui/events/event_target_iterator.h" |
| #include "ui/gfx/canvas.h" |
| #include "ui/gfx/geometry/point3_f.h" |
| @@ -1468,31 +1468,22 @@ void View::OnPaintLayerToDisplayList(cc::DisplayItemList* list, |
| float device_scale_factor) { |
| TRACE_EVENT1("views", "View::OnPaintToDisplayList", "class", GetClassName()); |
| + // TODO(danakj): Instead of always recording, cache a picture in each view and |
| + // reuse it when not invalidated. ie. just AppendItem() and return here. |
| + |
| // TODO(danakj): Does this include the bounds of all children? |
| // TODO(danakj): Should this be the layer's bounds? |
| + // TODO(danakj): The paint code does transforms on the canvas to position |
| + // children, but each DisplayItem's recording bounds and origin should be |
| + // relative to the layer, I think. |
| gfx::Rect view_bounds = GetLocalBounds(); |
| - // TODO(danakj): Instead of always recording, cache a picture in each view and |
| - // reuse it when not invalidated. |
| - SkPictureRecorder recorder; |
| - SkRTreeFactory* no_factory = nullptr; |
| - skia::RefPtr<SkCanvas> skcanvas = skia::SharePtr(recorder.beginRecording( |
| - view_bounds.width(), view_bounds.height(), no_factory, |
| - SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag)); |
| - skcanvas->clipRect(gfx::RectToSkRect(view_bounds)); |
| - |
| - { |
| - scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvasWithoutScaling( |
| - skcanvas.get(), device_scale_factor)); |
| - if (!layer() || !layer()->fills_bounds_opaquely()) |
| - canvas->DrawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); |
| - PaintCommon(canvas.get(), CullSet()); |
| - } |
| + ui::PaintRecorder recorder(view_bounds, device_scale_factor); |
| + OnPaintLayer(recorder.canvas()); |
| - skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); |
| - scoped_ptr<cc::DrawingDisplayItem> item = |
| - cc::DrawingDisplayItem::Create(picture); |
| - list->AppendItem(item.Pass()); |
| + // TODO(danakj): Cache this picture in the View and reuse it. |
|
piman
2015/03/19 20:59:19
nit: Is it not appropriate to cache the DrawingDis
danakj
2015/03/19 21:06:32
Thanks for asking, I shall do that. Slimming paint
danakj
2015/03/19 21:13:46
Done.
|
| + skia::RefPtr<SkPicture> picture = recorder.TakePicture(); |
| + list->AppendItem(cc::DrawingDisplayItem::Create(picture)); |
| } |
| void View::OnPaintLayer(gfx::Canvas* canvas) { |