Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / ui / gfx / ozone / dri / dri_skbitmap.h
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 UI_GFX_OZONE_DRI_DRI_SKBITMAP_H_
6 #define UI_GFX_OZONE_DRI_DRI_SKBITMAP_H_
7
8 #include "base/basictypes.h"
9 #include "third_party/skia/include/core/SkBitmap.h"
10 #include "ui/gfx/gfx_export.h"
11
12 namespace gfx {
13
14 // Extend the SkBitmap interface to keep track of additional parameters used by
15 // the DRM stack when allocating buffers.
16 class GFX_EXPORT DriSkBitmap : public SkBitmap {
17  public:
18   DriSkBitmap(int fd);
19   virtual ~DriSkBitmap();
20
21   // Allocates the backing pixels using DRI.
22   // Return true on success, false otherwise.
23   virtual bool Initialize(const SkImageInfo& info);
24
25   void set_handle(uint32_t handle) { handle_ = handle; };
26
27   uint32_t get_handle() const { return handle_; };
28
29   uint32_t get_framebuffer() const { return framebuffer_; };
30
31   int get_fd() const { return fd_; };
32
33   // Return the color depth of a pixel in this buffer.
34   uint8_t GetColorDepth() const;
35
36  private:
37   friend class HardwareDisplayController;
38
39   void set_framebuffer(uint32_t framebuffer) { framebuffer_ = framebuffer; };
40
41   // File descriptor used by the DRI allocator to request buffers from the DRI
42   // stack.
43   int fd_;
44
45   // Buffer handle used by the DRI allocator.
46   uint32_t handle_;
47
48   // Buffer ID used by the DRI modesettings API. This is set when the buffer is
49   // registered with the CRTC.
50   uint32_t framebuffer_;
51
52   DISALLOW_COPY_AND_ASSIGN(DriSkBitmap);
53 };
54
55 }  // namespace gfx
56
57 #endif  // UI_GFX_OZONE_DRI_DRI_SKBITMAP_H_