1 // Copyright 2014 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 CC_BLINK_WEB_EXTERNAL_TEXTURE_LAYER_IMPL_H_
6 #define CC_BLINK_WEB_EXTERNAL_TEXTURE_LAYER_IMPL_H_
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "cc/blink/cc_blink_export.h"
12 #include "cc/layers/texture_layer_client.h"
13 #include "third_party/WebKit/public/platform/WebExternalTextureLayer.h"
16 class WebExternalTextureLayerClient
;
18 struct WebExternalTextureMailbox
;
22 class SingleReleaseCallback
;
29 class WebExternalBitmapImpl
;
31 class WebExternalTextureLayerImpl
32 : public blink::WebExternalTextureLayer
,
33 public cc::TextureLayerClient
,
34 public base::SupportsWeakPtr
<WebExternalTextureLayerImpl
> {
36 CC_BLINK_EXPORT
explicit WebExternalTextureLayerImpl(
37 blink::WebExternalTextureLayerClient
*);
38 virtual ~WebExternalTextureLayerImpl();
40 // blink::WebExternalTextureLayer implementation.
41 virtual blink::WebLayer
* layer();
42 virtual void clearTexture();
43 virtual void setOpaque(bool opaque
);
44 virtual void setPremultipliedAlpha(bool premultiplied
);
45 virtual void setBlendBackgroundColor(bool blend
);
46 virtual void setRateLimitContext(bool rate_limit
);
47 virtual void setNearestNeighbor(bool nearest_neighbor
);
49 // TextureLayerClient implementation.
50 bool PrepareTextureMailbox(
51 cc::TextureMailbox
* mailbox
,
52 scoped_ptr
<cc::SingleReleaseCallback
>* release_callback
,
53 bool use_shared_memory
) override
;
56 static void DidReleaseMailbox(
57 base::WeakPtr
<WebExternalTextureLayerImpl
> layer
,
58 const blink::WebExternalTextureMailbox
& mailbox
,
59 WebExternalBitmapImpl
* bitmap
,
63 WebExternalBitmapImpl
* AllocateBitmap();
65 blink::WebExternalTextureLayerClient
* client_
;
66 scoped_ptr
<WebLayerImpl
> layer_
;
67 ScopedVector
<WebExternalBitmapImpl
> free_bitmaps_
;
69 DISALLOW_COPY_AND_ASSIGN(WebExternalTextureLayerImpl
);
72 } // namespace cc_blink
74 #endif // CC_BLINK_WEB_EXTERNAL_TEXTURE_LAYER_IMPL_H_