| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  * Copyright 2011 Google Inc. |    2  * Copyright 2011 Google Inc. | 
|    3  * |    3  * | 
|    4  * Use of this source code is governed by a BSD-style license that can be |    4  * Use of this source code is governed by a BSD-style license that can be | 
|    5  * found in the LICENSE file. |    5  * found in the LICENSE file. | 
|    6  */ |    6  */ | 
|    7  |    7  | 
|    8 #ifndef GrGpu_DEFINED |    8 #ifndef GrGpu_DEFINED | 
|    9 #define GrGpu_DEFINED |    9 #define GrGpu_DEFINED | 
|   10  |   10  | 
|   11 #include "GrPipelineBuilder.h" |   11 #include "GrPipelineBuilder.h" | 
|   12 #include "GrProgramDesc.h" |   12 #include "GrProgramDesc.h" | 
|   13 #include "GrStencil.h" |   13 #include "GrStencil.h" | 
|   14 #include "GrSwizzle.h" |   14 #include "GrSwizzle.h" | 
|   15 #include "GrAllocator.h" |   15 #include "GrAllocator.h" | 
|   16 #include "GrTextureParamsAdjuster.h" |   16 #include "GrTextureParamsAdjuster.h" | 
|   17 #include "GrTypes.h" |   17 #include "GrTypes.h" | 
|   18 #include "GrXferProcessor.h" |   18 #include "GrXferProcessor.h" | 
|   19 #include "SkPath.h" |   19 #include "SkPath.h" | 
|   20 #include "SkTArray.h" |   20 #include "SkTArray.h" | 
|   21  |   21  | 
|   22 class GrBatchTracker; |   22 class GrBatchTracker; | 
|   23 class GrBuffer; |  | 
|   24 class GrContext; |   23 class GrContext; | 
|   25 class GrGLContext; |   24 class GrGLContext; | 
 |   25 class GrIndexBuffer; | 
|   26 class GrMesh; |   26 class GrMesh; | 
|   27 class GrNonInstancedVertices; |   27 class GrNonInstancedVertices; | 
|   28 class GrPath; |   28 class GrPath; | 
|   29 class GrPathRange; |   29 class GrPathRange; | 
|   30 class GrPathRenderer; |   30 class GrPathRenderer; | 
|   31 class GrPathRendererChain; |   31 class GrPathRendererChain; | 
|   32 class GrPathRendering; |   32 class GrPathRendering; | 
|   33 class GrPipeline; |   33 class GrPipeline; | 
|   34 class GrPrimitiveProcessor; |   34 class GrPrimitiveProcessor; | 
|   35 class GrRenderTarget; |   35 class GrRenderTarget; | 
|   36 class GrStencilAttachment; |   36 class GrStencilAttachment; | 
|   37 class GrSurface; |   37 class GrSurface; | 
|   38 class GrTexture; |   38 class GrTexture; | 
 |   39 class GrTransferBuffer; | 
 |   40 class GrVertexBuffer; | 
|   39  |   41  | 
|   40 class GrGpu : public SkRefCnt { |   42 class GrGpu : public SkRefCnt { | 
|   41 public: |   43 public: | 
|   42     /** |   44     /** | 
|   43      * Create an instance of GrGpu that matches the specified backend. If the re
     quested backend is |   45      * Create an instance of GrGpu that matches the specified backend. If the re
     quested backend is | 
|   44      * not supported (at compile-time or run-time) this returns nullptr. The con
     text will not be |   46      * not supported (at compile-time or run-time) this returns nullptr. The con
     text will not be | 
|   45      * fully constructed and should not be used by GrGpu until after this functi
     on returns. |   47      * fully constructed and should not be used by GrGpu until after this functi
     on returns. | 
|   46      */ |   48      */ | 
|   47     static GrGpu* Create(GrBackend, GrBackendContext, const GrContextOptions&, G
     rContext* context); |   49     static GrGpu* Create(GrBackend, GrBackendContext, const GrContextOptions&, G
     rContext* context); | 
|   48  |   50  | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  120      * Implements GrTextureProvider::wrapBackendRenderTarget |  122      * Implements GrTextureProvider::wrapBackendRenderTarget | 
|  121      */ |  123      */ | 
|  122     GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc&, Gr
     WrapOwnership); |  124     GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc&, Gr
     WrapOwnership); | 
