| Index: ui/compositor/paint_recorder.h
|
| diff --git a/ui/compositor/paint_recorder.h b/ui/compositor/paint_recorder.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..08047959af249022e8c517e0ca83f931f1456817
|
| --- /dev/null
|
| +++ b/ui/compositor/paint_recorder.h
|
| @@ -0,0 +1,63 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef UI_COMPOSITOR_PAINT_RECORDER_H_
|
| +#define UI_COMPOSITOR_PAINT_RECORDER_H_
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "skia/ext/refptr.h"
|
| +#include "third_party/skia/include/core/SkPictureRecorder.h"
|
| +#include "ui/compositor/compositor_export.h"
|
| +
|
| +namespace cc {
|
| +class DisplayItemList;
|
| +}
|
| +
|
| +namespace gfx {
|
| +class Canvas;
|
| +class Rect;
|
| +}
|
| +
|
| +class SkCanvas;
|
| +
|
| +namespace ui {
|
| +
|
| +// A class to hide the complexity behind setting up a recording into an
|
| +// SkPicture. This is meant to be short-lived within the scope of recording
|
| +// taking place, the SkPicture should be removed from the PaintRecorder once
|
| +// recording is complete and can be cached.
|
| +class COMPOSITOR_EXPORT PaintRecorder {
|
| + public:
|
| + // The |recording_bounds| are in the space of the ui::Layer that the
|
| + // recording is being done in.
|
| + PaintRecorder(const gfx::Rect& recording_bounds, float device_scale_factor);
|
| + ~PaintRecorder();
|
| +
|
| + // Gets the SkCanvas for the recording. Any operations done on this canvas
|
| + // will be saved in the resulting SkPicture.
|
| + SkCanvas* skcanvas() { return skcanvas_.get(); }
|
| +
|
| + // Gets a gfx::Canvas wrapping the SkCanvas for convenience methods.
|
| + gfx::Canvas* canvas() { return canvas_.get(); }
|
| +
|
| + // Ends recording and removes the SkPicture from the object. Any use of the
|
| + // canvas after calling this would be lost or undefined.
|
| + skia::RefPtr<SkPicture> TakePicture();
|
| +
|
| + // A helper method for TakePicture(), when caching the SkPicture is not
|
| + // required, that inserts it directly into a DisplayItemList.
|
| + void TakeDisplayItem(cc::DisplayItemList* list);
|
| +
|
| + private:
|
| + float device_scale_factor_;
|
| + SkPictureRecorder recorder_;
|
| + skia::RefPtr<SkCanvas> skcanvas_;
|
| + scoped_ptr<gfx::Canvas> canvas_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(PaintRecorder);
|
| +};
|
| +
|
| +} // namespace ui
|
| +
|
| +#endif // UI_COMPOSITOR_PAINT_RECORDER_H_
|
|
|