Home | History | Annotate | Download | only in compositor_bindings
      1 // Copyright 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.
      4 
      5 #ifndef WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_EXTERNAL_BITMAP_IMPL_H_
      6 #define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_EXTERNAL_BITMAP_IMPL_H_
      7 
      8 #include "base/bind.h"
      9 #include "base/memory/scoped_ptr.h"
     10 #include "third_party/WebKit/public/platform/WebExternalBitmap.h"
     11 #include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
     12 
     13 namespace base {
     14 class SharedMemory;
     15 }
     16 
     17 namespace webkit {
     18 
     19 typedef scoped_ptr<base::SharedMemory> (*SharedMemoryAllocationFunction)(
     20     size_t);
     21 
     22 // Sets the function that this will use to allocate shared memory.
     23 WEBKIT_COMPOSITOR_BINDINGS_EXPORT void SetSharedMemoryAllocationFunction(
     24     SharedMemoryAllocationFunction);
     25 
     26 class WebExternalBitmapImpl : public WebKit::WebExternalBitmap {
     27  public:
     28   WEBKIT_COMPOSITOR_BINDINGS_EXPORT explicit WebExternalBitmapImpl();
     29   virtual ~WebExternalBitmapImpl();
     30 
     31   // WebKit::WebExternalBitmap implementation.
     32   virtual WebKit::WebSize size() OVERRIDE;
     33   virtual void setSize(WebKit::WebSize size) OVERRIDE;
     34   virtual uint8* pixels() OVERRIDE;
     35 
     36   base::SharedMemory* shared_memory() { return shared_memory_.get(); }
     37 
     38  private:
     39   scoped_ptr<base::SharedMemory> shared_memory_;
     40   WebKit::WebSize size_;
     41 
     42   DISALLOW_COPY_AND_ASSIGN(WebExternalBitmapImpl);
     43 };
     44 
     45 }  // namespace webkit
     46 
     47 #endif  // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_EXTERNAL_BITMAP_IMPL_H_
     48