bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 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 SkImage_Gpu_DEFINED |
| 9 | #define SkImage_Gpu_DEFINED |
| 10 | |
Brian Salomon | c65aec9 | 2017-03-09 09:03:58 -0500 | [diff] [blame] | 11 | #include "GrClip.h" |
Hal Canary | 271d495 | 2017-02-15 11:21:32 -0500 | [diff] [blame] | 12 | #include "GrContext.h" |
bsalomon | 3582d3e | 2015-02-13 14:20:05 -0800 | [diff] [blame] | 13 | #include "GrGpuResourcePriv.h" |
Robert Phillips | b726d58 | 2017-03-09 16:36:32 -0500 | [diff] [blame] | 14 | #include "GrSurfaceProxyPriv.h" |
Brian Salomon | c65aec9 | 2017-03-09 09:03:58 -0500 | [diff] [blame] | 15 | #include "SkAtomics.h" |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 16 | #include "SkBitmap.h" |
herb | a7c9d63 | 2016-04-19 12:30:22 -0700 | [diff] [blame] | 17 | #include "SkGr.h" |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 18 | #include "SkImagePriv.h" |
Brian Salomon | c65aec9 | 2017-03-09 09:03:58 -0500 | [diff] [blame] | 19 | #include "SkImage_Base.h" |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 20 | #include "SkSurface.h" |
| 21 | |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 22 | class GrTexture; |
| 23 | |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 24 | class SkImage_Gpu : public SkImage_Base { |
| 25 | public: |
Robert Phillips | b726d58 | 2017-03-09 16:36:32 -0500 | [diff] [blame] | 26 | SkImage_Gpu(GrContext*, uint32_t uniqueID, SkAlphaType, sk_sp<GrTextureProxy>, |
| 27 | sk_sp<SkColorSpace>, SkBudgeted); |
reed | 6f1216a | 2015-08-04 08:10:13 -0700 | [diff] [blame] | 28 | ~SkImage_Gpu() override; |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 29 | |
brianosman | 396fcdb | 2016-07-22 06:26:11 -0700 | [diff] [blame] | 30 | SkImageInfo onImageInfo() const override; |
brianosman | 69c166d | 2016-08-17 14:01:05 -0700 | [diff] [blame] | 31 | SkAlphaType onAlphaType() const override { return fAlphaType; } |
herb | a7c9d63 | 2016-04-19 12:30:22 -0700 | [diff] [blame] | 32 | |
Brian Osman | 61624f0 | 2016-12-09 14:51:59 -0500 | [diff] [blame] | 33 | bool getROPixels(SkBitmap*, SkColorSpace* dstColorSpace, CachingHint) const override; |
reed | 7fb4f8b | 2016-03-11 04:33:52 -0800 | [diff] [blame] | 34 | sk_sp<SkImage> onMakeSubset(const SkIRect&) const override; |
reed | 85d9178 | 2015-09-10 14:33:38 -0700 | [diff] [blame] | 35 | |
Robert Phillips | 8744405 | 2017-06-23 14:09:30 -0400 | [diff] [blame] | 36 | GrContext* context() const override { return fContext; } |
Robert Phillips | 0ae6faa | 2017-03-21 16:22:00 -0400 | [diff] [blame] | 37 | GrTextureProxy* peekProxy() const override { |
| 38 | return fProxy.get(); |
| 39 | } |
Robert Phillips | b726d58 | 2017-03-09 16:36:32 -0500 | [diff] [blame] | 40 | sk_sp<GrTextureProxy> asTextureProxyRef() const override { |
| 41 | return fProxy; |
| 42 | } |
Brian Salomon | 2bbdcc4 | 2017-09-07 12:36:34 -0400 | [diff] [blame^] | 43 | sk_sp<GrTextureProxy> asTextureProxyRef(GrContext*, const GrSamplerState&, SkColorSpace*, |
Robert Phillips | b726d58 | 2017-03-09 16:36:32 -0500 | [diff] [blame] | 44 | sk_sp<SkColorSpace>*, |
| 45 | SkScalar scaleAdjust[2]) const override; |
Robert Phillips | 0ae6faa | 2017-03-21 16:22:00 -0400 | [diff] [blame] | 46 | |
Robert Phillips | 3798c86 | 2017-03-27 11:08:16 -0400 | [diff] [blame] | 47 | sk_sp<GrTextureProxy> refPinnedTextureProxy(uint32_t* uniqueID) const override { |
reed | 2d5b714 | 2016-08-17 11:12:33 -0700 | [diff] [blame] | 48 | *uniqueID = this->uniqueID(); |
Robert Phillips | 3798c86 | 2017-03-27 11:08:16 -0400 | [diff] [blame] | 49 | return fProxy; |
reed | 2d5b714 | 2016-08-17 11:12:33 -0700 | [diff] [blame] | 50 | } |
Robert Phillips | 0ae6faa | 2017-03-21 16:22:00 -0400 | [diff] [blame] | 51 | GrBackendObject onGetTextureHandle(bool flushPendingGrContextIO, |
| 52 | GrSurfaceOrigin* origin) const override; |
| 53 | GrTexture* onGetTexture() const override; |
Robert Phillips | 538f1a3 | 2017-03-08 14:32:55 -0500 | [diff] [blame] | 54 | |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 55 | bool onReadPixels(const SkImageInfo&, void* dstPixels, size_t dstRowBytes, |
reed | 0955303 | 2015-11-23 12:32:16 -0800 | [diff] [blame] | 56 | int srcX, int srcY, CachingHint) const override; |
reed | 88d064d | 2015-10-12 11:30:02 -0700 | [diff] [blame] | 57 | |
Robert Phillips | 2c86249 | 2017-01-18 10:08:39 -0500 | [diff] [blame] | 58 | sk_sp<SkColorSpace> refColorSpace() { return fColorSpace; } |
| 59 | |
Matt Sarett | 9f3dcb3 | 2017-05-04 08:53:32 -0400 | [diff] [blame] | 60 | sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>, SkColorType, |
| 61 | SkTransferFunctionBehavior) const override; |
Brian Osman | 63954c9 | 2017-03-14 12:07:12 -0400 | [diff] [blame] | 62 | |
Brian Osman | 5bbd076 | 2017-05-08 11:07:42 -0400 | [diff] [blame] | 63 | bool onIsValid(GrContext*) const override; |
| 64 | |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 65 | private: |
Robert Phillips | b726d58 | 2017-03-09 16:36:32 -0500 | [diff] [blame] | 66 | GrContext* fContext; |
| 67 | sk_sp<GrTextureProxy> fProxy; |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 68 | const SkAlphaType fAlphaType; |
| 69 | const SkBudgeted fBudgeted; |
| 70 | sk_sp<SkColorSpace> fColorSpace; |
| 71 | mutable SkAtomic<bool> fAddedRasterVersionToCache; |
reed | 6f1216a | 2015-08-04 08:10:13 -0700 | [diff] [blame] | 72 | |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 73 | |
| 74 | typedef SkImage_Base INHERITED; |
| 75 | }; |
| 76 | |
| 77 | #endif |