OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_ANDROID_H_ | 5 #ifndef CONTENT_COMMON_GPU_STREAM_TEXTURE_ANDROID_H_ |
6 #define CONTENT_COMMON_GPU_STREAM_TEXTURE_ANDROID_H_ | 6 #define CONTENT_COMMON_GPU_STREAM_TEXTURE_ANDROID_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "content/common/gpu/gpu_command_buffer_stub.h" | 10 #include "content/common/gpu/gpu_command_buffer_stub.h" |
11 #include "ipc/ipc_listener.h" | 11 #include "ipc/ipc_listener.h" |
12 #include "ui/gl/android/surface_texture.h" | 12 #include "ui/gl/android/surface_texture.h" |
13 #include "ui/gl/gl_image.h" | 13 #include "ui/gl/gl_image.h" |
14 | 14 |
| 15 namespace ui { |
| 16 class ScopedMakeCurrent; |
| 17 } |
| 18 |
15 namespace gfx { | 19 namespace gfx { |
16 class Size; | 20 class Size; |
17 } | 21 } |
18 | 22 |
19 namespace content { | 23 namespace content { |
20 | 24 |
21 class StreamTexture : public gl::GLImage, | 25 class StreamTexture : public gl::GLImage, |
22 public IPC::Listener, | 26 public IPC::Listener, |
23 public GpuCommandBufferStub::DestructionObserver { | 27 public GpuCommandBufferStub::DestructionObserver { |
24 public: | 28 public: |
(...skipping 22 matching lines...) Expand all Loading... |
47 gfx::OverlayTransform transform, | 51 gfx::OverlayTransform transform, |
48 const gfx::Rect& bounds_rect, | 52 const gfx::Rect& bounds_rect, |
49 const gfx::RectF& crop_rect) override; | 53 const gfx::RectF& crop_rect) override; |
50 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, | 54 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, |
51 uint64_t process_tracing_id, | 55 uint64_t process_tracing_id, |
52 const std::string& dump_name) override; | 56 const std::string& dump_name) override; |
53 | 57 |
54 // GpuCommandBufferStub::DestructionObserver implementation. | 58 // GpuCommandBufferStub::DestructionObserver implementation. |
55 void OnWillDestroyStub() override; | 59 void OnWillDestroyStub() override; |
56 | 60 |
| 61 scoped_ptr<ui::ScopedMakeCurrent> MakeStubCurrent(); |
| 62 void DoUpdateTexImage(); |
| 63 bool DoCopyTexture(const gfx::Point& offset, const gfx::Rect& rect); |
| 64 |
| 65 void UpdateTransformMatrix(); |
57 // Called when a new frame is available for the SurfaceTexture. | 66 // Called when a new frame is available for the SurfaceTexture. |
58 void OnFrameAvailable(); | 67 void OnFrameAvailable(); |
59 | 68 |
60 // IPC::Listener implementation: | 69 // IPC::Listener implementation: |
61 bool OnMessageReceived(const IPC::Message& message) override; | 70 bool OnMessageReceived(const IPC::Message& message) override; |
62 | 71 |
63 // IPC message handlers: | 72 // IPC message handlers: |
64 void OnStartListening(); | 73 void OnStartListening(); |
65 void OnEstablishPeer(int32 primary_id, int32 secondary_id); | 74 void OnEstablishPeer(int32 primary_id, int32 secondary_id); |
66 void OnSetSize(const gfx::Size& size) { size_ = size; } | 75 void OnSetSize(const gfx::Size& size) { size_ = size; } |
67 | 76 |
68 scoped_refptr<gfx::SurfaceTexture> surface_texture_; | 77 scoped_refptr<gfx::SurfaceTexture> surface_texture_; |
69 | 78 |
70 // Current transform matrix of the surface texture. | 79 // Current transform matrix of the surface texture. |
71 float current_matrix_[16]; | 80 float current_matrix_[16]; |
72 | 81 |
73 // Current size of the surface texture. | 82 // Current size of the surface texture. |
74 gfx::Size size_; | 83 gfx::Size size_; |
75 | 84 |
76 // Whether we ever bound a valid frame. | 85 // Whether we ever bound a valid frame. |
77 bool has_valid_frame_; | 86 bool has_valid_frame_; |
78 | 87 |
79 // Whether a new frame is available that we should update to. | 88 // Whether a new frame is available that we should update to. |
80 bool has_pending_frame_; | 89 bool has_pending_frame_; |
81 | 90 |
82 GpuCommandBufferStub* owner_stub_; | 91 GpuCommandBufferStub* owner_stub_; |
83 int32 route_id_; | 92 int32 route_id_; |
84 bool has_listener_; | 93 bool has_listener_; |
| 94 bool matrix_modified_; |
85 uint32 texture_id_; | 95 uint32 texture_id_; |
86 | 96 |
| 97 unsigned framebuffer_; |
| 98 unsigned vertex_shader_; |
| 99 unsigned fragment_shader_; |
| 100 unsigned program_; |
| 101 unsigned vertex_buffer_; |
| 102 int u_xform_loc_; |
| 103 |
87 base::WeakPtrFactory<StreamTexture> weak_factory_; | 104 base::WeakPtrFactory<StreamTexture> weak_factory_; |
88 DISALLOW_COPY_AND_ASSIGN(StreamTexture); | 105 DISALLOW_COPY_AND_ASSIGN(StreamTexture); |
89 }; | 106 }; |
90 | 107 |
91 } // namespace content | 108 } // namespace content |
92 | 109 |
93 #endif // CONTENT_COMMON_GPU_STREAM_TEXTURE_ANDROID_H_ | 110 #endif // CONTENT_COMMON_GPU_STREAM_TEXTURE_ANDROID_H_ |
OLD | NEW |