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