OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2016 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 GrSurfaceProxy_DEFINED |
| 9 #define GrSurfaceProxy_DEFINED |
| 10 |
| 11 #include "GrGpuResource.h" |
| 12 |
| 13 class GrTextureProxy; |
| 14 class GrRenderTargetProxy; |
| 15 |
| 16 class GrSurfaceProxy : public GrIORef<GrSurfaceProxy> { |
| 17 public: |
| 18 const GrSurfaceDesc& desc() const { return fDesc; } |
| 19 |
| 20 GrSurfaceOrigin origin() const { |
| 21 SkASSERT(kTopLeft_GrSurfaceOrigin == fDesc.fOrigin || |
| 22 kBottomLeft_GrSurfaceOrigin == fDesc.fOrigin); |
| 23 return fDesc.fOrigin; |
| 24 } |
| 25 int width() const { return fDesc.fWidth; } |
| 26 int height() const { return fDesc.fWidth; } |
| 27 GrPixelConfig config() const { return fDesc.fConfig; } |
| 28 |
| 29 uint32_t uniqueID() const { return fUniqueID; } |
| 30 |
| 31 /** |
| 32 * @return the texture proxy associated with the surface proxy, may be NULL. |
| 33 */ |
| 34 virtual GrTextureProxy* asTextureProxy() { return nullptr; } |
| 35 virtual const GrTextureProxy* asTextureProxy() const { return nullptr; } |
| 36 |
| 37 /** |
| 38 * @return the render target proxy associated with the surface proxy, may be
NULL. |
| 39 */ |
| 40 virtual GrRenderTargetProxy* asRenderTargetProxy() { return nullptr; } |
| 41 virtual const GrRenderTargetProxy* asRenderTargetProxy() const { return null
ptr; } |
| 42 |
| 43 protected: |
| 44 GrSurfaceProxy(const GrSurfaceDesc& desc, SkBackingFit fit, SkBudgeted budge
ted) |
| 45 : fDesc(desc) |
| 46 , fFit(fit) |
| 47 , fBudgeted(budgeted) |
| 48 , fUniqueID(CreateUniqueID()) { |
| 49 } |
| 50 |
| 51 virtual ~GrSurfaceProxy() {} |
| 52 |
| 53 // For wrapped resources, 'fDesc' will always be filled in from the wrapped
resource. |
| 54 const GrSurfaceDesc fDesc; |
| 55 const SkBackingFit fFit; // always exact for wrapped resources |
| 56 const SkBudgeted fBudgeted; // set from the backing resource for wrapped
resources |
| 57 const uint32_t fUniqueID; |
| 58 |
| 59 private: |
| 60 static uint32_t CreateUniqueID(); |
| 61 |
| 62 // See comment in GrGpuResource.h. |
| 63 void notifyAllCntsAreZero(CntType) const { delete this; } |
| 64 bool notifyRefCountIsZero() const { return true; } |
| 65 |
| 66 typedef GrIORef<GrSurfaceProxy> INHERITED; |
| 67 |
| 68 // to access notifyAllCntsAreZero and notifyRefCntIsZero. |
| 69 friend class GrIORef<GrSurfaceProxy>; |
| 70 }; |
| 71 |
| 72 #endif |
OLD | NEW |