|  123  |  125  | 
|  124     /** |  126     /** | 
|  125      * Implements GrTextureProvider::wrapBackendTextureAsRenderTarget |  127      * Implements GrTextureProvider::wrapBackendTextureAsRenderTarget | 
|  126      */ |  128      */ | 
|  127     GrRenderTarget* wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&
     , GrWrapOwnership); |  129     GrRenderTarget* wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&
     , GrWrapOwnership); | 
|  128  |  130  | 
|  129     /** |  131     /** | 
|  130      * Creates a buffer. |  132      * Creates a vertex buffer. | 
|  131      * |  133      * | 
|  132      * @return the buffer if successful, otherwise nullptr. |  134      * @param size    size in bytes of the vertex buffer | 
 |  135      * @param dynamic hints whether the data will be frequently changed | 
 |  136      *                by either GrVertexBuffer::map() or | 
 |  137      *                GrVertexBuffer::updateData(). | 
 |  138      * | 
 |  139      * @return    The vertex buffer if successful, otherwise nullptr. | 
|  133      */ |  140      */ | 
|  134     GrBuffer* createBuffer(GrBufferType, size_t size, GrAccessPattern); |  141     GrVertexBuffer* createVertexBuffer(size_t size, bool dynamic); | 
 |  142  | 
 |  143     /** | 
 |  144      * Creates an index buffer. | 
 |  145      * | 
 |  146      * @param size    size in bytes of the index buffer | 
 |  147      * @param dynamic hints whether the data will be frequently changed | 
 |  148      *                by either GrIndexBuffer::map() or | 
 |  149      *                GrIndexBuffer::updateData(). | 
 |  150      * | 
 |  151      * @return The index buffer if successful, otherwise nullptr. | 
 |  152      */ | 
 |  153     GrIndexBuffer* createIndexBuffer(size_t size, bool dynamic); | 
 |  154  | 
 |  155     /** | 
 |  156      * Creates a transfer buffer. | 
 |  157      * | 
 |  158      * @param size      size in bytes of the index buffer | 
 |  159      * @param toGpu     true if used to transfer from the cpu to the gpu | 
 |  160      *                  otherwise to be used to transfer from the gpu to the cpu | 
 |  161      * | 
 |  162      * @return The transfer buffer if successful, otherwise nullptr. | 
 |  163      */ | 
 |  164     GrTransferBuffer* createTransferBuffer(size_t size, TransferType type); | 
