michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "gfxTeeSurface.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsTArray.h" michael@0: michael@0: #include "cairo-tee.h" michael@0: michael@0: gfxTeeSurface::gfxTeeSurface(cairo_surface_t *csurf) michael@0: { michael@0: Init(csurf, true); michael@0: } michael@0: michael@0: gfxTeeSurface::gfxTeeSurface(gfxASurface **aSurfaces, int32_t aSurfaceCount) michael@0: { michael@0: NS_ASSERTION(aSurfaceCount > 0, "Must have a least one surface"); michael@0: cairo_surface_t *csurf = cairo_tee_surface_create(aSurfaces[0]->CairoSurface()); michael@0: Init(csurf, false); michael@0: michael@0: for (int32_t i = 1; i < aSurfaceCount; ++i) { michael@0: cairo_tee_surface_add(csurf, aSurfaces[i]->CairoSurface()); michael@0: } michael@0: } michael@0: michael@0: const gfxIntSize michael@0: gfxTeeSurface::GetSize() const michael@0: { michael@0: nsRefPtr master = Wrap(cairo_tee_surface_index(mSurface, 0)); michael@0: return master->GetSize(); michael@0: } michael@0: michael@0: void michael@0: gfxTeeSurface::GetSurfaces(nsTArray >* aSurfaces) michael@0: { michael@0: for (int32_t i = 0; ; ++i) { michael@0: cairo_surface_t *csurf = cairo_tee_surface_index(mSurface, i); michael@0: if (cairo_surface_status(csurf)) michael@0: break; michael@0: nsRefPtr *elem = aSurfaces->AppendElement(); michael@0: if (!elem) michael@0: return; michael@0: *elem = Wrap(csurf); michael@0: } michael@0: }