Home | History | Annotate | Download | only in compositor_bindings
      1 // Copyright 2011 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_EXTERNAL_TEXTURE_LAYER_IMPL_H_
      6 #define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_EXTERNAL_TEXTURE_LAYER_IMPL_H_
      7 
      8 #include "base/bind.h"
      9 #include "base/memory/scoped_ptr.h"
     10 #include "base/memory/scoped_vector.h"
     11 #include "cc/layers/texture_layer_client.h"
     12 #include "cc/resources/texture_mailbox.h"
     13 #include "third_party/WebKit/public/platform/WebExternalTextureLayer.h"
     14 #include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
     15 
     16 namespace WebKit {
     17 struct WebFloatRect;
     18 struct WebExternalTextureMailbox;
     19 }
     20 
     21 namespace webkit {
     22 
     23 class WebLayerImpl;
     24 class WebExternalBitmapImpl;
     25 
     26 class WebExternalTextureLayerImpl
     27     : public WebKit::WebExternalTextureLayer,
     28       public cc::TextureLayerClient,
     29       public base::SupportsWeakPtr<WebExternalTextureLayerImpl> {
     30  public:
     31   WEBKIT_COMPOSITOR_BINDINGS_EXPORT explicit WebExternalTextureLayerImpl(
     32       WebKit::WebExternalTextureLayerClient*);
     33   virtual ~WebExternalTextureLayerImpl();
     34 
     35   // WebKit::WebExternalTextureLayer implementation.
     36   virtual WebKit::WebLayer* layer();
     37   virtual void clearTexture();
     38   virtual void setOpaque(bool opaque);
     39   virtual void setPremultipliedAlpha(bool premultiplied);
     40   virtual void setBlendBackgroundColor(bool blend);
     41   virtual void setRateLimitContext(bool rate_limit);
     42 
     43   // TextureLayerClient implementation.
     44   virtual unsigned PrepareTexture() OVERRIDE;
     45   virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE;
     46   virtual bool PrepareTextureMailbox(cc::TextureMailbox* mailbox,
     47                                      bool use_shared_memory) OVERRIDE;
     48 
     49  private:
     50   static void DidReleaseMailbox(
     51       base::WeakPtr<WebExternalTextureLayerImpl> layer,
     52       const WebKit::WebExternalTextureMailbox& mailbox,
     53       WebExternalBitmapImpl* bitmap,
     54       unsigned sync_point,
     55       bool lost_resource);
     56 
     57   WebExternalBitmapImpl* AllocateBitmap();
     58 
     59   WebKit::WebExternalTextureLayerClient* client_;
     60   scoped_ptr<WebLayerImpl> layer_;
     61   ScopedVector<WebExternalBitmapImpl> free_bitmaps_;
     62 
     63   DISALLOW_COPY_AND_ASSIGN(WebExternalTextureLayerImpl);
     64 };
     65 
     66 }  // namespace webkit
     67 
     68 #endif  // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_EXTERNAL_TEXTURE_LAYER_IMPL_H_
     69