Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: services/gfx/compositor/render/render_layer.h

Issue 1552963002: Initial checkin of the new Mozart compositor. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-11
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_LAYER_H_
6 #define SERVICES_GFX_COMPOSITOR_RENDER_RENDER_LAYER_H_
7
8 #include <memory>
9 #include <vector>
10
11 #include "base/macros.h"
12 #include "services/gfx/compositor/render/painting.h"
13 #include "services/gfx/compositor/render/render_image.h"
14 #include "third_party/skia/include/core/SkMatrix.h"
15 #include "third_party/skia/include/core/SkPaint.h"
16 #include "third_party/skia/include/core/SkPath.h"
17 #include "third_party/skia/include/core/SkRRect.h"
18 #include "third_party/skia/include/core/SkRect.h"
19
20 class SkCanvas;
21 class SkPicture;
22
23 namespace compositor {
24
25 class RenderCommand;
26
27 // Describes a sequence of drawing commands to be evaluated as a single pass.
28 // Layers are introduced into the render frame at points where blending must
29 // occur or where portions of a scene graph may be drawn once into a temporary
30 // buffer and used many times.
31 //
32 // Render objects are thread-safe, immutable, and reference counted via
33 // std::shared_ptr. They have no direct references to the scene graph.
34 class RenderLayer {
35 public:
36 ~RenderLayer();
37 explicit RenderLayer(const SkRect& cull_rect);
38
39 // Gets the cull rectangle for the layer.
40 const SkRect& cull_rect() const { return cull_rect_; }
41
42 // Creates a Skia picture from the underlying layer.
43 skia::RefPtr<SkPicture> CreateSkPicture(
44 const PaintingScope& painting_scope) const;
45
46 private:
47 friend class RenderLayerBuilder;
48
49 const SkRect cull_rect_;
50
51 // TODO(jeffbrown): Consider replacing this with something that has far
52 // less allocation overhead if the number of commands per layer becomes
53 // large.
54 std::vector<std::unique_ptr<RenderCommand>> commands_;
55
56 DISALLOW_COPY_AND_ASSIGN(RenderLayer);
57 };
58
59 // Builder for render layers.
60 class RenderLayerBuilder {
61 public:
62 // Creates a layer builder with an optional |cull_rect| to cull recorded
63 // geometry information.
64 RenderLayerBuilder();
65 explicit RenderLayerBuilder(const SkRect* cull_rect);
66 ~RenderLayerBuilder();
67
68 // Pushes information about a scene onto the stack.
69 void PushScene(uint32_t scene_token, uint32_t version);
70
71 // Pops a scene off the stack.
72 void PopScene();
73
74 // Pushes information about a node onto the stack.
75 void PushNode(uint32_t node_id,
76 uint32_t hit_id,
77 const SkMatrix& content_transform,
78 const SkPath& content_clip);
79
80 // Pops a node off the stack.
81 void PopNode();
82
83 // Inserts a command to draw a rectangle.
84 void DrawRect(const SkRect& content_rect, const SkPaint& paint);
85
86 // Inserts a command to draw an image.
87 void DrawImage(const std::shared_ptr<RenderImage>& image,
88 const SkRect& content_rect,
89 const SkRect& image_rect,
90 const SkPaint& paint);
91
92 // Inserts a command to draw an in-place layer.
93 void DrawLayer(const std::shared_ptr<RenderLayer>& layer);
94
95 // Inserts a command to draw a saved layer.
96 void DrawSavedLayer(const std::shared_ptr<RenderLayer>& layer,
97 const SkRect& content_rect,
98 const SkPaint& paint);
99
100 // Returns the layer which was built.
101 std::shared_ptr<RenderLayer> Build();
102
103 private:
104 std::shared_ptr<RenderLayer> layer_;
105
106 DISALLOW_COPY_AND_ASSIGN(RenderLayerBuilder);
107 };
108
109 } // namespace compositor
110
111 #endif // SERVICES_GFX_COMPOSITOR_RENDER_RENDER_LAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698