Home | History | Annotate | Download | only in vk
      1 /*
      2 * Copyright 2015 Google Inc.
      3 *
      4 * Use of this source code is governed by a BSD-style license that can be
      5 * found in the LICENSE file.
      6 */
      7 
      8 #ifndef GrVkStencil_DEFINED
      9 #define GrVkStencil_DEFINED
     10 
     11 #include "GrStencilAttachment.h"
     12 #include "GrVkImage.h"
     13 #include "vk/GrVkDefines.h"
     14 
     15 class GrVkImageView;
     16 class GrVkGpu;
     17 
     18 class GrVkStencilAttachment : public GrStencilAttachment, public GrVkImage {
     19 public:
     20     struct Format {
     21         VkFormat  fInternalFormat;
     22         int  fStencilBits;
     23         int  fTotalBits;
     24         bool fPacked;
     25     };
     26 
     27     static GrVkStencilAttachment* Create(GrVkGpu* gpu, int width, int height,
     28                                          int sampleCnt, const Format& format);
     29 
     30     ~GrVkStencilAttachment() override;
     31 
     32     const GrVkResource* imageResource() const { return this->resource(); }
     33     const GrVkImageView* stencilView() const { return fStencilView; }
     34 
     35     VkFormat vkFormat() const { return fFormat.fInternalFormat; }
     36 
     37 protected:
     38     void onRelease() override;
     39     void onAbandon() override;
     40 
     41 private:
     42     size_t onGpuMemorySize() const override;
     43 
     44     GrVkStencilAttachment(GrVkGpu* gpu,
     45                           const Format& format,
     46                           const GrVkImage::ImageDesc&,
     47                           const GrVkImageInfo&,
     48                           const GrVkImageView* stencilView);
     49 
     50     GrVkGpu* getVkGpu() const;
     51 
     52     Format fFormat;
     53 
     54     const GrVkImageView*       fStencilView;
     55 };
     56 
     57 #endif
     58