tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

RenderTarget9.cpp (3906B)


      1 //
      2 // Copyright 2012 The ANGLE Project Authors. All rights reserved.
      3 // Use of this source code is governed by a BSD-style license that can be
      4 // found in the LICENSE file.
      5 //
      6 
      7 // RenderTarget9.cpp: Implements a D3D9-specific wrapper for IDirect3DSurface9
      8 // pointers retained by renderbuffers.
      9 
     10 #include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h"
     11 #include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
     12 #include "libANGLE/renderer/d3d/d3d9/SwapChain9.h"
     13 #include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
     14 #include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h"
     15 
     16 namespace rx
     17 {
     18 
     19 // TODO: AddRef the incoming surface to take ownership instead of expecting that its ref is being
     20 // given.
     21 TextureRenderTarget9::TextureRenderTarget9(IDirect3DBaseTexture9 *texture,
     22                                           size_t textureLevel,
     23                                           IDirect3DSurface9 *surface,
     24                                           GLenum internalFormat,
     25                                           GLsizei width,
     26                                           GLsizei height,
     27                                           GLsizei depth,
     28                                           GLsizei samples)
     29    : mWidth(width),
     30      mHeight(height),
     31      mDepth(depth),
     32      mInternalFormat(internalFormat),
     33      mD3DFormat(D3DFMT_UNKNOWN),
     34      mSamples(samples),
     35      mTexture(texture),
     36      mTextureLevel(textureLevel),
     37      mRenderTarget(surface)
     38 {
     39    ASSERT(mDepth == 1);
     40 
     41    if (mRenderTarget)
     42    {
     43        D3DSURFACE_DESC description;
     44        mRenderTarget->GetDesc(&description);
     45        mD3DFormat = description.Format;
     46    }
     47 }
     48 
     49 TextureRenderTarget9::~TextureRenderTarget9()
     50 {
     51    SafeRelease(mTexture);
     52    SafeRelease(mRenderTarget);
     53 }
     54 
     55 GLsizei TextureRenderTarget9::getWidth() const
     56 {
     57    return mWidth;
     58 }
     59 
     60 GLsizei TextureRenderTarget9::getHeight() const
     61 {
     62    return mHeight;
     63 }
     64 
     65 GLsizei TextureRenderTarget9::getDepth() const
     66 {
     67    return mDepth;
     68 }
     69 
     70 GLenum TextureRenderTarget9::getInternalFormat() const
     71 {
     72    return mInternalFormat;
     73 }
     74 
     75 GLsizei TextureRenderTarget9::getSamples() const
     76 {
     77    return mSamples;
     78 }
     79 
     80 IDirect3DBaseTexture9 *TextureRenderTarget9::getTexture() const
     81 {
     82    return mTexture;
     83 }
     84 
     85 size_t TextureRenderTarget9::getTextureLevel() const
     86 {
     87    return mTextureLevel;
     88 }
     89 
     90 IDirect3DSurface9 *TextureRenderTarget9::getSurface() const
     91 {
     92    // Caller is responsible for releasing the returned surface reference.
     93    // TODO: remove the AddRef to match RenderTarget11
     94    if (mRenderTarget)
     95    {
     96        mRenderTarget->AddRef();
     97    }
     98 
     99    return mRenderTarget;
    100 }
    101 
    102 D3DFORMAT TextureRenderTarget9::getD3DFormat() const
    103 {
    104    return mD3DFormat;
    105 }
    106 
    107 SurfaceRenderTarget9::SurfaceRenderTarget9(SwapChain9 *swapChain, bool depth)
    108    : mSwapChain(swapChain), mDepth(depth)
    109 {}
    110 
    111 SurfaceRenderTarget9::~SurfaceRenderTarget9() {}
    112 
    113 GLsizei SurfaceRenderTarget9::getWidth() const
    114 {
    115    return mSwapChain->getWidth();
    116 }
    117 
    118 GLsizei SurfaceRenderTarget9::getHeight() const
    119 {
    120    return mSwapChain->getHeight();
    121 }
    122 
    123 GLsizei SurfaceRenderTarget9::getDepth() const
    124 {
    125    return 1;
    126 }
    127 
    128 GLenum SurfaceRenderTarget9::getInternalFormat() const
    129 {
    130    return (mDepth ? mSwapChain->getDepthBufferInternalFormat()
    131                   : mSwapChain->getRenderTargetInternalFormat());
    132 }
    133 
    134 GLsizei SurfaceRenderTarget9::getSamples() const
    135 {
    136    // Our EGL surfaces do not support multisampling.
    137    return 0;
    138 }
    139 
    140 IDirect3DSurface9 *SurfaceRenderTarget9::getSurface() const
    141 {
    142    return (mDepth ? mSwapChain->getDepthStencil() : mSwapChain->getRenderTarget());
    143 }
    144 
    145 IDirect3DBaseTexture9 *SurfaceRenderTarget9::getTexture() const
    146 {
    147    return (mDepth ? nullptr : mSwapChain->getOffscreenTexture());
    148 }
    149 
    150 size_t SurfaceRenderTarget9::getTextureLevel() const
    151 {
    152    return 0;
    153 }
    154 
    155 D3DFORMAT SurfaceRenderTarget9::getD3DFormat() const
    156 {
    157    return d3d9::GetTextureFormatInfo(getInternalFormat()).texFormat;
    158 }
    159 
    160 }  // namespace rx