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.
5 #ifndef WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_EXTERNAL_TEXTURE_LAYER_IMPL_H_
6 #define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_EXTERNAL_TEXTURE_LAYER_IMPL_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 "third_party/WebKit/public/platform/WebExternalTextureLayer.h"
13 #include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
16 class SingleReleaseCallback
;
22 struct WebExternalTextureMailbox
;
28 class WebExternalBitmapImpl
;
30 class WebExternalTextureLayerImpl
31 : public blink::WebExternalTextureLayer
,
32 public cc::TextureLayerClient
,
33 public base::SupportsWeakPtr
<WebExternalTextureLayerImpl
> {
35 WEBKIT_COMPOSITOR_BINDINGS_EXPORT
explicit WebExternalTextureLayerImpl(
36 blink::WebExternalTextureLayerClient
*);
37 virtual ~WebExternalTextureLayerImpl();
39 // blink::WebExternalTextureLayer implementation.
40 virtual blink::WebLayer
* layer();
41 virtual void clearTexture();
42 virtual void setOpaque(bool opaque
);
43 virtual void setPremultipliedAlpha(bool premultiplied
);
44 virtual void setBlendBackgroundColor(bool blend
);
45 virtual void setRateLimitContext(bool rate_limit
);
47 // TextureLayerClient implementation.
48 virtual unsigned PrepareTexture() OVERRIDE
;
49 virtual bool PrepareTextureMailbox(
50 cc::TextureMailbox
* mailbox
,
51 scoped_ptr
<cc::SingleReleaseCallback
>* release_callback
,
52 bool use_shared_memory
) OVERRIDE
;
55 static void DidReleaseMailbox(
56 base::WeakPtr
<WebExternalTextureLayerImpl
> layer
,
57 const blink::WebExternalTextureMailbox
& mailbox
,
58 WebExternalBitmapImpl
* bitmap
,
62 WebExternalBitmapImpl
* AllocateBitmap();
64 blink::WebExternalTextureLayerClient
* client_
;
65 scoped_ptr
<WebLayerImpl
> layer_
;
66 ScopedVector
<WebExternalBitmapImpl
> free_bitmaps_
;
68 DISALLOW_COPY_AND_ASSIGN(WebExternalTextureLayerImpl
);
73 #endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_EXTERNAL_TEXTURE_LAYER_IMPL_H_