Index: mojo/services/public/cpp/view_manager/lib/bitmap_uploader.h |
diff --git a/mojo/services/public/cpp/view_manager/lib/bitmap_uploader.h b/mojo/services/public/cpp/view_manager/lib/bitmap_uploader.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ac78f359749085da62b0139751bc2edfc00f409c |
--- /dev/null |
+++ b/mojo/services/public/cpp/view_manager/lib/bitmap_uploader.h |
@@ -0,0 +1,61 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_BITMAP_UPLOADER_H_ |
+#define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_BITMAP_UPLOADER_H_ |
+ |
+#include "base/callback.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/memory/weak_ptr.h" |
+#include "cc/surfaces/surface_id.h" |
+#include "mojo/public/c/gles2/gles2.h" |
+#include "mojo/services/public/interfaces/gpu/gpu.mojom.h" |
+#include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" |
+#include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h" |
+#include "third_party/skia/include/core/SkBitmap.h" |
+#include "ui/gfx/geometry/size.h" |
+ |
+namespace cc { |
+class SurfaceIdAllocator; |
+} |
+ |
+namespace mojo { |
+ |
+class BitmapUploader : public SurfaceClient { |
+ public: |
+ BitmapUploader(SurfacesServicePtr surfaces_service, GpuPtr gpu_service); |
+ virtual ~BitmapUploader(); |
+ |
+ void Upload(SkBitmap bitmap, |
+ const base::Callback<void(SurfaceIdPtr)>& done_callback); |
+ |
+ private: |
+ void OnSurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace); |
+ uint32_t BindTextureForSize(const gfx::Size size); |
+ |
+ // SurfaceClient implementation. |
+ virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE; |
+ |
+ SurfacesServicePtr surfaces_service_; |
+ GpuPtr gpu_service_; |
+ MojoGLES2Context gles2_context_; |
+ |
+ // Used to hold on to the bitmap until we can upload it. |
+ SkBitmap bitmap_; |
+ base::Callback<void(SurfaceIdPtr)> done_callback_; |
+ SurfacePtr surface_; |
+ cc::SurfaceId id_; |
+ scoped_ptr<cc::SurfaceIdAllocator> id_allocator_; |
+ gfx::Size surface_size_; |
+ uint32_t next_resource_id_; |
+ base::hash_map<uint32_t, uint32_t> resource_to_texture_id_map_; |
+ |
+ base::WeakPtrFactory<BitmapUploader> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(BitmapUploader); |
+}; |
+ |
+} // namespace mojo |
+ |
+#endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_BITMAP_UPLOADER_H_ |