OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_BITMAP_UPLOADER_H_ |
| 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_BITMAP_UPLOADER_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "cc/surfaces/surface_id.h" |
| 12 #include "mojo/public/c/gles2/gles2.h" |
| 13 #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_service.mojom.h" |
| 16 #include "third_party/skia/include/core/SkBitmap.h" |
| 17 #include "ui/gfx/geometry/size.h" |
| 18 |
| 19 namespace cc { |
| 20 class SurfaceIdAllocator; |
| 21 } |
| 22 |
| 23 namespace mojo { |
| 24 |
| 25 class BitmapUploader : public SurfaceClient { |
| 26 public: |
| 27 BitmapUploader(SurfacesServicePtr surfaces_service, GpuPtr gpu_service); |
| 28 virtual ~BitmapUploader(); |
| 29 |
| 30 void Upload(SkBitmap bitmap, |
| 31 const base::Callback<void(SurfaceIdPtr)>& done_callback); |
| 32 |
| 33 private: |
| 34 void OnSurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace); |
| 35 uint32_t BindTextureForSize(const gfx::Size size); |
| 36 |
| 37 // SurfaceClient implementation. |
| 38 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE; |
| 39 |
| 40 SurfacesServicePtr surfaces_service_; |
| 41 GpuPtr gpu_service_; |
| 42 MojoGLES2Context gles2_context_; |
| 43 |
| 44 // Used to hold on to the bitmap until we can upload it. |
| 45 SkBitmap bitmap_; |
| 46 base::Callback<void(SurfaceIdPtr)> done_callback_; |
| 47 SurfacePtr surface_; |
| 48 cc::SurfaceId id_; |
| 49 scoped_ptr<cc::SurfaceIdAllocator> id_allocator_; |
| 50 gfx::Size surface_size_; |
| 51 uint32_t next_resource_id_; |
| 52 base::hash_map<uint32_t, uint32_t> resource_to_texture_id_map_; |
| 53 |
| 54 base::WeakPtrFactory<BitmapUploader> weak_factory_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(BitmapUploader); |
| 57 }; |
| 58 |
| 59 } // namespace mojo |
| 60 |
| 61 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_BITMAP_UPLOADER_H_ |
OLD | NEW |