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 #ifndef SERVICES_GFX_COMPOSITOR_RENDER_RENDER_FRAME_H_ | 5 #ifndef SERVICES_GFX_COMPOSITOR_RENDER_RENDER_FRAME_H_ |
6 #define SERVICES_GFX_COMPOSITOR_RENDER_RENDER_FRAME_H_ | 6 #define SERVICES_GFX_COMPOSITOR_RENDER_RENDER_FRAME_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "mojo/services/gfx/composition/interfaces/scheduling.mojom.h" | 10 #include "mojo/services/gfx/composition/interfaces/scheduling.mojom.h" |
11 #include "skia/ext/refptr.h" | 11 #include "skia/ext/refptr.h" |
12 #include "third_party/skia/include/core/SkRect.h" | 12 #include "third_party/skia/include/core/SkRect.h" |
13 | 13 |
14 class SkCanvas; | 14 class SkCanvas; |
15 class SkPicture; | 15 class SkPicture; |
16 | 16 |
17 namespace compositor { | 17 namespace compositor { |
18 | 18 |
19 // Describes a frame to be rendered. | 19 // Describes a frame to be rendered. |
20 // | 20 // |
21 // Render objects are thread-safe, immutable, and reference counted. | 21 // Render objects are thread-safe, immutable, and reference counted. |
22 // They have no direct references to the scene graph. | 22 // They have no direct references to the scene graph. |
23 class RenderFrame : public base::RefCountedThreadSafe<RenderFrame> { | 23 class RenderFrame : public base::RefCountedThreadSafe<RenderFrame> { |
24 public: | 24 public: |
| 25 // Contains metadata about a particular |RenderFrame| used for tracing |
| 26 // and statistics. |
| 27 class Metadata { |
| 28 public: |
| 29 Metadata(const mojo::gfx::composition::FrameInfo& frame_info, |
| 30 int64_t composition_time); |
| 31 ~Metadata(); |
| 32 |
| 33 const mojo::gfx::composition::FrameInfo& frame_info() const { |
| 34 return frame_info_; |
| 35 } |
| 36 int64_t composition_time() const { return composition_time_; } |
| 37 |
| 38 private: |
| 39 mojo::gfx::composition::FrameInfo frame_info_; |
| 40 int64_t composition_time_; |
| 41 }; |
| 42 |
25 // Creates an empty render frame with no content. | 43 // Creates an empty render frame with no content. |
26 RenderFrame(const SkIRect& viewport, | 44 RenderFrame(const Metadata& metadata, const SkIRect& viewport); |
27 const mojo::gfx::composition::FrameInfo& frame_info); | |
28 | 45 |
29 // Creates render frame backed by a picture. | 46 // Creates render frame backed by a picture. |
30 RenderFrame(const SkIRect& viewport, | 47 RenderFrame(const Metadata& metadata, |
31 const mojo::gfx::composition::FrameInfo& frame_info, | 48 const SkIRect& viewport, |
32 const skia::RefPtr<SkPicture>& picture); | 49 const skia::RefPtr<SkPicture>& picture); |
33 | 50 |
| 51 // Gets metadata about the frame. |
| 52 const Metadata& metadata() const { return metadata_; } |
| 53 |
34 // Gets the frame's viewport in pixels. | 54 // Gets the frame's viewport in pixels. |
35 const SkIRect& viewport() const { return viewport_; } | 55 const SkIRect& viewport() const { return viewport_; } |
36 | 56 |
37 // Gets information about the frame to be rendered. | |
38 const mojo::gfx::composition::FrameInfo& frame_info() const { | |
39 return frame_info_; | |
40 } | |
41 | |
42 // Gets the underlying picture to rasterize, or null if the frame is empty. | 57 // Gets the underlying picture to rasterize, or null if the frame is empty. |
43 const skia::RefPtr<SkPicture>& picture() const { return picture_; } | 58 const skia::RefPtr<SkPicture>& picture() const { return picture_; } |
44 | 59 |
45 // Paints the frame to a canvas. | 60 // Draws the contents of the frame to a canvas. |
46 void Paint(SkCanvas* canvas) const; | 61 void Draw(SkCanvas* canvas) const; |
47 | 62 |
48 private: | 63 private: |
49 friend class base::RefCountedThreadSafe<RenderFrame>; | 64 friend class base::RefCountedThreadSafe<RenderFrame>; |
50 friend class RenderFrameBuilder; | 65 friend class RenderFrameBuilder; |
51 | 66 |
52 ~RenderFrame(); | 67 ~RenderFrame(); |
53 | 68 |
| 69 Metadata metadata_; |
54 SkIRect viewport_; | 70 SkIRect viewport_; |
55 mojo::gfx::composition::FrameInfo frame_info_; | |
56 skia::RefPtr<SkPicture> picture_; | 71 skia::RefPtr<SkPicture> picture_; |
57 | 72 |
58 DISALLOW_COPY_AND_ASSIGN(RenderFrame); | 73 DISALLOW_COPY_AND_ASSIGN(RenderFrame); |
59 }; | 74 }; |
60 | 75 |
61 } // namespace compositor | 76 } // namespace compositor |
62 | 77 |
63 #endif // SERVICES_GFX_COMPOSITOR_RENDER_RENDER_FRAME_H_ | 78 #endif // SERVICES_GFX_COMPOSITOR_RENDER_RENDER_FRAME_H_ |
OLD | NEW |