| 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_GRAPH_RESOURCE_DEF_H_ | |
| 6 #define SERVICES_GFX_COMPOSITOR_GRAPH_RESOURCE_DEF_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "mojo/services/gfx/composition/interfaces/resources.mojom.h" | |
| 12 #include "services/gfx/compositor/render/render_image.h" | |
| 13 | |
| 14 namespace compositor { | |
| 15 | |
| 16 class SceneDef; | |
| 17 | |
| 18 // Abstract scene graph resource definition. | |
| 19 // | |
| 20 // Instances of this class are immutable and reference counted so they may | |
| 21 // be shared by multiple versions of the same scene. | |
| 22 class ResourceDef : public base::RefCounted<ResourceDef> { | |
| 23 public: | |
| 24 enum class Type { kScene, kImage }; | |
| 25 | |
| 26 ResourceDef(); | |
| 27 | |
| 28 // Gets the resource type. | |
| 29 virtual Type type() const = 0; | |
| 30 | |
| 31 protected: | |
| 32 friend class base::RefCounted<ResourceDef>; | |
| 33 virtual ~ResourceDef(); | |
| 34 | |
| 35 private: | |
| 36 DISALLOW_COPY_AND_ASSIGN(ResourceDef); | |
| 37 }; | |
| 38 | |
| 39 // Reference to another scene expressed as a resource definition. | |
| 40 class SceneResourceDef : public ResourceDef { | |
| 41 public: | |
| 42 explicit SceneResourceDef( | |
| 43 const mojo::gfx::composition::SceneToken& scene_token, | |
| 44 const base::WeakPtr<SceneDef>& referenced_scene); | |
| 45 | |
| 46 Type type() const override; | |
| 47 | |
| 48 const mojo::gfx::composition::SceneToken& scene_token() const { | |
| 49 return scene_token_; | |
| 50 } | |
| 51 | |
| 52 // The referenced scene, may be null if the scene is unavailable. | |
| 53 const base::WeakPtr<SceneDef>& referenced_scene() const { | |
| 54 return referenced_scene_; | |
| 55 } | |
| 56 | |
| 57 // Returns a copy of the resource without its referenced scene. | |
| 58 scoped_refptr<const SceneResourceDef> Unlink() const; | |
| 59 | |
| 60 protected: | |
| 61 ~SceneResourceDef() override; | |
| 62 | |
| 63 private: | |
| 64 mojo::gfx::composition::SceneToken scene_token_; | |
| 65 base::WeakPtr<SceneDef> referenced_scene_; | |
| 66 | |
| 67 DISALLOW_COPY_AND_ASSIGN(SceneResourceDef); | |
| 68 }; | |
| 69 | |
| 70 // Reference to an image expressed as a resource definition. | |
| 71 class ImageResourceDef : public ResourceDef { | |
| 72 public: | |
| 73 explicit ImageResourceDef(const scoped_refptr<RenderImage>& image); | |
| 74 | |
| 75 Type type() const override; | |
| 76 | |
| 77 // The referenced image, never null. | |
| 78 const scoped_refptr<RenderImage>& image() const { return image_; } | |
| 79 | |
| 80 protected: | |
| 81 ~ImageResourceDef() override; | |
| 82 | |
| 83 private: | |
| 84 scoped_refptr<RenderImage> image_; | |
| 85 | |
| 86 DISALLOW_COPY_AND_ASSIGN(ImageResourceDef); | |
| 87 }; | |
| 88 | |
| 89 } // namespace compositor | |
| 90 | |
| 91 #endif // SERVICES_GFX_COMPOSITOR_GRAPH_RESOURCE_DEF_H_ | |
| OLD | NEW |