Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(720)

Side by Side Diff: examples/ganesh_app/texture_uploader.h

Issue 871373015: De-Client Surface interface (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 EXAMPLES_GANESH_APP_TEXTURE_UPLOADER_H_ 5 #ifndef EXAMPLES_GANESH_APP_TEXTURE_UPLOADER_H_
6 #define EXAMPLES_GANESH_APP_TEXTURE_UPLOADER_H_ 6 #define EXAMPLES_GANESH_APP_TEXTURE_UPLOADER_H_
7 7
8 #include "base/containers/hash_tables.h" 8 #include "base/containers/hash_tables.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "mojo/gpu/gl_context.h" 11 #include "mojo/gpu/gl_context.h"
12 #include "mojo/gpu/gl_texture.h" 12 #include "mojo/gpu/gl_texture.h"
13 #include "mojo/services/geometry/public/interfaces/geometry.mojom.h" 13 #include "mojo/services/geometry/public/interfaces/geometry.mojom.h"
14 #include "mojo/services/surfaces/public/interfaces/surface_id.mojom.h" 14 #include "mojo/services/surfaces/public/interfaces/surface_id.mojom.h"
15 #include "mojo/services/surfaces/public/interfaces/surfaces.mojom.h" 15 #include "mojo/services/surfaces/public/interfaces/surfaces.mojom.h"
16 16
17 namespace mojo { 17 namespace mojo {
18 class Shell; 18 class Shell;
19 } 19 }
20 20
21 namespace examples { 21 namespace examples {
22 22
23 class TextureUploader : public mojo::SurfaceClient, 23 class TextureUploader : public mojo::ResourceReturner,
24 public mojo::GLContext::Observer { 24 public mojo::GLContext::Observer {
25 public: 25 public:
26 class Client { 26 class Client {
27 public: 27 public:
28 virtual void OnSurfaceIdAvailable(mojo::SurfaceIdPtr surface_id) = 0; 28 virtual void OnSurfaceIdAvailable(mojo::SurfaceIdPtr surface_id) = 0;
29 29
30 protected: 30 protected:
31 virtual ~Client(); 31 virtual ~Client();
32 }; 32 };
33 33
34 TextureUploader(Client* client, 34 TextureUploader(Client* client,
35 mojo::Shell* shell, 35 mojo::Shell* shell,
36 base::WeakPtr<mojo::GLContext> context); 36 base::WeakPtr<mojo::GLContext> context);
37 ~TextureUploader(); 37 ~TextureUploader();
38 38
39 void Upload(scoped_ptr<mojo::GLTexture> texture); 39 void Upload(scoped_ptr<mojo::GLTexture> texture);
40 40
41 private: 41 private:
42 // mojo::GLContext::Observer 42 // mojo::GLContext::Observer
43 void OnContextLost() override; 43 void OnContextLost() override;
44 44
45 // mojo::SurfaceClient 45 void SetIdNamespace(uint32_t id_namespace);
46 void SetIdNamespace(uint32_t id_namespace) override; 46 // mojo::ResourceReturner
sky 2015/01/31 01:25:28 nit: newline here too.
47 void ReturnResources( 47 void ReturnResources(
48 mojo::Array<mojo::ReturnedResourcePtr> resources) override; 48 mojo::Array<mojo::ReturnedResourcePtr> resources) override;
49 49
50 void EnsureSurfaceForSize(const mojo::Size& size); 50 void EnsureSurfaceForSize(const mojo::Size& size);
51 void SendFullyQualifiedID(); 51 void SendFullyQualifiedID();
52 52
53 Client* client_; 53 Client* client_;
54 base::WeakPtr<mojo::GLContext> context_; 54 base::WeakPtr<mojo::GLContext> context_;
55 scoped_ptr<mojo::GLTexture> pending_upload_; 55 scoped_ptr<mojo::GLTexture> pending_upload_;
56 mojo::SurfacePtr surface_; 56 mojo::SurfacePtr surface_;
57 mojo::Size surface_size_; 57 mojo::Size surface_size_;
58 uint32_t next_resource_id_; 58 uint32_t next_resource_id_;
59 uint32_t id_namespace_; 59 uint32_t id_namespace_;
60 uint32_t local_id_; 60 uint32_t local_id_;
61 base::hash_map<uint32_t, mojo::GLTexture*> resource_to_texture_map_; 61 base::hash_map<uint32_t, mojo::GLTexture*> resource_to_texture_map_;
62 mojo::Binding<mojo::ResourceReturner> returner_binding_;
62 63
63 base::WeakPtrFactory<TextureUploader> weak_factory_; 64 base::WeakPtrFactory<TextureUploader> weak_factory_;
64 65
65 DISALLOW_COPY_AND_ASSIGN(TextureUploader); 66 DISALLOW_COPY_AND_ASSIGN(TextureUploader);
66 }; 67 };
67 68
68 } // namespace examples 69 } // namespace examples
69 70
70 #endif // EXAMPLES_GANESH_APP_TEXTURE_UPLOADER_H_ 71 #endif // EXAMPLES_GANESH_APP_TEXTURE_UPLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698