gfx/angle/src/libGLESv2/renderer/TextureStorage.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/angle/src/libGLESv2/renderer/TextureStorage.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,122 @@
     1.4 +#include "precompiled.h"
     1.5 +//
     1.6 +// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
     1.7 +// Use of this source code is governed by a BSD-style license that can be
     1.8 +// found in the LICENSE file.
     1.9 +//
    1.10 +
    1.11 +// TextureStorage.cpp: Implements the abstract rx::TextureStorageInterface class and its concrete derived
    1.12 +// classes TextureStorageInterface2D and TextureStorageInterfaceCube, which act as the interface to the
    1.13 +// GPU-side texture.
    1.14 +
    1.15 +#include "libGLESv2/renderer/TextureStorage.h"
    1.16 +#include "libGLESv2/renderer/Renderer.h"
    1.17 +#include "libGLESv2/Renderbuffer.h"
    1.18 +#include "libGLESv2/Texture.h"
    1.19 +
    1.20 +#include "common/debug.h"
    1.21 +
    1.22 +namespace rx
    1.23 +{
    1.24 +unsigned int TextureStorageInterface::mCurrentTextureSerial = 1;
    1.25 +
    1.26 +TextureStorageInterface::TextureStorageInterface()
    1.27 +    : mTextureSerial(issueTextureSerial()),
    1.28 +      mInstance(NULL)
    1.29 +{
    1.30 +}
    1.31 +
    1.32 +TextureStorageInterface::~TextureStorageInterface()
    1.33 +{
    1.34 +    delete mInstance;
    1.35 +}
    1.36 +
    1.37 +bool TextureStorageInterface::isRenderTarget() const
    1.38 +{
    1.39 +    return mInstance->isRenderTarget();
    1.40 +}
    1.41 +
    1.42 +
    1.43 +bool TextureStorageInterface::isManaged() const
    1.44 +{
    1.45 +    return mInstance->isManaged();
    1.46 +}
    1.47 +
    1.48 +unsigned int TextureStorageInterface::getTextureSerial() const
    1.49 +{
    1.50 +    return mTextureSerial;
    1.51 +}
    1.52 +
    1.53 +unsigned int TextureStorageInterface::issueTextureSerial()
    1.54 +{
    1.55 +    return mCurrentTextureSerial++;
    1.56 +}
    1.57 +
    1.58 +int TextureStorageInterface::getLodOffset() const
    1.59 +{
    1.60 +    return mInstance->getLodOffset();
    1.61 +}
    1.62 +
    1.63 +
    1.64 +int TextureStorageInterface::levelCount()
    1.65 +{
    1.66 +    return mInstance->levelCount();
    1.67 +}
    1.68 +
    1.69 +TextureStorageInterface2D::TextureStorageInterface2D(Renderer *renderer, SwapChain *swapchain) 
    1.70 +    : mRenderTargetSerial(gl::RenderbufferStorage::issueSerial())
    1.71 +{
    1.72 +    mInstance = renderer->createTextureStorage2D(swapchain);
    1.73 +}
    1.74 +
    1.75 +TextureStorageInterface2D::TextureStorageInterface2D(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height)
    1.76 +    : mRenderTargetSerial(gl::RenderbufferStorage::issueSerial())
    1.77 +{
    1.78 +    mInstance = renderer->createTextureStorage2D(levels, internalformat, usage, forceRenderable, width, height);
    1.79 +}
    1.80 +
    1.81 +TextureStorageInterface2D::~TextureStorageInterface2D()
    1.82 +{
    1.83 +}
    1.84 +
    1.85 +RenderTarget *TextureStorageInterface2D::getRenderTarget() const
    1.86 +{
    1.87 +    return mInstance->getRenderTarget();
    1.88 +}
    1.89 +
    1.90 +void TextureStorageInterface2D::generateMipmap(int level)
    1.91 +{
    1.92 +    mInstance->generateMipmap(level);
    1.93 +}
    1.94 +
    1.95 +unsigned int TextureStorageInterface2D::getRenderTargetSerial(GLenum target) const
    1.96 +{
    1.97 +    return mRenderTargetSerial;
    1.98 +}
    1.99 +
   1.100 +TextureStorageInterfaceCube::TextureStorageInterfaceCube(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size)
   1.101 +    : mFirstRenderTargetSerial(gl::RenderbufferStorage::issueCubeSerials())
   1.102 +{
   1.103 +    mInstance = renderer->createTextureStorageCube(levels, internalformat, usage, forceRenderable, size);
   1.104 +}
   1.105 +
   1.106 +TextureStorageInterfaceCube::~TextureStorageInterfaceCube()
   1.107 +{
   1.108 +}
   1.109 +
   1.110 +RenderTarget *TextureStorageInterfaceCube::getRenderTarget(GLenum faceTarget) const
   1.111 +{
   1.112 +    return mInstance->getRenderTarget(faceTarget);
   1.113 +}
   1.114 +
   1.115 +void TextureStorageInterfaceCube::generateMipmap(int face, int level)
   1.116 +{
   1.117 +    mInstance->generateMipmap(face, level);
   1.118 +}
   1.119 +
   1.120 +unsigned int TextureStorageInterfaceCube::getRenderTargetSerial(GLenum target) const
   1.121 +{
   1.122 +    return mFirstRenderTargetSerial + gl::TextureCubeMap::faceIndex(target);
   1.123 +}
   1.124 +
   1.125 +}
   1.126 \ No newline at end of file

mercurial