|
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
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 #include "gfxTeeSurface.h" |
|
7 #include "nsAutoPtr.h" |
|
8 #include "nsTArray.h" |
|
9 |
|
10 #include "cairo-tee.h" |
|
11 |
|
12 gfxTeeSurface::gfxTeeSurface(cairo_surface_t *csurf) |
|
13 { |
|
14 Init(csurf, true); |
|
15 } |
|
16 |
|
17 gfxTeeSurface::gfxTeeSurface(gfxASurface **aSurfaces, int32_t aSurfaceCount) |
|
18 { |
|
19 NS_ASSERTION(aSurfaceCount > 0, "Must have a least one surface"); |
|
20 cairo_surface_t *csurf = cairo_tee_surface_create(aSurfaces[0]->CairoSurface()); |
|
21 Init(csurf, false); |
|
22 |
|
23 for (int32_t i = 1; i < aSurfaceCount; ++i) { |
|
24 cairo_tee_surface_add(csurf, aSurfaces[i]->CairoSurface()); |
|
25 } |
|
26 } |
|
27 |
|
28 const gfxIntSize |
|
29 gfxTeeSurface::GetSize() const |
|
30 { |
|
31 nsRefPtr<gfxASurface> master = Wrap(cairo_tee_surface_index(mSurface, 0)); |
|
32 return master->GetSize(); |
|
33 } |
|
34 |
|
35 void |
|
36 gfxTeeSurface::GetSurfaces(nsTArray<nsRefPtr<gfxASurface> >* aSurfaces) |
|
37 { |
|
38 for (int32_t i = 0; ; ++i) { |
|
39 cairo_surface_t *csurf = cairo_tee_surface_index(mSurface, i); |
|
40 if (cairo_surface_status(csurf)) |
|
41 break; |
|
42 nsRefPtr<gfxASurface> *elem = aSurfaces->AppendElement(); |
|
43 if (!elem) |
|
44 return; |
|
45 *elem = Wrap(csurf); |
|
46 } |
|
47 } |