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 // Image9.h: Defines the rx::Image9 class, which acts as the interface to
8 // the actual underlying surfaces of a Texture.
9 
10 #ifndef LIBANGLE_RENDERER_D3D_D3D9_IMAGE9_H_
11 #define LIBANGLE_RENDERER_D3D_D3D9_IMAGE9_H_
12 
13 #include "libANGLE/renderer/d3d/ImageD3D.h"
14 #include "common/debug.h"
15 
16 namespace gl
17 {
18 class Framebuffer;
19 }
20 
21 namespace rx
22 {
23 class Renderer9;
24 
25 class Image9 : public ImageD3D
26 {
27   public:
28     Image9(Renderer9 *renderer);
29     ~Image9();
30 
31     static gl::Error generateMipmap(Image9 *dest, Image9 *source);
32     static gl::Error generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 *sourceSurface);
33     static gl::Error copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface9 *source);
34 
35     bool redefine(GLenum target, GLenum internalformat, const gl::Extents &size, bool forceRelease) override;
36 
37     D3DFORMAT getD3DFormat() const;
38 
39     virtual bool isDirty() const;
40 
41     virtual gl::Error setManagedSurface2D(TextureStorage *storage, int level);
42     virtual gl::Error setManagedSurfaceCube(TextureStorage *storage, int face, int level);
43     virtual gl::Error copyToStorage(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region);
44 
45     gl::Error loadData(const gl::Box &area,
46                        const gl::PixelUnpackState &unpack,
47                        GLenum type,
48                        const void *input,
49                        bool applySkipImages) override;
50     gl::Error loadCompressedData(const gl::Box &area, const void *input) override;
51 
52     gl::Error copyFromTexStorage(const gl::ImageIndex &imageIndex, TextureStorage *source) override;
53     gl::Error copyFromFramebuffer(const gl::Offset &destOffset,
54                                   const gl::Rectangle &sourceArea,
55                                   const gl::Framebuffer *source) override;
56 
57   private:
58     gl::Error getSurface(IDirect3DSurface9 **outSurface);
59 
60     gl::Error createSurface();
61     gl::Error setManagedSurface(IDirect3DSurface9 *surface);
62     gl::Error copyToSurface(IDirect3DSurface9 *dest, const gl::Box &area);
63 
64     gl::Error lock(D3DLOCKED_RECT *lockedRect, const RECT &rect);
65     void unlock();
66 
67     gl::Error copyFromRTInternal(const gl::Offset &destOffset,
68                                  const gl::Rectangle &sourceArea,
69                                  RenderTargetD3D *source);
70 
71     Renderer9 *mRenderer;
72 
73     D3DPOOL mD3DPool;   // can only be D3DPOOL_SYSTEMMEM or D3DPOOL_MANAGED since it needs to be lockable.
74     D3DFORMAT mD3DFormat;
75 
76     IDirect3DSurface9 *mSurface;
77 };
78 }
79 
80 #endif   // LIBANGLE_RENDERER_D3D_D3D9_IMAGE9_H_
81