OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 MOJO_SKIA_GANESH_IMAGE_FACTORY_H_ | 5 #ifndef MOJO_SKIA_GANESH_IMAGE_FACTORY_H_ |
6 #define MOJO_SKIA_GANESH_IMAGE_FACTORY_H_ | 6 #define MOJO_SKIA_GANESH_IMAGE_FACTORY_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 "mojo/skia/ganesh_context.h" | 12 #include "mojo/skia/ganesh_context.h" |
13 #include "skia/ext/refptr.h" | |
14 #include "third_party/skia/include/core/SkImageGenerator.h" | 13 #include "third_party/skia/include/core/SkImageGenerator.h" |
| 14 #include "third_party/skia/include/core/SkRefCnt.h" |
15 #include "third_party/skia/include/gpu/GrTypes.h" | 15 #include "third_party/skia/include/gpu/GrTypes.h" |
16 | 16 |
17 class SkImage; | 17 class SkImage; |
18 | 18 |
19 namespace mojo { | 19 namespace mojo { |
20 namespace skia { | 20 namespace skia { |
21 | 21 |
22 // Creates an SkImage from a GL texture. | 22 // Creates an SkImage from a GL texture. |
23 // The underlying texture must be kept alive for as long as the SkImage exists. | 23 // The underlying texture must be kept alive for as long as the SkImage exists. |
24 // Invokes |release_callback| when the SkImage is deleted. | 24 // Invokes |release_callback| when the SkImage is deleted. |
25 ::skia::RefPtr<SkImage> CreateImageFromTexture( | 25 sk_sp<SkImage> CreateImageFromTexture(const GaneshContext::Scope& scope, |
26 const GaneshContext::Scope& scope, | 26 uint32_t texture_id, |
27 uint32_t texture_id, | 27 uint32_t width, |
28 uint32_t width, | 28 uint32_t height, |
29 uint32_t height, | 29 GrSurfaceOrigin origin, |
30 GrSurfaceOrigin origin, | 30 const base::Closure& release_callback); |
31 const base::Closure& release_callback); | |
32 | 31 |
33 // Generates backing content for SkImages from a texture mailbox. | 32 // Generates backing content for SkImages from a texture mailbox. |
34 // If |sync_point| is non-zero, inserts a sync point into the command stream | 33 // If |sync_point| is non-zero, inserts a sync point into the command stream |
35 // before the image is first drawn. | 34 // before the image is first drawn. |
36 // It is the responsibility of the client of this class to ensure that | 35 // It is the responsibility of the client of this class to ensure that |
37 // the mailbox name is valid at the time when the image is being drawn. | 36 // the mailbox name is valid at the time when the image is being drawn. |
38 class MailboxTextureImageGenerator : public SkImageGenerator { | 37 class MailboxTextureImageGenerator : public SkImageGenerator { |
39 public: | 38 public: |
40 MailboxTextureImageGenerator( | 39 MailboxTextureImageGenerator( |
41 const GLbyte mailbox_name[GL_MAILBOX_SIZE_CHROMIUM], | 40 const GLbyte mailbox_name[GL_MAILBOX_SIZE_CHROMIUM], |
42 GLuint sync_point, | 41 GLuint sync_point, |
43 uint32_t width, | 42 uint32_t width, |
44 uint32_t height, | 43 uint32_t height, |
45 GrSurfaceOrigin origin); | 44 GrSurfaceOrigin origin); |
46 ~MailboxTextureImageGenerator() override; | 45 ~MailboxTextureImageGenerator() override; |
47 | 46 |
48 GrTexture* onGenerateTexture(GrContext* context, | 47 GrTexture* onGenerateTexture(GrContext* context, |
49 const SkIRect* subset) override; | 48 const SkIRect* subset) override; |
50 | 49 |
51 private: | 50 private: |
52 GLbyte mailbox_name_[GL_MAILBOX_SIZE_CHROMIUM]; | 51 GLbyte mailbox_name_[GL_MAILBOX_SIZE_CHROMIUM]; |
53 GLuint sync_point_; | 52 GLuint sync_point_; |
54 GrSurfaceOrigin origin_; | 53 GrSurfaceOrigin origin_; |
55 }; | 54 }; |
56 | 55 |
57 } // namespace skia | 56 } // namespace skia |
58 } // namespace mojo | 57 } // namespace mojo |
59 | 58 |
60 #endif // MOJO_SKIA_GANESH_IMAGE_FACTORY_H_ | 59 #endif // MOJO_SKIA_GANESH_IMAGE_FACTORY_H_ |
OLD | NEW |