Home | History | Annotate | Download | only in image
      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 
     11 #include "GrContext.h"
     12 #include "GrGpuResourcePriv.h"
     13 #include "GrSurfaceProxyPriv.h"
     14 #include "SkGr.h"
     15 #include "SkImagePriv.h"
     16 #include "SkImage_GpuBase.h"
     17 
     18 class GrTexture;
     19 
     20 class SkBitmap;
     21 struct SkYUVAIndex;
     22 
     23 class SkImage_Gpu : public SkImage_GpuBase {
     24 public:
     25     SkImage_Gpu(sk_sp<GrContext>, uint32_t uniqueID, SkAlphaType, sk_sp<GrTextureProxy>,
     26                 sk_sp<SkColorSpace>);
     27     ~SkImage_Gpu() override;
     28 
     29     SkImageInfo onImageInfo() const override;
     30 
     31     GrTextureProxy* peekProxy() const override {
     32         return fProxy.get();
     33     }
     34     sk_sp<GrTextureProxy> asTextureProxyRef() const override {
     35         return fProxy;
     36     }
     37 
     38     virtual bool onIsTextureBacked() const override { return SkToBool(fProxy.get()); }
     39 
     40     sk_sp<SkImage> onMakeColorTypeAndColorSpace(SkColorType, sk_sp<SkColorSpace>) const final;
     41 
     42     /**
     43      * This is the implementation of SkDeferredDisplayListRecorder::makePromiseImage.
     44      */
     45     static sk_sp<SkImage> MakePromiseTexture(GrContext* context,
     46                                              const GrBackendFormat& backendFormat,
     47                                              int width,
     48                                              int height,
     49                                              GrMipMapped mipMapped,
     50                                              GrSurfaceOrigin origin,
     51                                              SkColorType colorType,
     52                                              SkAlphaType alphaType,
     53                                              sk_sp<SkColorSpace> colorSpace,
     54                                              PromiseImageTextureFulfillProc textureFulfillProc,
     55                                              PromiseImageTextureReleaseProc textureReleaseProc,
     56                                              PromiseImageTextureDoneProc textureDoneProc,
     57                                              PromiseImageTextureContext textureContext,
     58                                              DelayReleaseCallback delayReleaseCallback);
     59 
     60     static sk_sp<SkImage> ConvertYUVATexturesToRGB(GrContext*, SkYUVColorSpace yuvColorSpace,
     61                                                    const GrBackendTexture yuvaTextures[],
     62                                                    const SkYUVAIndex yuvaIndices[4],
     63                                                    SkISize imageSize, GrSurfaceOrigin imageOrigin,
     64                                                    GrRenderTargetContext*);
     65 
     66 private:
     67     sk_sp<GrTextureProxy> fProxy;
     68 
     69     typedef SkImage_GpuBase INHERITED;
     70 };
     71 
     72 #endif
     73