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

Side by Side Diff: services/ui/demo/bitmap_uploader.h

Issue 2440453002: Splitting the Mus demo code out of a service. (Closed)
Patch Set: Addressed @sky comments and synced Created 4 years, 2 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
« no previous file with comments | « services/ui/demo/BUILD.gn ('k') | services/ui/demo/bitmap_uploader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/memory/weak_ptr.h"
15 #include "cc/output/compositor_frame_sink_client.h" 16 #include "cc/output/compositor_frame_sink_client.h"
16 #include "gpu/GLES2/gl2chromium.h" 17 #include "gpu/GLES2/gl2chromium.h"
17 #include "gpu/GLES2/gl2extchromium.h" 18 #include "gpu/GLES2/gl2extchromium.h"
18 #include "services/ui/public/cpp/compositor_frame_sink.h" 19 #include "services/ui/public/cpp/compositor_frame_sink.h"
19 #include "services/ui/public/cpp/window_surface.h" 20 #include "services/ui/public/cpp/window_surface.h"
20 #include "services/ui/public/cpp/window_surface_client.h" 21 #include "services/ui/public/cpp/window_surface_client.h"
21 22
23 namespace gpu {
24 class GpuChannelHost;
25 }
26
22 namespace ui { 27 namespace ui {
23 class GLES2Context; 28 class GLES2Context;
24 class GpuService; 29 class GpuService;
25 30
26 extern const char kBitmapUploaderForAcceleratedWidget[]; 31 extern const char kBitmapUploaderForAcceleratedWidget[];
27 32
28 // BitmapUploader is useful if you want to draw a bitmap or color in a 33 // BitmapUploader is useful if you want to draw a bitmap or color in a
29 // Window. 34 // Window.
30 class BitmapUploader : public cc::CompositorFrameSinkClient { 35 class BitmapUploader : public cc::CompositorFrameSinkClient {
31 public: 36 public:
(...skipping 11 matching lines...) Expand all
43 48
44 // Sets a bitmap. 49 // Sets a bitmap.
45 void SetBitmap(int width, 50 void SetBitmap(int width,
46 int height, 51 int height,
47 std::unique_ptr<std::vector<unsigned char>> data, 52 std::unique_ptr<std::vector<unsigned char>> data,
48 Format format); 53 Format format);
49 54
50 private: 55 private:
51 void Upload(); 56 void Upload();
52 57
58 void OnGpuChannelEstablished(scoped_refptr<gpu::GpuChannelHost> gpu_channel);
59
53 uint32_t BindTextureForSize(const gfx::Size& size); 60 uint32_t BindTextureForSize(const gfx::Size& size);
54 61
55 uint32_t TextureFormat() const { 62 uint32_t TextureFormat() const {
56 return format_ == BGRA ? GL_BGRA_EXT : GL_RGBA; 63 return format_ == BGRA ? GL_BGRA_EXT : GL_RGBA;
57 } 64 }
58 65
59 void SetIdNamespace(uint32_t id_namespace); 66 void SetIdNamespace(uint32_t id_namespace);
60 67
61 // cc::CompositorFrameSinkClient implementation. 68 // cc::CompositorFrameSinkClient implementation.
62 void SetBeginFrameSource(cc::BeginFrameSource* source) override; 69 void SetBeginFrameSource(cc::BeginFrameSource* source) override;
(...skipping 13 matching lines...) Expand all
76 std::unique_ptr<CompositorFrameSink> compositor_frame_sink_; 83 std::unique_ptr<CompositorFrameSink> compositor_frame_sink_;
77 84
78 uint32_t color_; 85 uint32_t color_;
79 int width_; 86 int width_;
80 int height_; 87 int height_;
81 Format format_; 88 Format format_;
82 std::unique_ptr<std::vector<unsigned char>> bitmap_; 89 std::unique_ptr<std::vector<unsigned char>> bitmap_;
83 uint32_t next_resource_id_; 90 uint32_t next_resource_id_;
84 base::hash_map<uint32_t, uint32_t> resource_to_texture_id_map_; 91 base::hash_map<uint32_t, uint32_t> resource_to_texture_id_map_;
85 92
93 base::WeakPtrFactory<BitmapUploader> weak_factory_;
94
86 DISALLOW_COPY_AND_ASSIGN(BitmapUploader); 95 DISALLOW_COPY_AND_ASSIGN(BitmapUploader);
87 }; 96 };
88 97
89 } // namespace ui 98 } // namespace ui
90 99
91 #endif // SERVICES_UI_DEMO_BITMAP_UPLOADER_H_ 100 #endif // SERVICES_UI_DEMO_BITMAP_UPLOADER_H_
OLDNEW
« no previous file with comments | « services/ui/demo/BUILD.gn ('k') | services/ui/demo/bitmap_uploader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698