Respond with QuotaExceededError when IndexedDB has no disk space on open.
[chromium-blink-merge.git] / content / common / gpu / stream_texture_manager_android.h
blobe1bfda46aae00fcd3d5ca3fd9e63182f0feea9af
1 // Copyright (c) 2012 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.
5 #ifndef CONTENT_COMMON_GPU_STREAM_TEXTURE_MANAGER_ANDROID_H_
6 #define CONTENT_COMMON_GPU_STREAM_TEXTURE_MANAGER_ANDROID_H_
8 #include "base/callback.h"
9 #include "base/id_map.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "content/common/android/surface_texture_peer.h"
13 #include "gpu/command_buffer/service/stream_texture.h"
14 #include "gpu/command_buffer/service/stream_texture_manager.h"
16 struct GpuStreamTextureMsg_MatrixChanged_Params;
18 namespace gfx {
19 class Size;
20 class SurfaceTexture;
23 namespace content {
24 class GpuChannel;
26 // Class for managing the stream texture.
27 class StreamTextureManagerAndroid : public gpu::StreamTextureManager {
28 public:
29 StreamTextureManagerAndroid(GpuChannel* channel);
30 virtual ~StreamTextureManagerAndroid();
32 // implement gpu::StreamTextureManager:
33 virtual uint32 CreateStreamTexture(uint32 service_id,
34 uint32 client_id) OVERRIDE;
35 virtual void DestroyStreamTexture(uint32 service_id) OVERRIDE;
36 virtual gpu::StreamTexture* LookupStreamTexture(uint32 service_id) OVERRIDE;
38 // Methods invoked from GpuChannel.
39 void RegisterStreamTextureProxy(int32 stream_id, int32 route_id);
40 void EstablishStreamTexture(
41 int32 stream_id, int32 primary_id, int32 secondary_id);
42 void SetStreamTextureSize(int32 stream_id, const gfx::Size& size);
44 // Send new transform matrix.
45 void SendMatrixChanged(int route_id,
46 const GpuStreamTextureMsg_MatrixChanged_Params& params);
48 private:
49 // The stream texture class for android.
50 class StreamTextureAndroid
51 : public gpu::StreamTexture,
52 public base::SupportsWeakPtr<StreamTextureAndroid> {
53 public:
54 StreamTextureAndroid(GpuChannel* channel, int service_id);
55 virtual ~StreamTextureAndroid();
57 virtual void Update() OVERRIDE;
58 virtual gfx::Size GetSize() OVERRIDE;
60 scoped_refptr<gfx::SurfaceTexture> surface_texture() {
61 return surface_texture_;
64 // Called when a new frame is available.
65 void OnFrameAvailable(int route_id);
67 // Set surface texture size.
68 void SetSize(const gfx::Size& size) { size_ = size; }
70 // Callback function when transform matrix of the surface texture
71 // has changed.
72 typedef base::Callback<
73 void(const GpuStreamTextureMsg_MatrixChanged_Params&)>
74 MatrixChangedCB;
76 void set_matrix_changed_callback(const MatrixChangedCB& callback) {
77 matrix_callback_ = callback;
80 private:
81 scoped_refptr<gfx::SurfaceTexture> surface_texture_;
83 // Current transform matrix of the surface texture.
84 float current_matrix_[16];
86 // Current size of the surface texture.
87 gfx::Size size_;
89 // Whether the surface texture has been updated.
90 bool has_updated_;
92 MatrixChangedCB matrix_callback_;
94 GpuChannel* channel_;
95 DISALLOW_COPY_AND_ASSIGN(StreamTextureAndroid);
98 GpuChannel* channel_;
100 typedef IDMap<StreamTextureAndroid, IDMapOwnPointer> TextureMap;
101 TextureMap textures_;
103 // Map for more convenient lookup.
104 typedef IDMap<gpu::StreamTexture, IDMapExternalPointer> TextureServiceIdMap;
105 TextureServiceIdMap textures_from_service_id_;
107 DISALLOW_COPY_AND_ASSIGN(StreamTextureManagerAndroid);
110 } // namespace content
112 #endif // CONTENT_COMMON_GPU_STREAM_TEXTURE_MANAGER_ANDROID_H_