OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SERVICES_GFX_COMPOSITOR_RENDER_RENDER_FRAME_H_ |
| 6 #define SERVICES_GFX_COMPOSITOR_RENDER_RENDER_FRAME_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "mojo/services/gfx/composition/interfaces/hit_tests.mojom.h" |
| 12 #include "mojo/services/gfx/composition/interfaces/scheduling.mojom.h" |
| 13 #include "third_party/skia/include/core/SkRect.h" |
| 14 |
| 15 class SkCanvas; |
| 16 struct SkPoint; |
| 17 |
| 18 namespace compositor { |
| 19 |
| 20 class RenderLayer; |
| 21 |
| 22 // Describes a sequence of drawing commands to be evaluated as a single pass. |
| 23 // Frames are introduced into the render frame at points where blending must |
| 24 // occur or where portions of a scene graph may be drawn once into a temporary |
| 25 // buffer and used many times. |
| 26 // |
| 27 // Render objects are thread-safe, immutable, and reference counted via |
| 28 // std::shared_ptr. They have no direct references to the scene graph. |
| 29 class RenderFrame { |
| 30 public: |
| 31 RenderFrame(const std::shared_ptr<RenderLayer>& root_layer, |
| 32 const SkRect& viewport, |
| 33 const mojo::gfx::composition::FrameInfo& frame_info); |
| 34 ~RenderFrame(); |
| 35 |
| 36 static std::shared_ptr<RenderFrame> Create( |
| 37 const std::shared_ptr<RenderLayer>& root_layer, |
| 38 const SkRect& viewport, |
| 39 const mojo::gfx::composition::FrameInfo& frame_info) { |
| 40 return std::make_shared<RenderFrame>(root_layer, viewport, frame_info); |
| 41 } |
| 42 |
| 43 // Gets the root layer of the frame. |
| 44 const std::shared_ptr<RenderLayer>& root_layer() const { return root_layer_; } |
| 45 |
| 46 // Gets the frame's viewport. |
| 47 const SkRect& viewport() const { return viewport_; } |
| 48 |
| 49 // Gets information about the frame to be rendered. |
| 50 const mojo::gfx::composition::FrameInfo& frame_info() const { |
| 51 return frame_info_; |
| 52 } |
| 53 |
| 54 // Paints the frame to a canvas. |
| 55 void Paint(SkCanvas* canvas) const; |
| 56 |
| 57 // Performs a hit test on the content of the frame. |
| 58 mojo::gfx::composition::HitTestResultPtr HitTest(const SkPoint& point) const; |
| 59 |
| 60 private: |
| 61 friend class RenderFrameBuilder; |
| 62 |
| 63 std::shared_ptr<RenderLayer> root_layer_; |
| 64 SkRect viewport_; |
| 65 mojo::gfx::composition::FrameInfo frame_info_; |
| 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(RenderFrame); |
| 68 }; |
| 69 |
| 70 } // namespace compositor |
| 71 |
| 72 #endif // SERVICES_GFX_COMPOSITOR_RENDER_RENDER_FRAME_H_ |
OLD | NEW |