|
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef MOZILLA_GFX_SOURCESURFACERAWDATA_H_ |
|
7 #define MOZILLA_GFX_SOURCESURFACERAWDATA_H_ |
|
8 |
|
9 #include "2D.h" |
|
10 #include "Tools.h" |
|
11 |
|
12 namespace mozilla { |
|
13 namespace gfx { |
|
14 |
|
15 class SourceSurfaceRawData : public DataSourceSurface |
|
16 { |
|
17 public: |
|
18 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceRawData) |
|
19 SourceSurfaceRawData() {} |
|
20 ~SourceSurfaceRawData() { if(mOwnData) delete [] mRawData; } |
|
21 |
|
22 virtual uint8_t *GetData() { return mRawData; } |
|
23 virtual int32_t Stride() { return mStride; } |
|
24 |
|
25 virtual SurfaceType GetType() const { return SurfaceType::DATA; } |
|
26 virtual IntSize GetSize() const { return mSize; } |
|
27 virtual SurfaceFormat GetFormat() const { return mFormat; } |
|
28 |
|
29 bool InitWrappingData(unsigned char *aData, |
|
30 const IntSize &aSize, |
|
31 int32_t aStride, |
|
32 SurfaceFormat aFormat, |
|
33 bool aOwnData); |
|
34 |
|
35 private: |
|
36 uint8_t *mRawData; |
|
37 int32_t mStride; |
|
38 SurfaceFormat mFormat; |
|
39 IntSize mSize; |
|
40 bool mOwnData; |
|
41 }; |
|
42 |
|
43 class SourceSurfaceAlignedRawData : public DataSourceSurface |
|
44 { |
|
45 public: |
|
46 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceAlignedRawData) |
|
47 SourceSurfaceAlignedRawData() {} |
|
48 |
|
49 virtual uint8_t *GetData() { return mArray; } |
|
50 virtual int32_t Stride() { return mStride; } |
|
51 |
|
52 virtual SurfaceType GetType() const { return SurfaceType::DATA; } |
|
53 virtual IntSize GetSize() const { return mSize; } |
|
54 virtual SurfaceFormat GetFormat() const { return mFormat; } |
|
55 |
|
56 bool Init(const IntSize &aSize, |
|
57 SurfaceFormat aFormat); |
|
58 bool InitWithStride(const IntSize &aSize, |
|
59 SurfaceFormat aFormat, |
|
60 int32_t aStride); |
|
61 |
|
62 private: |
|
63 AlignedArray<uint8_t> mArray; |
|
64 int32_t mStride; |
|
65 SurfaceFormat mFormat; |
|
66 IntSize mSize; |
|
67 }; |
|
68 |
|
69 } |
|
70 } |
|
71 |
|
72 #endif /* MOZILLA_GFX_SOURCESURFACERAWDATA_H_ */ |