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_DEMO_BITMAP_UPLOADER_H_ | 5 #ifndef SERVICES_UI_DEMO_BITMAP_UPLOADER_H_ |
6 #define SERVICES_UI_DEMO_BITMAP_UPLOADER_H_ | 6 #define SERVICES_UI_DEMO_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 "cc/output/compositor_frame_sink_client.h" | |
15 #include "gpu/GLES2/gl2chromium.h" | 16 #include "gpu/GLES2/gl2chromium.h" |
16 #include "gpu/GLES2/gl2extchromium.h" | 17 #include "gpu/GLES2/gl2extchromium.h" |
18 #include "services/ui/public/cpp/compositor_frame_sink.h" | |
17 #include "services/ui/public/cpp/window_surface.h" | 19 #include "services/ui/public/cpp/window_surface.h" |
18 #include "services/ui/public/cpp/window_surface_client.h" | 20 #include "services/ui/public/cpp/window_surface_client.h" |
19 #include "services/ui/public/interfaces/surface.mojom.h" | |
20 | 21 |
21 namespace ui { | 22 namespace ui { |
22 class GLES2Context; | 23 class GLES2Context; |
23 class GpuService; | 24 class GpuService; |
24 | 25 |
25 extern const char kBitmapUploaderForAcceleratedWidget[]; | 26 extern const char kBitmapUploaderForAcceleratedWidget[]; |
26 | 27 |
27 // BitmapUploader is useful if you want to draw a bitmap or color in a | 28 // BitmapUploader is useful if you want to draw a bitmap or color in a |
28 // Window. | 29 // Window. |
29 class BitmapUploader : public WindowSurfaceClient { | 30 class BitmapUploader : public cc::CompositorFrameSinkClient { |
30 public: | 31 public: |
31 explicit BitmapUploader(Window* window); | 32 explicit BitmapUploader(Window* window); |
32 ~BitmapUploader() override; | 33 ~BitmapUploader() override; |
33 | 34 |
34 void Init(GpuService* gpu_service); | 35 void Init(GpuService* gpu_service); |
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. |
(...skipping 10 matching lines...) Expand all Loading... | |
50 void Upload(); | 51 void Upload(); |
51 | 52 |
52 uint32_t BindTextureForSize(const gfx::Size& size); | 53 uint32_t BindTextureForSize(const gfx::Size& size); |
53 | 54 |
54 uint32_t TextureFormat() const { | 55 uint32_t TextureFormat() const { |
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 // CompositorFrameSinkClient implementation. |
rjkroege
2016/10/20 21:33:18
we've made being a client a bit more complicated.
Fady Samuel
2016/10/20 23:04:10
But hopefully more correct once all these things a
| |
61 void OnResourcesReturned(WindowSurface* surface, | 62 void SetBeginFrameSource(cc::BeginFrameSource* source) override; |
62 const cc::ReturnedResourceArray& resources) override; | 63 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; |
64 void SetTreeActivationCallback(const base::Closure& callback) override; | |
65 void DidReceiveCompositorFrameAck() override; | |
66 void DidLoseCompositorFrameSink() override; | |
67 void OnDraw(const gfx::Transform& transform, | |
68 const gfx::Rect& viewport, | |
69 bool resourceless_software_draw) override; | |
70 void SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) override; | |
71 void SetExternalTilePriorityConstraints( | |
72 const gfx::Rect& viewport_rect, | |
73 const gfx::Transform& transform) override; | |
63 | 74 |
64 Window* window_; | 75 Window* window_; |
65 std::unique_ptr<WindowSurface> surface_; | 76 std::unique_ptr<CompositorFrameSink> compositor_frame_sink_; |
66 // This may be null if there is an error contacting mus/initializing. We | |
67 // assume we'll be shutting down soon and do nothing in this case. | |
68 std::unique_ptr<GLES2Context> gles2_context_; | |
69 | 77 |
70 uint32_t color_; | 78 uint32_t color_; |
71 int width_; | 79 int width_; |
72 int height_; | 80 int height_; |
73 Format format_; | 81 Format format_; |
74 std::unique_ptr<std::vector<unsigned char>> bitmap_; | 82 std::unique_ptr<std::vector<unsigned char>> bitmap_; |
75 uint32_t next_resource_id_; | 83 uint32_t next_resource_id_; |
76 base::hash_map<uint32_t, uint32_t> resource_to_texture_id_map_; | 84 base::hash_map<uint32_t, uint32_t> resource_to_texture_id_map_; |
77 | 85 |
78 DISALLOW_COPY_AND_ASSIGN(BitmapUploader); | 86 DISALLOW_COPY_AND_ASSIGN(BitmapUploader); |
79 }; | 87 }; |
80 | 88 |
81 } // namespace ui | 89 } // namespace ui |
82 | 90 |
83 #endif // SERVICES_UI_DEMO_BITMAP_UPLOADER_H_ | 91 #endif // SERVICES_UI_DEMO_BITMAP_UPLOADER_H_ |
OLD | NEW |