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

Side by Side Diff: services/gfx/compositor/graph/resources.h

Issue 1874593002: Mozart: Rename scene graph classes. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-2
Patch Set: Created 4 years, 8 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
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_GRAPH_RESOURCE_DEF_H_ 5 #ifndef SERVICES_GFX_COMPOSITOR_GRAPH_RESOURCES_H_
6 #define SERVICES_GFX_COMPOSITOR_GRAPH_RESOURCE_DEF_H_ 6 #define SERVICES_GFX_COMPOSITOR_GRAPH_RESOURCES_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 "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "mojo/services/gfx/composition/interfaces/resources.mojom.h" 11 #include "mojo/services/gfx/composition/interfaces/resources.mojom.h"
12 #include "services/gfx/compositor/render/render_image.h" 12 #include "services/gfx/compositor/render/render_image.h"
13 13
14 namespace compositor { 14 namespace compositor {
15 15
16 class SceneDef; 16 class SceneDef;
17 17
18 // Abstract scene graph resource definition. 18 // Base class for resources in a scene graph.
19 // 19 //
20 // Instances of this class are immutable and reference counted so they may 20 // Instances of this class are immutable and reference counted so they may
21 // be shared by multiple versions of the same scene. 21 // be shared by multiple versions of the same scene.
22 class ResourceDef : public base::RefCounted<ResourceDef> { 22 class Resource : public base::RefCounted<Resource> {
23 public: 23 public:
24 enum class Type { kScene, kImage }; 24 enum class Type { kScene, kImage };
25 25
26 ResourceDef(); 26 Resource();
27 27
28 // Gets the resource type. 28 // Gets the resource type.
29 virtual Type type() const = 0; 29 virtual Type type() const = 0;
30 30
31 protected: 31 protected:
32 friend class base::RefCounted<ResourceDef>; 32 friend class base::RefCounted<Resource>;
33 virtual ~ResourceDef(); 33 virtual ~Resource();
34 34
35 private: 35 private:
36 DISALLOW_COPY_AND_ASSIGN(ResourceDef); 36 DISALLOW_COPY_AND_ASSIGN(Resource);
37 }; 37 };
38 38
39 // Reference to another scene expressed as a resource definition. 39 // A resource which represents a reference to a specified scene.
40 class SceneResourceDef : public ResourceDef { 40 class SceneResource : public Resource {
41 public: 41 public:
42 explicit SceneResourceDef( 42 SceneResource(const mojo::gfx::composition::SceneToken& scene_token,
43 const mojo::gfx::composition::SceneToken& scene_token, 43 const base::WeakPtr<SceneDef>& referenced_scene);
44 const base::WeakPtr<SceneDef>& referenced_scene);
45 44
46 Type type() const override; 45 Type type() const override;
47 46
48 const mojo::gfx::composition::SceneToken& scene_token() const { 47 const mojo::gfx::composition::SceneToken& scene_token() const {
49 return scene_token_; 48 return scene_token_;
50 } 49 }
51 50
52 // The referenced scene, may be null if the scene is unavailable. 51 // The referenced scene, may be null if the scene is unavailable.
53 const base::WeakPtr<SceneDef>& referenced_scene() const { 52 const base::WeakPtr<SceneDef>& referenced_scene() const {
54 return referenced_scene_; 53 return referenced_scene_;
55 } 54 }
56 55
57 // Returns a copy of the resource without its referenced scene. 56 // Returns a copy of the resource without its referenced scene.
58 scoped_refptr<const SceneResourceDef> Unlink() const; 57 scoped_refptr<const SceneResource> Unlink() const;
59 58
60 protected: 59 protected:
61 ~SceneResourceDef() override; 60 ~SceneResource() override;
62 61
63 private: 62 private:
64 mojo::gfx::composition::SceneToken scene_token_; 63 mojo::gfx::composition::SceneToken scene_token_;
65 base::WeakPtr<SceneDef> referenced_scene_; 64 base::WeakPtr<SceneDef> referenced_scene_;
66 65
67 DISALLOW_COPY_AND_ASSIGN(SceneResourceDef); 66 DISALLOW_COPY_AND_ASSIGN(SceneResource);
68 }; 67 };
69 68
70 // Reference to an image expressed as a resource definition. 69 // A resource which represents a refrence to a specified image.
71 class ImageResourceDef : public ResourceDef { 70 class ImageResource : public Resource {
72 public: 71 public:
73 explicit ImageResourceDef(const scoped_refptr<RenderImage>& image); 72 explicit ImageResource(const scoped_refptr<RenderImage>& image);
74 73
75 Type type() const override; 74 Type type() const override;
76 75
77 // The referenced image, never null. 76 // The referenced image, never null.
78 const scoped_refptr<RenderImage>& image() const { return image_; } 77 const scoped_refptr<RenderImage>& image() const { return image_; }
79 78
80 protected: 79 protected:
81 ~ImageResourceDef() override; 80 ~ImageResource() override;
82 81
83 private: 82 private:
84 scoped_refptr<RenderImage> image_; 83 scoped_refptr<RenderImage> image_;
85 84
86 DISALLOW_COPY_AND_ASSIGN(ImageResourceDef); 85 DISALLOW_COPY_AND_ASSIGN(ImageResource);
87 }; 86 };
88 87
89 } // namespace compositor 88 } // namespace compositor
90 89
91 #endif // SERVICES_GFX_COMPOSITOR_GRAPH_RESOURCE_DEF_H_ 90 #endif // SERVICES_GFX_COMPOSITOR_GRAPH_RESOURCES_H_
OLDNEW
« no previous file with comments | « services/gfx/compositor/graph/resource_def.cc ('k') | services/gfx/compositor/graph/resources.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698