Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_COMMON_GPU_STREAM_TEXTURE_MANAGER_ANDROID_H_ | 5 #ifndef CONTENT_COMMON_GPU_STREAM_TEXTURE_MANAGER_ANDROID_H_ |
| 6 #define CONTENT_COMMON_GPU_STREAM_TEXTURE_MANAGER_ANDROID_H_ | 6 #define CONTENT_COMMON_GPU_STREAM_TEXTURE_MANAGER_ANDROID_H_ |
| 7 #pragma once | |
|
apatrick_chromium
2012/07/12 23:51:31
pragma once is not allowed anymore.
qinmin
2012/07/13 00:41:33
Done.
| |
| 7 | 8 |
| 9 #include "base/callback.h" | |
| 8 #include "base/id_map.h" | 10 #include "base/id_map.h" |
| 9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "content/common/android/surface_texture_peer.h" | |
| 11 #include "gpu/command_buffer/service/stream_texture.h" | 14 #include "gpu/command_buffer/service/stream_texture.h" |
| 12 #include "gpu/command_buffer/service/stream_texture_manager.h" | 15 #include "gpu/command_buffer/service/stream_texture_manager.h" |
| 13 | 16 |
| 14 class GpuChannel; | 17 class GpuChannel; |
| 18 struct GpuStreamTextureMsg_MatrixChanged_Params; | |
| 19 | |
| 20 namespace gfx { | |
| 21 class Size; | |
| 22 } | |
| 15 | 23 |
| 16 namespace content { | 24 namespace content { |
| 17 | 25 |
| 18 class SurfaceTextureBridge; | 26 class SurfaceTextureBridge; |
| 19 | 27 |
| 20 // Class for managing the stream texture. | 28 // Class for managing the stream texture. |
| 21 class StreamTextureManagerAndroid : public gpu::StreamTextureManager { | 29 class StreamTextureManagerAndroid : public gpu::StreamTextureManager { |
| 22 public: | 30 public: |
| 23 StreamTextureManagerAndroid(GpuChannel* channel); | 31 StreamTextureManagerAndroid(GpuChannel* channel); |
| 24 virtual ~StreamTextureManagerAndroid(); | 32 virtual ~StreamTextureManagerAndroid(); |
| 25 | 33 |
| 26 // implement gpu::StreamTextureManager: | 34 // implement gpu::StreamTextureManager: |
| 27 GLuint CreateStreamTexture(uint32 service_id, | 35 virtual GLuint CreateStreamTexture(uint32 service_id, |
| 28 uint32 client_id) OVERRIDE; | 36 uint32 client_id) OVERRIDE; |
|
apatrick_chromium
2012/07/12 23:51:31
indentation is out
qinmin
2012/07/13 00:41:33
Done.
| |
| 29 void DestroyStreamTexture(uint32 service_id) OVERRIDE; | 37 virtual void DestroyStreamTexture(uint32 service_id) OVERRIDE; |
| 30 gpu::StreamTexture* LookupStreamTexture(uint32 service_id) OVERRIDE; | 38 virtual gpu::StreamTexture* LookupStreamTexture(uint32 service_id) OVERRIDE; |
| 39 | |
| 40 // Methods invoked from GpuChannel. | |
| 41 void RegisterStreamTextureProxy( | |
| 42 int32 stream_id, const gfx::Size& initial_size, int32 route_id); | |
| 43 void EstablishStreamTexture( | |
| 44 int32 stream_id, content::SurfaceTexturePeer::SurfaceTextureTarget type, | |
| 45 int32 primary_id, int32 secondary_id); | |
| 46 | |
| 47 // Send new transform matrix. | |
| 48 void SendMatrixChanged(int route_id, | |
| 49 const GpuStreamTextureMsg_MatrixChanged_Params& params); | |
| 31 | 50 |
| 32 private: | 51 private: |
| 33 // The stream texture class for android. | 52 // The stream texture class for android. |
| 34 class StreamTextureAndroid | 53 class StreamTextureAndroid |
| 35 : public gpu::StreamTexture, | 54 : public gpu::StreamTexture, |
| 36 public base::SupportsWeakPtr<StreamTextureAndroid> { | 55 public base::SupportsWeakPtr<StreamTextureAndroid> { |
| 37 public: | 56 public: |
| 38 StreamTextureAndroid(GpuChannel* channel, int service_id); | 57 StreamTextureAndroid(GpuChannel* channel, int service_id); |
| 39 virtual ~StreamTextureAndroid(); | 58 virtual ~StreamTextureAndroid(); |
| 40 | 59 |
| 41 void Update() OVERRIDE; | 60 virtual void Update() OVERRIDE; |
| 42 | 61 |
| 43 SurfaceTextureBridge* bridge() { return surface_texture_.get(); } | 62 SurfaceTextureBridge* bridge() { return surface_texture_.get(); } |
| 44 | 63 |
| 64 // Called when a new frame is available. | |
| 65 void OnFrameAvailable(int route_id); | |
| 66 | |
| 67 // Callback function when transform matrix of the surface texture | |
| 68 // has changed. | |
| 69 typedef base::Callback< | |
| 70 void(const GpuStreamTextureMsg_MatrixChanged_Params&)> | |
| 71 MatrixChangedCB; | |
| 72 | |
| 73 void set_matrix_changed_callback(const MatrixChangedCB& callback) | |
| 74 { matrix_callback_ = callback; } | |
| 75 | |
| 45 private: | 76 private: |
| 46 scoped_ptr<SurfaceTextureBridge> surface_texture_; | 77 scoped_ptr<SurfaceTextureBridge> surface_texture_; |
| 78 | |
| 79 // Current transform matrix of the surface texture. | |
| 80 float current_matrix_[16]; | |
| 81 | |
| 82 // Whether the surface texture has been updated. | |
| 83 bool has_updated_; | |
| 84 | |
| 85 MatrixChangedCB matrix_callback_; | |
| 86 | |
| 47 GpuChannel* channel_; | 87 GpuChannel* channel_; |
| 48 | |
| 49 DISALLOW_COPY_AND_ASSIGN(StreamTextureAndroid); | 88 DISALLOW_COPY_AND_ASSIGN(StreamTextureAndroid); |
| 50 }; | 89 }; |
| 51 | 90 |
| 52 GpuChannel* channel_; | 91 GpuChannel* channel_; |
| 53 | 92 |
| 54 typedef IDMap<StreamTextureAndroid, IDMapOwnPointer> TextureMap; | 93 typedef IDMap<StreamTextureAndroid, IDMapOwnPointer> TextureMap; |
| 55 TextureMap textures_; | 94 TextureMap textures_; |
| 56 | 95 |
| 96 // Map for more convenient lookup. | |
| 97 typedef IDMap<gpu::StreamTexture, IDMapExternalPointer> TextureServiceIdMap; | |
| 98 TextureServiceIdMap textures_from_service_id_; | |
| 99 | |
| 57 DISALLOW_COPY_AND_ASSIGN(StreamTextureManagerAndroid); | 100 DISALLOW_COPY_AND_ASSIGN(StreamTextureManagerAndroid); |
| 58 }; | 101 }; |
| 59 | 102 |
| 60 } // namespace content | 103 } // namespace content |
| 61 | 104 |
| 62 #endif // CONTENT_COMMON_GPU_STREAM_TEXTURE_MANAGER_ANDROID_H_ | 105 #endif // CONTENT_COMMON_GPU_STREAM_TEXTURE_MANAGER_ANDROID_H_ |
| OLD | NEW |