Stephen White | 0850dcd | 2019-08-13 15:28:47 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 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 GrDawnTexture_DEFINED |
| 9 | #define GrDawnTexture_DEFINED |
| 10 | |
| 11 | #include "include/gpu/GrTexture.h" |
| 12 | #include "dawn/dawncpp.h" |
| 13 | |
| 14 | class GrDawnGpu; |
| 15 | struct GrDawnImageInfo; |
| 16 | |
| 17 | class GrDawnTexture : public GrTexture { |
| 18 | public: |
| 19 | static sk_sp<GrDawnTexture> Make(GrDawnGpu*, const SkISize& size, GrPixelConfig config, |
| 20 | dawn::TextureFormat format, GrRenderable, int sampleCnt, |
| 21 | SkBudgeted, int mipLevels, GrMipMapsStatus); |
| 22 | |
| 23 | static sk_sp<GrDawnTexture> MakeWrapped(GrDawnGpu*, const SkISize& size, GrPixelConfig config, |
Stephen White | 7a2930a | 2019-08-16 16:48:50 -0400 | [diff] [blame] | 24 | GrRenderable, int sampleCnt, |
Stephen White | 0850dcd | 2019-08-13 15:28:47 -0400 | [diff] [blame] | 25 | GrMipMapsStatus, GrWrapCacheable, |
| 26 | const GrDawnImageInfo&); |
| 27 | |
| 28 | ~GrDawnTexture() override; |
| 29 | |
| 30 | GrBackendTexture getBackendTexture() const override; |
| 31 | GrBackendFormat backendFormat() const override; |
| 32 | |
| 33 | void textureParamsModified() override {} |
| 34 | |
Stephen White | d729e2d | 2019-08-28 12:37:47 -0400 | [diff] [blame] | 35 | void upload(const GrMipLevel texels[], int mipLevels, dawn::CommandEncoder copyEncoder); |
| 36 | void upload(const GrMipLevel texels[], int mipLevels, const SkIRect& dstRect, |
| 37 | dawn::CommandEncoder copyEncoder); |
Stephen White | 0850dcd | 2019-08-13 15:28:47 -0400 | [diff] [blame] | 38 | |
| 39 | dawn::Texture texture() const { return fInfo.fTexture; } |
| 40 | dawn::TextureView textureView() const { return fTextureView; } |
| 41 | protected: |
| 42 | GrDawnTexture(GrDawnGpu*, const SkISize& size, GrPixelConfig config, |
| 43 | dawn::TextureView, const GrDawnImageInfo&, GrMipMapsStatus); |
| 44 | |
| 45 | GrDawnGpu* getDawnGpu() const; |
| 46 | |
| 47 | void onAbandon() override; |
| 48 | void onRelease() override; |
| 49 | |
| 50 | bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) override { |
| 51 | return false; |
| 52 | } |
| 53 | |
| 54 | private: |
| 55 | GrDawnTexture(GrDawnGpu*, const GrSurfaceDesc&, const GrDawnImageInfo&, GrMipMapsStatus); |
| 56 | |
| 57 | GrDawnImageInfo fInfo; |
| 58 | dawn::TextureView fTextureView; |
| 59 | |
| 60 | typedef GrTexture INHERITED; |
| 61 | }; |
| 62 | |
| 63 | #endif |