ASPiK SDK
cairobitmap.h
1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #pragma once
6 
7 #include <cairo/cairo.h>
8 
9 #include "../../cpoint.h"
10 #include "../../vstguidebug.h"
11 #include "../iplatformbitmap.h"
12 #include "cairoutils.h"
13 
14 //------------------------------------------------------------------------
15 namespace VSTGUI {
16 namespace Cairo {
17 
18 //-----------------------------------------------------------------------------
19 class Bitmap : public IPlatformBitmap
20 {
21 public:
22  explicit Bitmap (CPoint* size);
23  explicit Bitmap (const SurfaceHandle& surface);
24  ~Bitmap () override;
25 
26  bool load (const CResourceDescription& desc) override;
27  const CPoint& getSize () const override;
28  SharedPointer<IPlatformBitmapPixelAccess> lockPixels (bool alphaPremultiplied) override;
29  void setScaleFactor (double factor) override;
30  double getScaleFactor () const override;
31 
32  const SurfaceHandle& getSurface () const
33  {
34  vstgui_assert (!locked, "Bitmap is locked");
35  if (locked)
36  {
37  static SurfaceHandle empty;
38  return empty;
39  }
40  return surface;
41  }
42 
43  void unlock () { locked = false; }
44 private:
45  double scaleFactor {1.0};
46  SurfaceHandle surface;
47  CPoint size;
48  bool locked {false};
49 };
50 
51 //------------------------------------------------------------------------
52 } // Cairo
53 } // VSTGUI
Describes a resource by name or by ID.
Definition: cresourcedescription.h:16
Definition: cairobitmap.h:19
Definition: customcontrols.cpp:8
Point structure.
Definition: cpoint.h:17