/*
 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#include "config.h"
#include "SurfaceOpenVG.h"

#include "IntSize.h"
#include "PainterOpenVG.h"
#include "VGUtils.h"


#include <stdio.h>
#include <vgu.h>
#include <wtf/Assertions.h>

namespace WebCore {

DLL_PUBLIC PainterOpenVG* SurfaceOpenVG::s_currentPainter = 0;

SurfaceOpenVG* SurfaceOpenVG::currentSurface()
{
    //fprintf(stderr, "Cannot get current surface!\n");
    ASSERT_NOT_REACHED();
    return 0;
}



DLL_PUBLIC bool SurfaceOpenVG::isValid() const
{
#if USE(ACCELERATED_COMPOSITING)
    if (m_espialTexture != NULL)
        return true;
#endif
    return m_espialSurface != NULL;
}


#if 0
SurfaceOpenVG* SurfaceOpenVG::sharedSurface() const
{
    ASSERT_NOT_REACHED();
    return 0;
}
#endif



void SurfaceOpenVG::flush()
{
}

void SurfaceOpenVG::setActivePainter(PainterOpenVG* painter)
{
    ASSERT(isValid());

    // If painter is non-zero, we want to make sure there was no previous painter set.
    ASSERT(!painter || !m_activePainter);

    // Make sure a disabled painter isn't marked as global current painter anymore.
    if (!painter && s_currentPainter == m_activePainter)
        s_currentPainter = 0;

    m_activePainter = painter;
}

}
