gfx/gl/SurfaceFactory.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/gl/SurfaceFactory.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     1.4 +/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef SURFACE_FACTORY_H_
    1.10 +#define SURFACE_FACTORY_H_
    1.11 +
    1.12 +#include <queue>
    1.13 +#include "SurfaceTypes.h"
    1.14 +#include "gfxPoint.h"
    1.15 +
    1.16 +namespace mozilla {
    1.17 +namespace gfx {
    1.18 +// Forward:
    1.19 +class SharedSurface;
    1.20 +
    1.21 +class SurfaceFactory
    1.22 +{
    1.23 +protected:
    1.24 +    SurfaceCaps mCaps;
    1.25 +    SharedSurfaceType mType;
    1.26 +
    1.27 +    SurfaceFactory(SharedSurfaceType type, const SurfaceCaps& caps)
    1.28 +        : mCaps(caps)
    1.29 +        , mType(type)
    1.30 +    {}
    1.31 +
    1.32 +public:
    1.33 +    virtual ~SurfaceFactory();
    1.34 +
    1.35 +protected:
    1.36 +    virtual SharedSurface* CreateShared(const gfx::IntSize& size) = 0;
    1.37 +
    1.38 +    std::queue<SharedSurface*> mScraps;
    1.39 +
    1.40 +public:
    1.41 +    SharedSurface* NewSharedSurface(const gfx::IntSize& size);
    1.42 +
    1.43 +    // Auto-deletes surfs of the wrong type.
    1.44 +    void Recycle(SharedSurface*& surf);
    1.45 +
    1.46 +    const SurfaceCaps& Caps() const {
    1.47 +        return mCaps;
    1.48 +    }
    1.49 +
    1.50 +    SharedSurfaceType Type() const {
    1.51 +        return mType;
    1.52 +    }
    1.53 +};
    1.54 +
    1.55 +}   // namespace gfx
    1.56 +}   // namespace mozilla
    1.57 +
    1.58 +#endif  // SURFACE_FACTORY_H_

mercurial