Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 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 GrTextureContext_DEFINED |
| 9 | #define GrTextureContext_DEFINED |
| 10 | |
| 11 | #include "GrSurfaceContext.h" |
| 12 | #include "../private/GrTextureProxy.h" |
| 13 | |
| 14 | class GrContext; |
| 15 | class GrDrawingManager; |
| 16 | class GrSurface; |
| 17 | class GrTextureOpList; |
| 18 | class GrTextureProxy; |
| 19 | struct SkIPoint; |
| 20 | struct SkIRect; |
| 21 | |
| 22 | /** |
| 23 | * A helper object to orchestrate commands (currently just copies) for GrSurfaces that are |
| 24 | * GrTextures and not GrRenderTargets. |
| 25 | */ |
| 26 | class SK_API GrTextureContext : public GrSurfaceContext { |
| 27 | public: |
| 28 | ~GrTextureContext() override; |
| 29 | |
Robert Phillips | 2734136 | 2016-12-14 08:46:47 -0500 | [diff] [blame] | 30 | GrSurfaceProxy* asDeferredSurface() override { return fTextureProxy.get(); } |
| 31 | GrTextureProxy* asDeferredTexture() override { return fTextureProxy.get(); } |
| 32 | GrRenderTargetProxy* asDeferredRenderTarget() override; |
| 33 | |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 34 | protected: |
Robert Phillips | 2c86249 | 2017-01-18 10:08:39 -0500 | [diff] [blame] | 35 | GrTextureContext(GrContext*, GrDrawingManager*, sk_sp<GrTextureProxy>, |
| 36 | sk_sp<SkColorSpace>, GrAuditTrail*, GrSingleOwner*); |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 37 | |
| 38 | GrDrawingManager* drawingManager() { return fDrawingManager; } |
| 39 | |
| 40 | SkDEBUGCODE(void validate() const;) |
| 41 | |
| 42 | private: |
| 43 | friend class GrDrawingManager; // for ctor |
| 44 | |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 45 | bool onCopy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override; |
Robert Phillips | 2c86249 | 2017-01-18 10:08:39 -0500 | [diff] [blame] | 46 | bool onReadPixels(const SkImageInfo& dstInfo, void* dstBuffer, |
| 47 | size_t dstRowBytes, int x, int y) override; |
| 48 | bool onWritePixels(const SkImageInfo& srcInfo, const void* srcBuffer, |
| 49 | size_t srcRowBytes, int x, int y) override; |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 50 | |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 51 | GrTextureOpList* getOpList(); |
| 52 | |
| 53 | GrDrawingManager* fDrawingManager; |
| 54 | sk_sp<GrTextureProxy> fTextureProxy; |
| 55 | |
| 56 | // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked |
| 57 | // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'. |
| 58 | GrTextureOpList* fOpList; |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 59 | |
| 60 | typedef GrSurfaceContext INHERITED; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | #endif |