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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "content/common/gpu/gpu_command_buffer_stub.h" | 12 #include "content/common/gpu/gpu_command_buffer_stub.h" |
13 #include "gpu/command_buffer/service/gl_stream_texture_image.h" | |
14 #include "ipc/ipc_listener.h" | 13 #include "ipc/ipc_listener.h" |
15 #include "ui/gl/android/surface_texture.h" | 14 #include "ui/gl/android/surface_texture.h" |
16 #include "ui/gl/gl_image.h" | 15 #include "ui/gl/gl_image.h" |
17 | 16 |
18 namespace ui { | 17 namespace ui { |
19 class ScopedMakeCurrent; | 18 class ScopedMakeCurrent; |
20 } | 19 } |
21 | 20 |
22 namespace gfx { | 21 namespace gfx { |
23 class Size; | 22 class Size; |
24 } | 23 } |
25 | 24 |
26 namespace content { | 25 namespace content { |
27 | 26 |
28 class StreamTexture : public gpu::gles2::GLStreamTextureImage, | 27 class StreamTexture : public gl::GLImage, |
29 public IPC::Listener, | 28 public IPC::Listener, |
30 public GpuCommandBufferStub::DestructionObserver { | 29 public GpuCommandBufferStub::DestructionObserver { |
31 public: | 30 public: |
32 static bool Create(GpuCommandBufferStub* owner_stub, | 31 static bool Create(GpuCommandBufferStub* owner_stub, |
33 uint32_t client_texture_id, | 32 uint32_t client_texture_id, |
34 int stream_id); | 33 int stream_id); |
35 | 34 |
36 private: | 35 private: |
37 StreamTexture(GpuCommandBufferStub* owner_stub, | 36 StreamTexture(GpuCommandBufferStub* owner_stub, |
38 int32_t route_id, | 37 int32_t route_id, |
(...skipping 12 matching lines...) Expand all Loading... |
51 const gfx::Rect& rect) override; | 50 const gfx::Rect& rect) override; |
52 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 51 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
53 int z_order, | 52 int z_order, |
54 gfx::OverlayTransform transform, | 53 gfx::OverlayTransform transform, |
55 const gfx::Rect& bounds_rect, | 54 const gfx::Rect& bounds_rect, |
56 const gfx::RectF& crop_rect) override; | 55 const gfx::RectF& crop_rect) override; |
57 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, | 56 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, |
58 uint64_t process_tracing_id, | 57 uint64_t process_tracing_id, |
59 const std::string& dump_name) override; | 58 const std::string& dump_name) override; |
60 | 59 |
61 // gpu::gles2::GLStreamTextureMatrix implementation | |
62 void GetTextureMatrix(float xform[16]) override; | |
63 | |
64 // GpuCommandBufferStub::DestructionObserver implementation. | 60 // GpuCommandBufferStub::DestructionObserver implementation. |
65 void OnWillDestroyStub() override; | 61 void OnWillDestroyStub() override; |
66 | 62 |
67 scoped_ptr<ui::ScopedMakeCurrent> MakeStubCurrent(); | 63 scoped_ptr<ui::ScopedMakeCurrent> MakeStubCurrent(); |
68 | 64 |
69 void UpdateTexImage(); | 65 void UpdateTexImage(); |
70 | 66 |
71 // Called when a new frame is available for the SurfaceTexture. | 67 // Called when a new frame is available for the SurfaceTexture. |
72 void OnFrameAvailable(); | 68 void OnFrameAvailable(); |
73 | 69 |
74 // IPC::Listener implementation: | 70 // IPC::Listener implementation: |
75 bool OnMessageReceived(const IPC::Message& message) override; | 71 bool OnMessageReceived(const IPC::Message& message) override; |
76 | 72 |
77 // IPC message handlers: | 73 // IPC message handlers: |
78 void OnStartListening(); | 74 void OnStartListening(); |
79 void OnEstablishPeer(int32_t primary_id, int32_t secondary_id); | 75 void OnEstablishPeer(int32_t primary_id, int32_t secondary_id); |
80 void OnSetSize(const gfx::Size& size) { size_ = size; } | 76 void OnSetSize(const gfx::Size& size) { size_ = size; } |
81 | 77 |
82 scoped_refptr<gfx::SurfaceTexture> surface_texture_; | 78 scoped_refptr<gfx::SurfaceTexture> surface_texture_; |
83 | 79 |
84 // Current transform matrix of the surface texture. | 80 // Current transform matrix of the surface texture. |
85 float current_matrix_[16]; | 81 float current_matrix_[16]; |
86 | 82 |
87 // Current size of the surface texture. | 83 // Current size of the surface texture. |
88 gfx::Size size_; | 84 gfx::Size size_; |
89 | 85 |
| 86 // Whether we ever bound a valid frame. |
| 87 bool has_valid_frame_; |
| 88 |
90 // Whether a new frame is available that we should update to. | 89 // Whether a new frame is available that we should update to. |
91 bool has_pending_frame_; | 90 bool has_pending_frame_; |
92 | 91 |
93 GpuCommandBufferStub* owner_stub_; | 92 GpuCommandBufferStub* owner_stub_; |
94 int32_t route_id_; | 93 int32_t route_id_; |
95 bool has_listener_; | 94 bool has_listener_; |
96 uint32_t texture_id_; | 95 uint32_t texture_id_; |
97 | 96 |
98 unsigned framebuffer_; | 97 unsigned framebuffer_; |
99 unsigned vertex_shader_; | 98 unsigned vertex_shader_; |
100 unsigned fragment_shader_; | 99 unsigned fragment_shader_; |
101 unsigned program_; | 100 unsigned program_; |
102 unsigned vertex_buffer_; | 101 unsigned vertex_buffer_; |
103 int u_xform_location_; | 102 int u_xform_location_; |
104 | 103 |
105 base::WeakPtrFactory<StreamTexture> weak_factory_; | 104 base::WeakPtrFactory<StreamTexture> weak_factory_; |
106 DISALLOW_COPY_AND_ASSIGN(StreamTexture); | 105 DISALLOW_COPY_AND_ASSIGN(StreamTexture); |
107 }; | 106 }; |
108 | 107 |
109 } // namespace content | 108 } // namespace content |
110 | 109 |
111 #endif // CONTENT_COMMON_GPU_STREAM_TEXTURE_ANDROID_H_ | 110 #endif // CONTENT_COMMON_GPU_STREAM_TEXTURE_ANDROID_H_ |
OLD | NEW |