Home | History | Annotate | Download | only in renderer
      1 //
      2 // Copyright (c) 2002-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 // Image9.h: Defines the rx::Image9 class, which acts as the interface to
      8 // the actual underlying surfaces of a Texture.
      9 
     10 #ifndef LIBGLESV2_RENDERER_IMAGE9_H_
     11 #define LIBGLESV2_RENDERER_IMAGE9_H_
     12 
     13 #include "libGLESv2/renderer/Image.h"
     14 #include "common/debug.h"
     15 
     16 namespace gl
     17 {
     18 class Framebuffer;
     19 }
     20 
     21 namespace rx
     22 {
     23 class Renderer;
     24 class Renderer9;
     25 class TextureStorageInterface2D;
     26 class TextureStorageInterfaceCube;
     27 
     28 class Image9 : public Image
     29 {
     30   public:
     31     Image9();
     32     ~Image9();
     33 
     34     static Image9 *makeImage9(Image *img);
     35 
     36     static void generateMipmap(Image9 *dest, Image9 *source);
     37     static void generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 *sourceSurface);
     38     static void copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface9 *source);
     39 
     40     virtual bool redefine(Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, bool forceRelease);
     41 
     42     virtual bool isRenderableFormat() const;
     43     D3DFORMAT getD3DFormat() const;
     44 
     45     virtual bool isDirty() const {return mSurface && mDirty;}
     46     IDirect3DSurface9 *getSurface();
     47 
     48     virtual void setManagedSurface(TextureStorageInterface2D *storage, int level);
     49     virtual void setManagedSurface(TextureStorageInterfaceCube *storage, int face, int level);
     50     virtual bool updateSurface(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
     51     virtual bool updateSurface(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
     52 
     53     virtual void loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
     54                   GLint unpackAlignment, const void *input);
     55     virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
     56                                     const void *input);
     57 
     58     virtual void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
     59 
     60   private:
     61     DISALLOW_COPY_AND_ASSIGN(Image9);
     62 
     63     void createSurface();
     64     void setManagedSurface(IDirect3DSurface9 *surface);
     65     bool updateSurface(IDirect3DSurface9 *dest, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
     66 
     67     HRESULT lock(D3DLOCKED_RECT *lockedRect, const RECT *rect);
     68     void unlock();
     69 
     70     Renderer9 *mRenderer;
     71 
     72     D3DPOOL mD3DPool;   // can only be D3DPOOL_SYSTEMMEM or D3DPOOL_MANAGED since it needs to be lockable.
     73     D3DFORMAT mD3DFormat;
     74 
     75     IDirect3DSurface9 *mSurface;
     76 };
     77 }
     78 
     79 #endif   // LIBGLESV2_RENDERER_IMAGE9_H_
     80