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(GrRecordingContext*) const override {
     35         return fProxy;
     36     }
     37 
     38     bool onIsTextureBacked() const override { return SkToBool(fProxy.get()); }
     39 
     40     sk_sp<SkImage> onMakeColorTypeAndColorSpace(GrRecordingContext*,
     41                                                 SkColorType, sk_sp<SkColorSpace>) const final;
     42 
     43     /**
     44      * This is the implementation of SkDeferredDisplayListRecorder::makePromiseImage.
     45      */
     46     static sk_sp<SkImage> MakePromiseTexture(GrContext* context,
     47                                              const GrBackendFormat& backendFormat,
     48                                              int width,
     49                                              int height,
     50                                              GrMipMapped mipMapped,
     51                                              GrSurfaceOrigin origin,
     52                                              SkColorType colorType,
     53                                              SkAlphaType alphaType,
     54                                              sk_sp<SkColorSpace> colorSpace,
     55                                              PromiseImageTextureFulfillProc textureFulfillProc,
     56                                              PromiseImageTextureReleaseProc textureReleaseProc,
     57                                              PromiseImageTextureDoneProc textureDoneProc,
     58                                              PromiseImageTextureContext textureContext);
     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