Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / angle / src / libGLESv2 / renderer / d3d / d3d9 / renderer9_utils.h
1 //
2 // Copyright (c) 2002-2014 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 // renderer9_utils.h: Conversion functions and other utility routines
8 // specific to the D3D9 renderer
9
10 #ifndef LIBGLESV2_RENDERER_RENDERER9_UTILS_H
11 #define LIBGLESV2_RENDERER_RENDERER9_UTILS_H
12
13 #include "libGLESv2/angletypes.h"
14 #include "libGLESv2/Caps.h"
15 #include "libGLESv2/Error.h"
16
17 namespace gl
18 {
19 class FramebufferAttachment;
20 }
21
22 namespace rx
23 {
24 class RenderTarget9;
25 struct Workarounds;
26
27 namespace gl_d3d9
28 {
29
30 D3DCMPFUNC ConvertComparison(GLenum comparison);
31 D3DCOLOR ConvertColor(gl::ColorF color);
32 D3DBLEND ConvertBlendFunc(GLenum blend);
33 D3DBLENDOP ConvertBlendOp(GLenum blendOp);
34 D3DSTENCILOP ConvertStencilOp(GLenum stencilOp);
35 D3DTEXTUREADDRESS ConvertTextureWrap(GLenum wrap);
36 D3DCULL ConvertCullMode(GLenum cullFace, GLenum frontFace);
37 D3DCUBEMAP_FACES ConvertCubeFace(GLenum cubeFace);
38 DWORD ConvertColorMask(bool red, bool green, bool blue, bool alpha);
39 D3DTEXTUREFILTERTYPE ConvertMagFilter(GLenum magFilter, float maxAnisotropy);
40 void ConvertMinFilter(GLenum minFilter, D3DTEXTUREFILTERTYPE *d3dMinFilter, D3DTEXTUREFILTERTYPE *d3dMipFilter, float maxAnisotropy);
41
42 D3DMULTISAMPLE_TYPE GetMultisampleType(GLuint samples);
43
44 }
45
46 namespace d3d9_gl
47 {
48
49 GLsizei GetSamplesCount(D3DMULTISAMPLE_TYPE type);
50
51 bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format);
52
53 void GenerateCaps(IDirect3D9 *d3d9, IDirect3DDevice9 *device, D3DDEVTYPE deviceType, UINT adapter, gl::Caps *caps,
54                   gl::TextureCapsMap *textureCapsMap, gl::Extensions *extensions);
55
56 }
57
58 namespace d3d9
59 {
60
61 GLuint ComputeBlockSize(D3DFORMAT format, GLuint width, GLuint height);
62
63 void MakeValidSize(bool isImage, D3DFORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset);
64
65 inline bool isDeviceLostError(HRESULT errorCode)
66 {
67     switch (errorCode)
68     {
69       case D3DERR_DRIVERINTERNALERROR:
70       case D3DERR_DEVICELOST:
71       case D3DERR_DEVICEHUNG:
72       case D3DERR_DEVICEREMOVED:
73         return true;
74       default:
75         return false;
76     }
77 }
78
79 gl::Error GetAttachmentRenderTarget(gl::FramebufferAttachment *attachment, RenderTarget9 **outRT);
80 Workarounds GenerateWorkarounds();
81
82 }
83
84 }
85
86 #endif // LIBGLESV2_RENDERER_RENDERER9_UTILS_H