OLD | NEW |
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_RENDER_RENDER_IMAGE_H_ | 5 #ifndef SERVICES_GFX_COMPOSITOR_RENDER_RENDER_IMAGE_H_ |
6 #define SERVICES_GFX_COMPOSITOR_RENDER_RENDER_IMAGE_H_ | 6 #define SERVICES_GFX_COMPOSITOR_RENDER_RENDER_IMAGE_H_ |
7 | 7 |
8 #include <GLES2/gl2.h> | 8 #include <GLES2/gl2.h> |
9 #include <GLES2/gl2extmojo.h> | 9 #include <GLES2/gl2extmojo.h> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/task_runner.h" | 14 #include "base/task_runner.h" |
15 #include "mojo/services/gfx/composition/interfaces/resources.mojom.h" | 15 #include "mojo/services/gfx/composition/interfaces/resources.mojom.h" |
16 #include "skia/ext/refptr.h" | |
17 #include "third_party/skia/include/core/SkImage.h" | 16 #include "third_party/skia/include/core/SkImage.h" |
| 17 #include "third_party/skia/include/core/SkRefCnt.h" |
18 | 18 |
19 namespace compositor { | 19 namespace compositor { |
20 | 20 |
21 // Describes an image which can be rendered by the compositor. | 21 // Describes an image which can be rendered by the compositor. |
22 // | 22 // |
23 // Render objects are thread-safe, immutable, and reference counted. | 23 // Render objects are thread-safe, immutable, and reference counted. |
24 // They have no direct references to the scene graph. | 24 // They have no direct references to the scene graph. |
25 // | 25 // |
26 // TODO(jeffbrown): Generalize this beyond mailbox textures. | 26 // TODO(jeffbrown): Generalize this beyond mailbox textures. |
27 class RenderImage : public base::RefCountedThreadSafe<RenderImage> { | 27 class RenderImage : public base::RefCountedThreadSafe<RenderImage> { |
28 class Releaser; | 28 class Releaser; |
29 class Generator; | 29 class Generator; |
30 | 30 |
31 public: | 31 public: |
32 RenderImage(const skia::RefPtr<SkImage>& image, | 32 RenderImage(const sk_sp<SkImage>& image, |
33 const scoped_refptr<Releaser>& releaser); | 33 const scoped_refptr<Releaser>& releaser); |
34 | 34 |
35 // Creates a new image backed by a mailbox texture. | 35 // Creates a new image backed by a mailbox texture. |
36 // If |sync_point| is non-zero, inserts a sync point into the command stream | 36 // If |sync_point| is non-zero, inserts a sync point into the command stream |
37 // before the image is first drawn. | 37 // before the image is first drawn. |
38 // When the last reference is released, the associated release task is | 38 // When the last reference is released, the associated release task is |
39 // posted to the task runner. Returns nullptr if the mailbox texture | 39 // posted to the task runner. Returns nullptr if the mailbox texture |
40 // is invalid. | 40 // is invalid. |
41 static scoped_refptr<RenderImage> CreateFromMailboxTexture( | 41 static scoped_refptr<RenderImage> CreateFromMailboxTexture( |
42 const GLbyte mailbox_name[GL_MAILBOX_SIZE_CHROMIUM], | 42 const GLbyte mailbox_name[GL_MAILBOX_SIZE_CHROMIUM], |
43 GLuint sync_point, | 43 GLuint sync_point, |
44 uint32_t width, | 44 uint32_t width, |
45 uint32_t height, | 45 uint32_t height, |
46 mojo::gfx::composition::MailboxTextureResource::Origin origin, | 46 mojo::gfx::composition::MailboxTextureResource::Origin origin, |
47 const scoped_refptr<base::TaskRunner>& task_runner, | 47 const scoped_refptr<base::TaskRunner>& task_runner, |
48 const base::Closure& release_task); | 48 const base::Closure& release_task); |
49 | 49 |
50 uint32_t width() const { return image_->width(); } | 50 uint32_t width() const { return image_->width(); } |
51 uint32_t height() const { return image_->height(); } | 51 uint32_t height() const { return image_->height(); } |
52 | 52 |
53 // Gets the underlying image to rasterize, never null. | 53 // Gets the underlying image to rasterize, never null. |
54 const skia::RefPtr<SkImage>& image() const { return image_; } | 54 const sk_sp<SkImage>& image() const { return image_; } |
55 | 55 |
56 private: | 56 private: |
57 friend class base::RefCountedThreadSafe<RenderImage>; | 57 friend class base::RefCountedThreadSafe<RenderImage>; |
58 | 58 |
59 ~RenderImage(); | 59 ~RenderImage(); |
60 | 60 |
61 skia::RefPtr<SkImage> image_; | 61 sk_sp<SkImage> image_; |
62 scoped_refptr<Releaser> releaser_; | 62 scoped_refptr<Releaser> releaser_; |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(RenderImage); | 64 DISALLOW_COPY_AND_ASSIGN(RenderImage); |
65 }; | 65 }; |
66 | 66 |
67 } // namespace compositor | 67 } // namespace compositor |
68 | 68 |
69 #endif // SERVICES_GFX_COMPOSITOR_RENDER_RENDER_IMAGE_H_ | 69 #endif // SERVICES_GFX_COMPOSITOR_RENDER_RENDER_IMAGE_H_ |
OLD | NEW |