|  135      |  165      | 
|  136     /** |  166     /** | 
|  137      * Resolves MSAA. |  167      * Resolves MSAA. | 
|  138      */ |  168      */ | 
|  139     void resolveRenderTarget(GrRenderTarget* target); |  169     void resolveRenderTarget(GrRenderTarget* target); | 
|  140  |  170  | 
|  141     /** Info struct returned by getReadPixelsInfo about performing intermediate 
     draws before |  171     /** Info struct returned by getReadPixelsInfo about performing intermediate 
     draws before | 
|  142         reading pixels for performance or correctness. */ |  172         reading pixels for performance or correctness. */ | 
|  143     struct ReadPixelTempDrawInfo { |  173     struct ReadPixelTempDrawInfo { | 
|  144         /** If the GrGpu is requesting that the caller do a draw to an intermedi
     ate surface then |  174         /** If the GrGpu is requesting that the caller do a draw to an intermedi
     ate surface then | 
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  261      * @param buffer   memory to read pixels from. |  291      * @param buffer   memory to read pixels from. | 
|  262      * @param rowBytes number of bytes between consecutive rows. Zero |  292      * @param rowBytes number of bytes between consecutive rows. Zero | 
|  263      *                 means rows are tightly packed. |  293      *                 means rows are tightly packed. | 
|  264      */ |  294      */ | 
|  265     bool writePixels(GrSurface* surface, |  295     bool writePixels(GrSurface* surface, | 
|  266                      int left, int top, int width, int height, |  296                      int left, int top, int width, int height, | 
|  267                      GrPixelConfig config, const void* buffer, |  297                      GrPixelConfig config, const void* buffer, | 
|  268                      size_t rowBytes); |  298                      size_t rowBytes); | 
|  269  |  299  | 
|  270     /** |  300     /** | 
|  271      * Updates the pixels in a rectangle of a surface using a buffer |  301      * Updates the pixels in a rectangle of a surface using a GrTransferBuffer | 
|  272      * |  302      * | 
|  273      * @param surface          The surface to write to. |  303      * @param surface       The surface to write to. | 
|  274      * @param left             left edge of the rectangle to write (inclusive) |  304      * @param left          left edge of the rectangle to write (inclusive) | 
|  275      * @param top              top edge of the rectangle to write (inclusive) |  305      * @param top           top edge of the rectangle to write (inclusive) | 
|  276      * @param width            width of rectangle to write in pixels. |  306      * @param width         width of rectangle to write in pixels. | 
|  277      * @param height           height of rectangle to write in pixels. |  307      * @param height        height of rectangle to write in pixels. | 
|  278      * @param config           the pixel config of the source buffer |  308      * @param config        the pixel config of the source buffer | 
|  279      * @param transferBuffer   GrBuffer to read pixels from (type must be "kCpuT
     oGpu") |  309      * @param buffer        GrTransferBuffer to read pixels from | 
|  280      * @param offset           offset from the start of the buffer |  310      * @param offset        offset from the start of the buffer | 
|  281      * @param rowBytes         number of bytes between consecutive rows. Zero |  311      * @param rowBytes      number of bytes between consecutive rows. Zero | 
|  282      *                         means rows are tightly packed. |  312      *                      means rows are tightly packed. | 
|  283      */ |  313      */ | 
|  284     bool transferPixels(GrSurface* surface, |  314     bool transferPixels(GrSurface* surface, | 
|  285                         int left, int top, int width, int height, |  315                         int left, int top, int width, int height, | 
|  286                         GrPixelConfig config, GrBuffer* transferBuffer, |  316                         GrPixelConfig config, GrTransferBuffer* buffer, | 
|  287                         size_t offset, size_t rowBytes); |  317                         size_t offset, size_t rowBytes); | 
|  288  |  318  | 
|  289     /** |  319     /** | 
|  290      * Clear the passed in render target. Ignores the draw state and clip. |  320      * Clear the passed in render target. Ignores the draw state and clip. | 
|  291      */ |  321      */ | 
|  292     void clear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget)
     ; |  322     void clear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget)
     ; | 
|  293  |  323  | 
|  294  |  324  | 
|  295     void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* 
     renderTarget); |  325     void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* 
     renderTarget); | 
|  296  |  326  | 
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  521                                        const SkTArray<GrMipLevel>& texels) = 0; |  551                                        const SkTArray<GrMipLevel>& texels) = 0; | 
|  522     virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, |  552     virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, | 
|  523                                                  GrGpuResource::LifeCycle lifeCy
     cle, |  553                                                  GrGpuResource::LifeCycle lifeCy
     cle, | 
|  524                                                  const SkTArray<GrMipLevel>& tex
     els) = 0; |  554                                                  const SkTArray<GrMipLevel>& tex
     els) = 0; | 
|  525  |  555  | 
|  526     virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapO
     wnership) = 0; |  556     virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapO
     wnership) = 0; | 
|  527     virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
     tDesc&, |  557     virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
     tDesc&, | 
|  528                                                       GrWrapOwnership) = 0; |  558                                                       GrWrapOwnership) = 0; | 
|  529     virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTe
     xtureDesc&, |  559     virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTe
     xtureDesc&, | 
|  530                                                                GrWrapOwnership) 
     = 0; |  560                                                                GrWrapOwnership) 
     = 0; | 
|  531     virtual GrBuffer* onCreateBuffer(GrBufferType, size_t size, GrAccessPattern)
      = 0; |  561     virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; | 
 |  562     virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; | 
 |  563     virtual GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType t
     ype) = 0; | 
