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 COMPONENTS_BITMAP_UPLOADER_BITMAP_UPLOADER_H_ | 5 #ifndef COMPONENTS_BITMAP_UPLOADER_BITMAP_UPLOADER_H_ |
6 #define COMPONENTS_BITMAP_UPLOADER_BITMAP_UPLOADER_H_ | 6 #define COMPONENTS_BITMAP_UPLOADER_BITMAP_UPLOADER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "components/bitmap_uploader/bitmap_uploader_export.h" | 13 #include "components/bitmap_uploader/bitmap_uploader_export.h" |
14 #include "components/mus/public/cpp/window_surface.h" | 14 #include "components/mus/public/cpp/window_surface.h" |
| 15 #include "components/mus/public/cpp/window_surface_client.h" |
15 #include "components/mus/public/interfaces/compositor_frame.mojom.h" | 16 #include "components/mus/public/interfaces/compositor_frame.mojom.h" |
16 #include "components/mus/public/interfaces/gpu.mojom.h" | 17 #include "components/mus/public/interfaces/gpu.mojom.h" |
17 #include "gpu/GLES2/gl2chromium.h" | 18 #include "gpu/GLES2/gl2chromium.h" |
18 #include "gpu/GLES2/gl2extchromium.h" | 19 #include "gpu/GLES2/gl2extchromium.h" |
19 #include "mojo/public/c/gles2/gles2.h" | 20 #include "mojo/public/c/gles2/gles2.h" |
20 | 21 |
21 namespace mojo { | 22 namespace mojo { |
22 class Connector; | 23 class Connector; |
23 } | 24 } |
24 | 25 |
25 namespace bitmap_uploader { | 26 namespace bitmap_uploader { |
26 | 27 |
27 BITMAP_UPLOADER_EXPORT extern const char kBitmapUploaderForAcceleratedWidget[]; | 28 BITMAP_UPLOADER_EXPORT extern const char kBitmapUploaderForAcceleratedWidget[]; |
28 | 29 |
29 // BitmapUploader is useful if you want to draw a bitmap or color in a | 30 // BitmapUploader is useful if you want to draw a bitmap or color in a |
30 // mus::Window. | 31 // mus::Window. |
31 class BITMAP_UPLOADER_EXPORT BitmapUploader | 32 class BITMAP_UPLOADER_EXPORT BitmapUploader |
32 : NON_EXPORTED_BASE(public mus::mojom::SurfaceClient) { | 33 : public NON_EXPORTED_BASE(mus::WindowSurfaceClient) { |
33 public: | 34 public: |
34 explicit BitmapUploader(mus::Window* window); | 35 explicit BitmapUploader(mus::Window* window); |
35 ~BitmapUploader() override; | 36 ~BitmapUploader() override; |
36 | 37 |
37 void Init(mojo::Connector* connector); | 38 void Init(mojo::Connector* connector); |
38 | 39 |
39 // Sets the color which is RGBA. | 40 // Sets the color which is RGBA. |
40 void SetColor(uint32_t color); | 41 void SetColor(uint32_t color); |
41 | 42 |
42 enum Format { | 43 enum Format { |
(...skipping 11 matching lines...) Expand all Loading... |
54 void Upload(); | 55 void Upload(); |
55 | 56 |
56 uint32_t BindTextureForSize(const mojo::Size size); | 57 uint32_t BindTextureForSize(const mojo::Size size); |
57 | 58 |
58 uint32_t TextureFormat() const { | 59 uint32_t TextureFormat() const { |
59 return format_ == BGRA ? GL_BGRA_EXT : GL_RGBA; | 60 return format_ == BGRA ? GL_BGRA_EXT : GL_RGBA; |
60 } | 61 } |
61 | 62 |
62 void SetIdNamespace(uint32_t id_namespace); | 63 void SetIdNamespace(uint32_t id_namespace); |
63 | 64 |
64 // SurfaceClient implementation. | 65 // WindowSurfaceClient implementation. |
65 void ReturnResources( | 66 void OnResourcesReturned( |
| 67 mus::WindowSurface* surface, |
66 mojo::Array<mus::mojom::ReturnedResourcePtr> resources) override; | 68 mojo::Array<mus::mojom::ReturnedResourcePtr> resources) override; |
67 | 69 |
68 mus::Window* window_; | 70 mus::Window* window_; |
69 mus::mojom::GpuPtr gpu_service_; | 71 mus::mojom::GpuPtr gpu_service_; |
70 scoped_ptr<mus::WindowSurface> surface_; | 72 scoped_ptr<mus::WindowSurface> surface_; |
71 MojoGLES2Context gles2_context_; | 73 MojoGLES2Context gles2_context_; |
72 | 74 |
73 mojo::Size size_; | 75 mojo::Size size_; |
74 uint32_t color_; | 76 uint32_t color_; |
75 int width_; | 77 int width_; |
76 int height_; | 78 int height_; |
77 Format format_; | 79 Format format_; |
78 scoped_ptr<std::vector<unsigned char>> bitmap_; | 80 scoped_ptr<std::vector<unsigned char>> bitmap_; |
79 uint32_t next_resource_id_; | 81 uint32_t next_resource_id_; |
80 uint32_t id_namespace_; | 82 uint32_t id_namespace_; |
81 base::hash_map<uint32_t, uint32_t> resource_to_texture_id_map_; | 83 base::hash_map<uint32_t, uint32_t> resource_to_texture_id_map_; |
82 mojo::Binding<mus::mojom::SurfaceClient> surface_client_binding_; | |
83 | 84 |
84 DISALLOW_COPY_AND_ASSIGN(BitmapUploader); | 85 DISALLOW_COPY_AND_ASSIGN(BitmapUploader); |
85 }; | 86 }; |
86 | 87 |
87 } // namespace bitmap_uploader | 88 } // namespace bitmap_uploader |
88 | 89 |
89 #endif // COMPONENTS_BITMAP_UPLOADER_BITMAP_UPLAODER_H_ | 90 #endif // COMPONENTS_BITMAP_UPLOADER_BITMAP_UPLAODER_H_ |
OLD | NEW |