• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2002 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 "common/debug.h"
14 #include "libANGLE/renderer/d3d/ImageD3D.h"
15 
16 namespace gl
17 {
18 class Framebuffer;
19 }
20 
21 namespace rx
22 {
23 class Context9;
24 class Renderer9;
25 
26 class Image9 : public ImageD3D
27 {
28   public:
29     Image9(Renderer9 *renderer);
30     ~Image9() override;
31 
32     static angle::Result GenerateMipmap(Context9 *context9, Image9 *dest, Image9 *source);
33     static angle::Result GenerateMip(Context9 *context9,
34                                      IDirect3DSurface9 *destSurface,
35                                      IDirect3DSurface9 *sourceSurface);
36     static angle::Result CopyLockableSurfaces(Context9 *context9,
37                                               IDirect3DSurface9 *dest,
38                                               IDirect3DSurface9 *source);
39     static angle::Result CopyImage(const gl::Context *context,
40                                    Image9 *dest,
41                                    Image9 *source,
42                                    const gl::Rectangle &sourceRect,
43                                    const gl::Offset &destOffset,
44                                    bool unpackFlipY,
45                                    bool unpackPremultiplyAlpha,
46                                    bool unpackUnmultiplyAlpha);
47 
48     bool redefine(gl::TextureType type,
49                   GLenum internalformat,
50                   const gl::Extents &size,
51                   bool forceRelease) override;
52 
53     D3DFORMAT getD3DFormat() const;
54 
55     bool isDirty() const override;
56 
57     angle::Result setManagedSurface2D(const gl::Context *context,
58                                       TextureStorage *storage,
59                                       int level) override;
60     angle::Result setManagedSurfaceCube(const gl::Context *context,
61                                         TextureStorage *storage,
62                                         int face,
63                                         int level) override;
64     angle::Result copyToStorage(const gl::Context *context,
65                                 TextureStorage *storage,
66                                 const gl::ImageIndex &index,
67                                 const gl::Box &region) override;
68 
69     angle::Result loadData(const gl::Context *context,
70                            const gl::Box &area,
71                            const gl::PixelUnpackState &unpack,
72                            GLenum type,
73                            const void *input,
74                            bool applySkipImages) override;
75     angle::Result loadCompressedData(const gl::Context *context,
76                                      const gl::Box &area,
77                                      const void *input) override;
78 
79     angle::Result copyFromTexStorage(const gl::Context *context,
80                                      const gl::ImageIndex &imageIndex,
81                                      TextureStorage *source) override;
82     angle::Result copyFromFramebuffer(const gl::Context *context,
83                                       const gl::Offset &destOffset,
84                                       const gl::Rectangle &sourceArea,
85                                       const gl::Framebuffer *source) override;
86 
87   private:
88     angle::Result getSurface(Context9 *context9, IDirect3DSurface9 **outSurface);
89 
90     angle::Result createSurface(Context9 *context9);
91     angle::Result setManagedSurface(Context9 *context9, IDirect3DSurface9 *surface);
92     angle::Result copyToSurface(Context9 *context9, IDirect3DSurface9 *dest, const gl::Box &area);
93 
94     angle::Result lock(Context9 *context9, D3DLOCKED_RECT *lockedRect, const RECT &rect);
95     void unlock();
96 
97     angle::Result copyFromRTInternal(Context9 *context9,
98                                      const gl::Offset &destOffset,
99                                      const gl::Rectangle &sourceArea,
100                                      RenderTargetD3D *source);
101 
102     Renderer9 *mRenderer;
103 
104     D3DPOOL mD3DPool;  // can only be D3DPOOL_SYSTEMMEM or D3DPOOL_MANAGED since it needs to be
105                        // lockable.
106     D3DFORMAT mD3DFormat;
107 
108     IDirect3DSurface9 *mSurface;
109 };
110 }  // namespace rx
111 
112 #endif  // LIBANGLE_RENDERER_D3D_D3D9_IMAGE9_H_
113