Home | History | Annotate | Download | only in renderer_host
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CONTENT_BROWSER_RENDERER_HOST_SURFACE_TEXTURE_TRANSPORT_CLIENT_ANDROID_H_
      6 #define CONTENT_BROWSER_RENDERER_HOST_SURFACE_TEXTURE_TRANSPORT_CLIENT_ANDROID_H_
      7 
      8 #include "base/memory/ref_counted.h"
      9 #include "base/memory/scoped_ptr.h"
     10 #include "base/memory/weak_ptr.h"
     11 #include "cc/layers/video_frame_provider.h"
     12 #include "gpu/command_buffer/common/mailbox.h"
     13 #include "ui/gfx/native_widget_types.h"
     14 #include "ui/gfx/size.h"
     15 
     16 struct ANativeWindow;
     17 
     18 namespace cc {
     19 class Layer;
     20 class VideoLayer;
     21 }
     22 
     23 namespace gfx {
     24 class SurfaceTextureBridge;
     25 }
     26 
     27 namespace content {
     28 
     29 class SurfaceTextureTransportClient : public cc::VideoFrameProvider {
     30  public:
     31   SurfaceTextureTransportClient();
     32   virtual ~SurfaceTextureTransportClient();
     33 
     34   scoped_refptr<cc::Layer> Initialize();
     35   gfx::GLSurfaceHandle GetCompositingSurface(int surface_id);
     36   void SetSize(const gfx::Size& size);
     37 
     38   // cc::VideoFrameProvider implementation.
     39   virtual void SetVideoFrameProviderClient(Client*) OVERRIDE {}
     40   virtual scoped_refptr<media::VideoFrame> GetCurrentFrame() OVERRIDE;
     41   virtual void PutCurrentFrame(const scoped_refptr<media::VideoFrame>& frame)
     42       OVERRIDE;
     43 
     44  private:
     45   void OnSurfaceTextureFrameAvailable();
     46 
     47   scoped_refptr<cc::VideoLayer> video_layer_;
     48   scoped_refptr<gfx::SurfaceTextureBridge> surface_texture_;
     49   ANativeWindow* window_;
     50   scoped_refptr<media::VideoFrame> video_frame_;
     51   uint32 texture_id_;
     52   gpu::Mailbox texture_mailbox_;
     53   uint32 texture_mailbox_sync_point_;
     54   int surface_id_;
     55   base::WeakPtrFactory<SurfaceTextureTransportClient> weak_factory_;
     56 
     57   DISALLOW_COPY_AND_ASSIGN(SurfaceTextureTransportClient);
     58 };
     59 
     60 }  // namespace content
     61 
     62 #endif  // CONTENT_BROWSER_RENDERER_HOST_SURFACE_TEXTURE_TRANSPORT_CLIENT_ANDROID_H_
     63