Hash :
f4bf3811
Author :
Date :
2015-04-01T16:15:32
Use GetAs/GetImplAs whenever possible. This patch cleans up the rest of our custom casting helper functions. Change-Id: I41975c736765fca855c4498acca31116df3e8317 Reviewed-on: https://chromium-review.googlesource.com/263477 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Brandon Jones <bajones@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
//
// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// RenderTarget9.cpp: Implements a D3D9-specific wrapper for IDirect3DSurface9
// pointers retained by renderbuffers.
#include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h"
#include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
#include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h"
#include "libANGLE/renderer/d3d/d3d9/SwapChain9.h"
#include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
namespace rx
{
// TODO: AddRef the incoming surface to take ownership instead of expecting that its ref is being given.
TextureRenderTarget9::TextureRenderTarget9(IDirect3DSurface9 *surface, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth,
GLsizei samples)
: mWidth(width),
mHeight(height),
mDepth(depth),
mInternalFormat(internalFormat),
mD3DFormat(D3DFMT_UNKNOWN),
mSamples(samples),
mRenderTarget(surface)
{
ASSERT(mDepth == 1);
if (mRenderTarget)
{
D3DSURFACE_DESC description;
mRenderTarget->GetDesc(&description);
mD3DFormat = description.Format;
}
}
TextureRenderTarget9::~TextureRenderTarget9()
{
SafeRelease(mRenderTarget);
}
GLsizei TextureRenderTarget9::getWidth() const
{
return mWidth;
}
GLsizei TextureRenderTarget9::getHeight() const
{
return mHeight;
}
GLsizei TextureRenderTarget9::getDepth() const
{
return mDepth;
}
GLenum TextureRenderTarget9::getInternalFormat() const
{
return mInternalFormat;
}
GLsizei TextureRenderTarget9::getSamples() const
{
return mSamples;
}
IDirect3DSurface9 *TextureRenderTarget9::getSurface()
{
// Caller is responsible for releasing the returned surface reference.
// TODO: remove the AddRef to match RenderTarget11
if (mRenderTarget)
{
mRenderTarget->AddRef();
}
return mRenderTarget;
}
D3DFORMAT TextureRenderTarget9::getD3DFormat() const
{
return mD3DFormat;
}
SurfaceRenderTarget9::SurfaceRenderTarget9(SwapChain9 *swapChain, bool depth)
: mSwapChain(swapChain),
mDepth(depth)
{
}
SurfaceRenderTarget9::~SurfaceRenderTarget9()
{
}
GLsizei SurfaceRenderTarget9::getWidth() const
{
return mSwapChain->getWidth();
}
GLsizei SurfaceRenderTarget9::getHeight() const
{
return mSwapChain->getHeight();
}
GLsizei SurfaceRenderTarget9::getDepth() const
{
return 1;
}
GLenum SurfaceRenderTarget9::getInternalFormat() const
{
return (mDepth ? mSwapChain->GetDepthBufferInternalFormat() : mSwapChain->GetBackBufferInternalFormat());
}
GLsizei SurfaceRenderTarget9::getSamples() const
{
// Our EGL surfaces do not support multisampling.
return 0;
}
IDirect3DSurface9 *SurfaceRenderTarget9::getSurface()
{
return (mDepth ? mSwapChain->getDepthStencil() : mSwapChain->getRenderTarget());
}
D3DFORMAT SurfaceRenderTarget9::getD3DFormat() const
{
return d3d9::GetTextureFormatInfo(getInternalFormat()).texFormat;
}
}