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

Unified 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: fix android build 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/gfx/compositor/render/render_image.cc ('k') | services/gfx/compositor/render/render_layer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/gfx/compositor/render/render_layer.h
diff --git a/services/gfx/compositor/render/render_layer.h b/services/gfx/compositor/render/render_layer.h
new file mode 100644
index 0000000000000000000000000000000000000000..34e614c94cd9c4402c178e1d21c8f928a0f0fe2b
--- /dev/null
+++ b/services/gfx/compositor/render/render_layer.h
@@ -0,0 +1,108 @@
+// 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 SERVICES_GFX_COMPOSITOR_RENDER_RENDER_LAYER_H_
+#define SERVICES_GFX_COMPOSITOR_RENDER_RENDER_LAYER_H_
+
+#include <memory>
+#include <vector>
+
+#include "base/macros.h"
+#include "services/gfx/compositor/render/render_image.h"
+#include "skia/ext/refptr.h"
+#include "third_party/skia/include/core/SkMatrix.h"
+#include "third_party/skia/include/core/SkPaint.h"
+#include "third_party/skia/include/core/SkPath.h"
+#include "third_party/skia/include/core/SkPictureRecorder.h"
+#include "third_party/skia/include/core/SkRRect.h"
+#include "third_party/skia/include/core/SkRect.h"
+
+class SkCanvas;
+class SkPicture;
+
+namespace compositor {
+
+class RenderCommand;
+
+// Describes a sequence of drawing commands to be evaluated as a single pass.
+// Layers are introduced into the render frame at points where blending must
+// occur or where portions of a scene graph may be drawn once into a temporary
+// buffer and used many times.
+//
+// Render objects are thread-safe, immutable, and reference counted via
+// std::shared_ptr. They have no direct references to the scene graph.
+class RenderLayer {
+ public:
+ ~RenderLayer();
+ explicit RenderLayer(const skia::RefPtr<SkPicture>& picture);
+
+ // Gets the underlying picture to rasterize.
+ const skia::RefPtr<SkPicture>& picture() const { return picture_; }
+
+ private:
+ friend class RenderLayerBuilder;
+
+ // TODO: store auxiliary information required for hit testing
+ skia::RefPtr<SkPicture> picture_;
+
+ DISALLOW_COPY_AND_ASSIGN(RenderLayer);
+};
+
+// Builder for render layers.
+class RenderLayerBuilder {
+ public:
+ // Creates a layer builder with an optional |cull_rect| to cull recorded
+ // geometry information.
+ RenderLayerBuilder();
+ explicit RenderLayerBuilder(const SkRect* cull_rect);
+ ~RenderLayerBuilder();
+
+ // Pushes information about a scene onto the stack.
+ void PushScene(uint32_t scene_token, uint32_t version);
+
+ // Pops a scene off the stack.
+ void PopScene();
+
+ // Pushes information about a node onto the stack.
+ void PushNode(uint32_t node_id, uint32_t hit_id);
+
+ // Pops a node off the stack.
+ void PopNode();
+
+ // Applies a transformation matrix to the node.
+ void ApplyTransform(const SkMatrix& content_transform);
+
+ // Applies a clip to the node.
+ void ApplyClip(const SkRect& content_clip);
+
+ // Inserts a command to draw a rectangle.
+ void DrawRect(const SkRect& content_rect, const SkPaint& paint);
+
+ // Inserts a command to draw an image.
+ void DrawImage(const std::shared_ptr<RenderImage>& image,
+ const SkRect& content_rect,
+ const SkRect& image_rect,
+ const SkPaint& paint);
+
+ // Inserts a command to draw an in-place layer.
+ void DrawLayer(const std::shared_ptr<RenderLayer>& layer);
+
+ // Inserts a command to draw a saved layer.
+ void DrawSavedLayer(const std::shared_ptr<RenderLayer>& layer,
+ const SkRect& content_rect,
+ const SkPaint& paint);
+
+ // Returns the layer which was built.
+ std::shared_ptr<RenderLayer> Build();
+
+ private:
+ SkPictureRecorder recorder_;
+ SkCanvas* canvas_;
+
+ DISALLOW_COPY_AND_ASSIGN(RenderLayerBuilder);
+};
+
+} // namespace compositor
+
+#endif // SERVICES_GFX_COMPOSITOR_RENDER_RENDER_LAYER_H_
« no previous file with comments | « services/gfx/compositor/render/render_image.cc ('k') | services/gfx/compositor/render/render_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698