OLD | NEW |
| (Empty) |
1 // Copyright 2014 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 EXAMPLES_GANESH_APP_TEXTURE_UPLOADER_H_ | |
6 #define EXAMPLES_GANESH_APP_TEXTURE_UPLOADER_H_ | |
7 | |
8 #include "base/containers/hash_tables.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/weak_ptr.h" | |
11 #include "mojo/gpu/gl_context.h" | |
12 #include "mojo/gpu/gl_texture.h" | |
13 #include "mojo/public/cpp/bindings/binding.h" | |
14 #include "mojo/services/geometry/interfaces/geometry.mojom.h" | |
15 #include "mojo/services/surfaces/interfaces/surface_id.mojom.h" | |
16 #include "mojo/services/surfaces/interfaces/surfaces.mojom.h" | |
17 | |
18 namespace mojo { | |
19 class Shell; | |
20 } | |
21 | |
22 namespace examples { | |
23 | |
24 class TextureUploader : public mojo::ResourceReturner, | |
25 public mojo::GLContext::Observer { | |
26 public: | |
27 class Client { | |
28 public: | |
29 virtual void OnSurfaceIdAvailable(mojo::SurfaceIdPtr surface_id) = 0; | |
30 | |
31 protected: | |
32 virtual ~Client(); | |
33 }; | |
34 | |
35 TextureUploader(Client* client, | |
36 mojo::Shell* shell, | |
37 base::WeakPtr<mojo::GLContext> context); | |
38 ~TextureUploader() override; | |
39 | |
40 void Upload(scoped_ptr<mojo::GLTexture> texture); | |
41 | |
42 private: | |
43 // mojo::GLContext::Observer | |
44 void OnContextLost() override; | |
45 | |
46 // mojo::ResourceReturner | |
47 void ReturnResources( | |
48 mojo::Array<mojo::ReturnedResourcePtr> resources) override; | |
49 | |
50 void SetIdNamespace(uint32_t id_namespace); | |
51 void EnsureSurfaceForSize(const mojo::Size& size); | |
52 void SendFullyQualifiedID(); | |
53 | |
54 Client* client_; | |
55 base::WeakPtr<mojo::GLContext> context_; | |
56 mojo::SurfacePtr surface_; | |
57 mojo::Size surface_size_; | |
58 uint32_t next_resource_id_; | |
59 uint32_t id_namespace_; | |
60 uint32_t local_id_; | |
61 base::hash_map<uint32_t, mojo::GLTexture*> resource_to_texture_map_; | |
62 mojo::Binding<mojo::ResourceReturner> returner_binding_; | |
63 | |
64 DISALLOW_COPY_AND_ASSIGN(TextureUploader); | |
65 }; | |
66 | |
67 } // namespace examples | |
68 | |
69 #endif // EXAMPLES_GANESH_APP_TEXTURE_UPLOADER_H_ | |
OLD | NEW |