|
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_SOURCESURFACESKIA_H_ |
|
7 #define MOZILLA_GFX_SOURCESURFACESKIA_H_ |
|
8 |
|
9 #include "2D.h" |
|
10 #include <vector> |
|
11 #include "skia/SkCanvas.h" |
|
12 #include "skia/SkBitmap.h" |
|
13 |
|
14 namespace mozilla { |
|
15 namespace gfx { |
|
16 |
|
17 class DrawTargetSkia; |
|
18 |
|
19 class SourceSurfaceSkia : public DataSourceSurface |
|
20 { |
|
21 public: |
|
22 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceSkia) |
|
23 SourceSurfaceSkia(); |
|
24 ~SourceSurfaceSkia(); |
|
25 |
|
26 virtual SurfaceType GetType() const { return SurfaceType::SKIA; } |
|
27 virtual IntSize GetSize() const; |
|
28 virtual SurfaceFormat GetFormat() const; |
|
29 |
|
30 SkBitmap& GetBitmap() { return mBitmap; } |
|
31 |
|
32 bool InitFromData(unsigned char* aData, |
|
33 const IntSize &aSize, |
|
34 int32_t aStride, |
|
35 SurfaceFormat aFormat); |
|
36 |
|
37 bool InitFromCanvas(SkCanvas* aCanvas, |
|
38 SurfaceFormat aFormat, |
|
39 DrawTargetSkia* aOwner); |
|
40 |
|
41 virtual unsigned char *GetData(); |
|
42 |
|
43 virtual int32_t Stride() { return mStride; } |
|
44 |
|
45 private: |
|
46 friend class DrawTargetSkia; |
|
47 |
|
48 void DrawTargetWillChange(); |
|
49 void MaybeUnlock(); |
|
50 |
|
51 SkBitmap mBitmap; |
|
52 SurfaceFormat mFormat; |
|
53 IntSize mSize; |
|
54 int32_t mStride; |
|
55 RefPtr<DrawTargetSkia> mDrawTarget; |
|
56 bool mLocked; |
|
57 }; |
|
58 |
|
59 } |
|
60 } |
|
61 |
|
62 #endif /* MOZILLA_GFX_SOURCESURFACESKIA_H_ */ |