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..7a66460cece6343b325d7ab78cc726d02d05d187 |
--- /dev/null |
+++ b/services/gfx/compositor/render/render_layer.h |
@@ -0,0 +1,111 @@ |
+// 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/painting.h" |
+#include "services/gfx/compositor/render/render_image.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/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 SkRect& cull_rect); |
+ |
+ // Gets the cull rectangle for the layer. |
+ const SkRect& cull_rect() const { return cull_rect_; } |
+ |
+ // Creates a Skia picture from the underlying layer. |
+ skia::RefPtr<SkPicture> CreateSkPicture( |
+ const PaintingScope& painting_scope) const; |
+ |
+ private: |
+ friend class RenderLayerBuilder; |
+ |
+ const SkRect cull_rect_; |
+ |
+ // TODO(jeffbrown): Consider replacing this with something that has far |
+ // less allocation overhead if the number of commands per layer becomes |
+ // large. |
+ std::vector<std::unique_ptr<RenderCommand>> commands_; |
+ |
+ 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, |
+ const SkMatrix& content_transform, |
+ const SkPath& content_clip); |
+ |
+ // Pops a node off the stack. |
+ void PopNode(); |
+ |
+ // 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: |
+ std::shared_ptr<RenderLayer> layer_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(RenderLayerBuilder); |
+}; |
+ |
+} // namespace compositor |
+ |
+#endif // SERVICES_GFX_COMPOSITOR_RENDER_RENDER_LAYER_H_ |