• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 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 GrMtlCopyManager_DEFINED
9 #define GrMtlCopyManager_DEFINED
10 
11 #include "GrTypes.h"
12 
13 #import <metal/metal.h>
14 
15 class GrMtlCopyPipelineState;
16 class GrMtlGpu;
17 class GrSurface;
18 struct SkIPoint;
19 struct SkIRect;
20 
21 class GrMtlCopyManager {
22 public:
GrMtlCopyManager(GrMtlGpu * gpu)23     GrMtlCopyManager(GrMtlGpu* gpu) : fGpu(gpu) {}
24 
25     bool copySurfaceAsDraw(GrSurface* dst, GrSurfaceOrigin dstOrigin,
26                            GrSurface* src, GrSurfaceOrigin srcOrigin,
27                            const SkIRect& srcRect, const SkIPoint& dstPoint,
28                            bool canDiscardOutsideDstRect);
29 
30     static bool IsCompatible(const GrMtlCopyPipelineState*, MTLPixelFormat dstPixelFormat);
31 
32 private:
33     enum BufferIndex {
34         kUniform_BufferIndex,
35         kAttribute_BufferIndex,
36     };
37 
38     void createCopyProgramBuffer();
39     void createCopyProgramShaders();
40     void createCopyProgramVertexDescriptor();
41 
42     void createCopyProgram();
43 
44     id<MTLSamplerState>  fSamplerState;
45     id<MTLBuffer>        fVertexAttributeBuffer;
46     id<MTLFunction>      fVertexFunction;
47     id<MTLFunction>      fFragmentFunction;
48     MTLVertexDescriptor* fVertexDescriptor;
49 
50     GrMtlGpu* fGpu;
51 };
52 
53 #endif
54