|  532  |  564  | 
|  533     // overridden by backend-specific derived class to perform the clear. |  565     // overridden by backend-specific derived class to perform the clear. | 
|  534     virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) = 
     0; |  566     virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) = 
     0; | 
|  535  |  567  | 
|  536     // Overridden by backend specific classes to perform a clear of the stencil 
     clip bits.  This is |  568     // Overridden by backend specific classes to perform a clear of the stencil 
     clip bits.  This is | 
|  537     // ONLY used by the the clip target |  569     // ONLY used by the the clip target | 
|  538     virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i
     nsideClip) = 0; |  570     virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i
     nsideClip) = 0; | 
|  539  |  571  | 
|  540     // overridden by backend-specific derived class to perform the draw call. |  572     // overridden by backend-specific derived class to perform the draw call. | 
|  541     virtual void onDraw(const GrPipeline&, |  573     virtual void onDraw(const GrPipeline&, | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
|  563  |  595  | 
|  564     // overridden by backend-specific derived class to perform the surface write |  596     // overridden by backend-specific derived class to perform the surface write | 
|  565     virtual bool onWritePixels(GrSurface*, |  597     virtual bool onWritePixels(GrSurface*, | 
|  566                                int left, int top, int width, int height, |  598                                int left, int top, int width, int height, | 
|  567                                GrPixelConfig config, |  599                                GrPixelConfig config, | 
|  568                                const SkTArray<GrMipLevel>& texels) = 0; |  600                                const SkTArray<GrMipLevel>& texels) = 0; | 
|  569  |  601  | 
|  570     // overridden by backend-specific derived class to perform the surface write |  602     // overridden by backend-specific derived class to perform the surface write | 
|  571     virtual bool onTransferPixels(GrSurface*, |  603     virtual bool onTransferPixels(GrSurface*, | 
|  572                                   int left, int top, int width, int height, |  604                                   int left, int top, int width, int height, | 
|  573                                   GrPixelConfig config, GrBuffer* transferBuffer
     , |  605                                   GrPixelConfig config, GrTransferBuffer* buffer
     , | 
|  574                                   size_t offset, size_t rowBytes) = 0; |  606                                   size_t offset, size_t rowBytes) = 0; | 
|  575  |  607  | 
|  576     // overridden by backend-specific derived class to perform the resolve |  608     // overridden by backend-specific derived class to perform the resolve | 
|  577     virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; |  609     virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; | 
|  578  |  610  | 
|  579     // overridden by backend specific derived class to perform the copy surface |  611     // overridden by backend specific derived class to perform the copy surface | 
|  580     virtual bool onCopySurface(GrSurface* dst, |  612     virtual bool onCopySurface(GrSurface* dst, | 
|  581                                GrSurface* src, |  613                                GrSurface* src, | 
|  582                                const SkIRect& srcRect, |  614                                const SkIRect& srcRect, | 
|  583                                const SkIPoint& dstPoint) = 0; |  615                                const SkIPoint& dstPoint) = 0; | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|  599     SkTArray<const MultisampleSpecs*, true>                             fMultisa
     mpleSpecsMap; |  631     SkTArray<const MultisampleSpecs*, true>                             fMultisa
     mpleSpecsMap; | 
|  600     GrTAllocator<MultisampleSpecs>                                      fMultisa
     mpleSpecsAllocator; |  632     GrTAllocator<MultisampleSpecs>                                      fMultisa
     mpleSpecsAllocator; | 
|  601     // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |  633     // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 
|  602     GrContext*                                                          fContext
     ; |  634     GrContext*                                                          fContext
     ; | 
|  603  |  635  | 
|  604     friend class GrPathRendering; |  636     friend class GrPathRendering; | 
|  605     typedef SkRefCnt INHERITED; |  637     typedef SkRefCnt INHERITED; | 
|  606 }; |  638 }; | 
|  607  |  639  | 
|  608 #endif |  640 #endif | 
| OLD | NEW |