Home | History | Annotate | Download | only in dri
      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();
     24 
     25   uint32_t get_handle() const { return handle_; };
     26 
     27   uint32_t get_framebuffer() const { return framebuffer_; };
     28 
     29   int get_fd() const { return fd_; };
     30 
     31   // Return the color depth of a pixel in this buffer.
     32   uint8_t GetColorDepth() const;
     33 
     34  private:
     35   friend class DriAllocator;
     36   friend class HardwareDisplayController;
     37 
     38   void set_handle(uint32_t handle) { handle_ = handle; };
     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_
     58