|
1 /* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */ |
|
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 SURFACE_FACTORY_H_ |
|
7 #define SURFACE_FACTORY_H_ |
|
8 |
|
9 #include <queue> |
|
10 #include "SurfaceTypes.h" |
|
11 #include "gfxPoint.h" |
|
12 |
|
13 namespace mozilla { |
|
14 namespace gfx { |
|
15 // Forward: |
|
16 class SharedSurface; |
|
17 |
|
18 class SurfaceFactory |
|
19 { |
|
20 protected: |
|
21 SurfaceCaps mCaps; |
|
22 SharedSurfaceType mType; |
|
23 |
|
24 SurfaceFactory(SharedSurfaceType type, const SurfaceCaps& caps) |
|
25 : mCaps(caps) |
|
26 , mType(type) |
|
27 {} |
|
28 |
|
29 public: |
|
30 virtual ~SurfaceFactory(); |
|
31 |
|
32 protected: |
|
33 virtual SharedSurface* CreateShared(const gfx::IntSize& size) = 0; |
|
34 |
|
35 std::queue<SharedSurface*> mScraps; |
|
36 |
|
37 public: |
|
38 SharedSurface* NewSharedSurface(const gfx::IntSize& size); |
|
39 |
|
40 // Auto-deletes surfs of the wrong type. |
|
41 void Recycle(SharedSurface*& surf); |
|
42 |
|
43 const SurfaceCaps& Caps() const { |
|
44 return mCaps; |
|
45 } |
|
46 |
|
47 SharedSurfaceType Type() const { |
|
48 return mType; |
|
49 } |
|
50 }; |
|
51 |
|
52 } // namespace gfx |
|
53 } // namespace mozilla |
|
54 |
|
55 #endif // SURFACE_FACTORY_H_ |