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

Side by Side Diff: mojo/services/public/cpp/view_manager/lib/bitmap_uploader.h

Issue 555953007: Fixes for surfaces bindings exposed by wm_flow app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_BITMAP_UPLOADER_H_ 5 #ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_BITMAP_UPLOADER_H_
6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_BITMAP_UPLOADER_H_ 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_BITMAP_UPLOADER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.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 "cc/surfaces/surface_id.h" 11 #include "cc/surfaces/surface_id.h"
12 #include "mojo/public/c/gles2/gles2.h" 12 #include "mojo/public/c/gles2/gles2.h"
13 #include "mojo/services/public/cpp/view_manager/types.h"
13 #include "mojo/services/public/interfaces/gpu/gpu.mojom.h" 14 #include "mojo/services/public/interfaces/gpu/gpu.mojom.h"
14 #include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" 15 #include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h"
15 #include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h" 16 #include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h"
16 #include "third_party/skia/include/core/SkBitmap.h" 17 #include "third_party/skia/include/core/SkBitmap.h"
17 #include "ui/gfx/geometry/size.h" 18 #include "ui/gfx/geometry/size.h"
18 19
19 namespace cc { 20 namespace cc {
20 class SurfaceIdAllocator; 21 class SurfaceIdAllocator;
21 } 22 }
22 23
23 namespace mojo { 24 namespace mojo {
25 class ViewManagerClientImpl;
24 26
25 class BitmapUploader : public SurfaceClient { 27 class BitmapUploader : public SurfaceClient {
26 public: 28 public:
27 BitmapUploader(SurfacesServicePtr surfaces_service, GpuPtr gpu_service); 29 BitmapUploader(ViewManagerClientImpl* client,
30 Id view_id,
31 SurfacesServicePtr surfaces_service,
32 GpuPtr gpu_service);
28 virtual ~BitmapUploader(); 33 virtual ~BitmapUploader();
29 34
30 void Upload(SkBitmap bitmap, 35 void SetSize(const gfx::Size& size);
31 const base::Callback<void(SurfaceIdPtr)>& done_callback); 36 void SetColor(SkColor color);
37 void SetBitmap(SkBitmap bitmap);
38 void SetDoneCallback(const base::Callback<void(SurfaceIdPtr)>& done_callback);
32 39
33 private: 40 private:
41 void Upload();
34 void OnSurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace); 42 void OnSurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace);
35 uint32_t BindTextureForSize(const gfx::Size size); 43 uint32_t BindTextureForSize(const gfx::Size size);
36 44
37 // SurfaceClient implementation. 45 // SurfaceClient implementation.
38 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE; 46 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE;
39 47
48 ViewManagerClientImpl* client_;
49 Id view_id_;
40 SurfacesServicePtr surfaces_service_; 50 SurfacesServicePtr surfaces_service_;
41 GpuPtr gpu_service_; 51 GpuPtr gpu_service_;
42 MojoGLES2Context gles2_context_; 52 MojoGLES2Context gles2_context_;
43 53
44 // Used to hold on to the bitmap until we can upload it. 54 gfx::Size size_;
55 SkColor color_;
45 SkBitmap bitmap_; 56 SkBitmap bitmap_;
46 base::Callback<void(SurfaceIdPtr)> done_callback_; 57 base::Callback<void(SurfaceIdPtr)> done_callback_;
47 SurfacePtr surface_; 58 SurfacePtr surface_;
48 cc::SurfaceId id_; 59 cc::SurfaceId id_;
49 scoped_ptr<cc::SurfaceIdAllocator> id_allocator_; 60 scoped_ptr<cc::SurfaceIdAllocator> id_allocator_;
50 gfx::Size surface_size_; 61 gfx::Size surface_size_;
51 uint32_t next_resource_id_; 62 uint32_t next_resource_id_;
52 base::hash_map<uint32_t, uint32_t> resource_to_texture_id_map_; 63 base::hash_map<uint32_t, uint32_t> resource_to_texture_id_map_;
53 64
54 base::WeakPtrFactory<BitmapUploader> weak_factory_; 65 base::WeakPtrFactory<BitmapUploader> weak_factory_;
55 66
56 DISALLOW_COPY_AND_ASSIGN(BitmapUploader); 67 DISALLOW_COPY_AND_ASSIGN(BitmapUploader);
57 }; 68 };
58 69
59 } // namespace mojo 70 } // namespace mojo
60 71
61 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_BITMAP_UPLOADER_H_ 72 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_BITMAP_UPLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698