Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / common / gpu / stream_texture_android.h
blob72e4ed4dee0a1f90f3f91cb0303732fb23f08e55
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.
5 #ifndef CONTENT_COMMON_GPU_STREAM_TEXTURE_ANDROID_H_
6 #define CONTENT_COMMON_GPU_STREAM_TEXTURE_ANDROID_H_
8 #include "base/basictypes.h"
9 #include "base/memory/weak_ptr.h"
10 #include "content/common/gpu/gpu_command_buffer_stub.h"
11 #include "ipc/ipc_listener.h"
12 #include "ui/gl/android/surface_texture.h"
13 #include "ui/gl/gl_image.h"
15 namespace gfx {
16 class Size;
19 namespace content {
21 class StreamTexture : public gfx::GLImage,
22 public IPC::Listener,
23 public GpuCommandBufferStub::DestructionObserver {
24 public:
25 static bool Create(GpuCommandBufferStub* owner_stub,
26 uint32 client_texture_id,
27 int stream_id);
29 private:
30 StreamTexture(GpuCommandBufferStub* owner_stub,
31 int32 route_id,
32 uint32 texture_id);
33 ~StreamTexture() override;
35 // gfx::GLImage implementation:
36 void Destroy(bool have_context) override;
37 gfx::Size GetSize() override;
38 bool BindTexImage(unsigned target) override;
39 void ReleaseTexImage(unsigned target) override;
40 bool CopyTexImage(unsigned target) override;
41 void WillUseTexImage() override;
42 void DidUseTexImage() override {}
43 void WillModifyTexImage() override {}
44 void DidModifyTexImage() override {}
45 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
46 int z_order,
47 gfx::OverlayTransform transform,
48 const gfx::Rect& bounds_rect,
49 const gfx::RectF& crop_rect) override;
51 // GpuCommandBufferStub::DestructionObserver implementation.
52 void OnWillDestroyStub() override;
54 // Called when a new frame is available for the SurfaceTexture.
55 void OnFrameAvailable();
57 // IPC::Listener implementation:
58 bool OnMessageReceived(const IPC::Message& message) override;
60 // IPC message handlers:
61 void OnStartListening();
62 void OnEstablishPeer(int32 primary_id, int32 secondary_id);
63 void OnSetSize(const gfx::Size& size) { size_ = size; }
65 scoped_refptr<gfx::SurfaceTexture> surface_texture_;
67 // Current transform matrix of the surface texture.
68 float current_matrix_[16];
70 // Current size of the surface texture.
71 gfx::Size size_;
73 // Whether we ever bound a valid frame.
74 bool has_valid_frame_;
76 // Whether a new frame is available that we should update to.
77 bool has_pending_frame_;
79 GpuCommandBufferStub* owner_stub_;
80 int32 route_id_;
81 bool has_listener_;
83 base::WeakPtrFactory<StreamTexture> weak_factory_;
84 DISALLOW_COPY_AND_ASSIGN(StreamTexture);
87 } // namespace content
89 #endif // CONTENT_COMMON_GPU_STREAM_TEXTURE_ANDROID_H_