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