Home | History | Annotate | Download | only in image
      1 /*
      2  * Copyright 2014 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 SkSurface_Gpu_DEFINED
      9 #define SkSurface_Gpu_DEFINED
     10 
     11 #include "GrTypesPriv.h"
     12 #include "SkSurface_Base.h"
     13 
     14 #if SK_SUPPORT_GPU
     15 
     16 class SkGpuDevice;
     17 
     18 class SkSurface_Gpu : public SkSurface_Base {
     19 public:
     20     SkSurface_Gpu(sk_sp<SkGpuDevice>);
     21     ~SkSurface_Gpu() override;
     22 
     23     // This is an internal-only factory
     24     static sk_sp<SkSurface> MakeWrappedRenderTarget(GrContext*, sk_sp<GrRenderTargetContext>);
     25 
     26     GrBackendTexture onGetBackendTexture(BackendHandleAccess) override;
     27     GrBackendRenderTarget onGetBackendRenderTarget(BackendHandleAccess) override;
     28 
     29     SkCanvas* onNewCanvas() override;
     30     sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override;
     31     sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subset) override;
     32     void onWritePixels(const SkPixmap&, int x, int y) override;
     33     void onCopyOnWrite(ContentChangeMode) override;
     34     void onDiscard() override;
     35     GrSemaphoresSubmitted onFlush(int numSemaphores,
     36                                   GrBackendSemaphore signalSemaphores[]) override;
     37     bool onWait(int numSemaphores, const GrBackendSemaphore* waitSemaphores) override;
     38     bool onCharacterize(SkSurfaceCharacterization*) const override;
     39     bool isCompatible(const SkSurfaceCharacterization&) const;
     40     bool onDraw(const SkDeferredDisplayList*) override;
     41 
     42     SkGpuDevice* getDevice() { return fDevice.get(); }
     43 
     44     static bool Valid(const SkImageInfo&);
     45     static bool Valid(const GrCaps*, GrPixelConfig, SkColorSpace*);
     46 
     47 private:
     48     sk_sp<SkGpuDevice> fDevice;
     49 
     50     typedef SkSurface_Base INHERITED;
     51 };
     52 
     53 #endif // SK_SUPPORT_GPU
     54 
     55 #endif // SkSurface_Gpu_DEFINED
     56