| 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 SERVICES_UI_PUBLIC_CPP_BITMAP_UPLOADER_H_ | 5 #ifndef SERVICES_UI_PUBLIC_CPP_BITMAP_UPLOADER_H_ |
| 6 #define SERVICES_UI_PUBLIC_CPP_BITMAP_UPLOADER_H_ | 6 #define SERVICES_UI_PUBLIC_CPP_BITMAP_UPLOADER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "gpu/GLES2/gl2chromium.h" | 15 #include "gpu/GLES2/gl2chromium.h" |
| 16 #include "gpu/GLES2/gl2extchromium.h" | 16 #include "gpu/GLES2/gl2extchromium.h" |
| 17 #include "services/ui/public/cpp/window_surface.h" | 17 #include "services/ui/public/cpp/window_surface.h" |
| 18 #include "services/ui/public/cpp/window_surface_client.h" | 18 #include "services/ui/public/cpp/window_surface_client.h" |
| 19 #include "services/ui/public/interfaces/surface.mojom.h" | 19 #include "services/ui/public/interfaces/surface.mojom.h" |
| 20 | 20 |
| 21 namespace ui { | 21 namespace ui { |
| 22 class GLES2Context; | 22 class GLES2Context; |
| 23 class GpuService; |
| 23 | 24 |
| 24 extern const char kBitmapUploaderForAcceleratedWidget[]; | 25 extern const char kBitmapUploaderForAcceleratedWidget[]; |
| 25 | 26 |
| 26 // BitmapUploader is useful if you want to draw a bitmap or color in a | 27 // BitmapUploader is useful if you want to draw a bitmap or color in a |
| 27 // Window. | 28 // Window. |
| 28 class BitmapUploader : public WindowSurfaceClient { | 29 class BitmapUploader : public WindowSurfaceClient { |
| 29 public: | 30 public: |
| 30 explicit BitmapUploader(Window* window); | 31 BitmapUploader(Window* window, GpuService* gpu_service); |
| 31 ~BitmapUploader() override; | 32 ~BitmapUploader() override; |
| 32 | 33 |
| 33 void Init(); | 34 void Init(); |
| 34 | 35 |
| 35 // Sets the color which is RGBA. | 36 // Sets the color which is RGBA. |
| 36 void SetColor(uint32_t color); | 37 void SetColor(uint32_t color); |
| 37 | 38 |
| 38 enum Format { | 39 enum Format { |
| 39 RGBA, // Pixel layout on Android. | 40 RGBA, // Pixel layout on Android. |
| 40 BGRA, // Pixel layout everywhere else. | 41 BGRA, // Pixel layout everywhere else. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 55 return format_ == BGRA ? GL_BGRA_EXT : GL_RGBA; | 56 return format_ == BGRA ? GL_BGRA_EXT : GL_RGBA; |
| 56 } | 57 } |
| 57 | 58 |
| 58 void SetIdNamespace(uint32_t id_namespace); | 59 void SetIdNamespace(uint32_t id_namespace); |
| 59 | 60 |
| 60 // WindowSurfaceClient implementation. | 61 // WindowSurfaceClient implementation. |
| 61 void OnResourcesReturned( | 62 void OnResourcesReturned( |
| 62 WindowSurface* surface, | 63 WindowSurface* surface, |
| 63 mojo::Array<cc::ReturnedResource> resources) override; | 64 mojo::Array<cc::ReturnedResource> resources) override; |
| 64 | 65 |
| 65 ui::Window* window_; | 66 Window* window_; |
| 66 std::unique_ptr<ui::WindowSurface> surface_; | 67 std::unique_ptr<WindowSurface> surface_; |
| 67 // This may be null if there is an error contacting mus/initializing. We | 68 // This may be null if there is an error contacting mus/initializing. We |
| 68 // assume we'll be shutting down soon and do nothing in this case. | 69 // assume we'll be shutting down soon and do nothing in this case. |
| 69 std::unique_ptr<ui::GLES2Context> gles2_context_; | 70 std::unique_ptr<GLES2Context> gles2_context_; |
| 71 GpuService* gpu_service_; |
| 70 | 72 |
| 71 uint32_t color_; | 73 uint32_t color_; |
| 72 int width_; | 74 int width_; |
| 73 int height_; | 75 int height_; |
| 74 Format format_; | 76 Format format_; |
| 75 std::unique_ptr<std::vector<unsigned char>> bitmap_; | 77 std::unique_ptr<std::vector<unsigned char>> bitmap_; |
| 76 uint32_t next_resource_id_; | 78 uint32_t next_resource_id_; |
| 77 base::hash_map<uint32_t, uint32_t> resource_to_texture_id_map_; | 79 base::hash_map<uint32_t, uint32_t> resource_to_texture_id_map_; |
| 78 | 80 |
| 79 DISALLOW_COPY_AND_ASSIGN(BitmapUploader); | 81 DISALLOW_COPY_AND_ASSIGN(BitmapUploader); |
| 80 }; | 82 }; |
| 81 | 83 |
| 82 } // namespace ui | 84 } // namespace ui |
| 83 | 85 |
| 84 #endif // SERVICES_UI_PUBLIC_CPP_BITMAP_UPLOADER_H_ | 86 #endif // SERVICES_UI_PUBLIC_CPP_BITMAP_UPLOADER_H_ |
| OLD | NEW |