LCOV - code coverage report
Current view: top level - gfx/skia/skia/src/core - SkCoreBlitters.h (source / functions) Hit Total Coverage
Test: output.info Lines: 9 11 81.8 %
Date: 2017-07-14 16:53:18 Functions: 7 15 46.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright 2006 The Android Open Source Project
       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 SkCoreBlitters_DEFINED
       9             : #define SkCoreBlitters_DEFINED
      10             : 
      11             : #include "SkBitmapProcShader.h"
      12             : #include "SkBlitter.h"
      13             : #include "SkBlitRow.h"
      14             : #include "SkShader.h"
      15             : #include "SkXfermodePriv.h"
      16             : 
      17         310 : class SkRasterBlitter : public SkBlitter {
      18             : public:
      19         310 :     SkRasterBlitter(const SkPixmap& device) : fDevice(device) {}
      20             : 
      21             : protected:
      22             :     const SkPixmap fDevice;
      23             : 
      24             : private:
      25             :     typedef SkBlitter INHERITED;
      26             : };
      27             : 
      28             : class SkShaderBlitter : public SkRasterBlitter {
      29             : public:
      30             :     /**
      31             :       *  The storage for shaderContext is owned by the caller, but the object itself is not.
      32             :       *  The blitter only ensures that the storage always holds a live object, but it may
      33             :       *  exchange that object.
      34             :       */
      35             :     SkShaderBlitter(const SkPixmap& device, const SkPaint& paint,
      36             :                     SkShader::Context* shaderContext);
      37             :     virtual ~SkShaderBlitter();
      38             : 
      39             : protected:
      40             :     uint32_t            fShaderFlags;
      41             :     const SkShader*     fShader;
      42             :     SkShader::Context*  fShaderContext;
      43             :     bool                fConstInY;
      44             : 
      45             : private:
      46             :     // illegal
      47             :     SkShaderBlitter& operator=(const SkShaderBlitter&);
      48             : 
      49             :     typedef SkRasterBlitter INHERITED;
      50             : };
      51             : 
      52             : ///////////////////////////////////////////////////////////////////////////////
      53             : 
      54           0 : class SkA8_Coverage_Blitter : public SkRasterBlitter {
      55             : public:
      56             :     SkA8_Coverage_Blitter(const SkPixmap& device, const SkPaint& paint);
      57             :     void blitH(int x, int y, int width) override;
      58             :     void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override;
      59             :     void blitV(int x, int y, int height, SkAlpha alpha) override;
      60             :     void blitRect(int x, int y, int width, int height) override;
      61             :     void blitMask(const SkMask&, const SkIRect&) override;
      62             :     const SkPixmap* justAnOpaqueColor(uint32_t*) override;
      63             : };
      64             : 
      65           0 : class SkA8_Blitter : public SkRasterBlitter {
      66             : public:
      67             :     SkA8_Blitter(const SkPixmap& device, const SkPaint& paint);
      68             :     void blitH(int x, int y, int width) override;
      69             :     void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override;
      70             :     void blitV(int x, int y, int height, SkAlpha alpha) override;
      71             :     void blitRect(int x, int y, int width, int height) override;
      72             :     void blitMask(const SkMask&, const SkIRect&) override;
      73             :     const SkPixmap* justAnOpaqueColor(uint32_t*) override;
      74             : 
      75             : private:
      76             :     unsigned fSrcA;
      77             : 
      78             :     // illegal
      79             :     SkA8_Blitter& operator=(const SkA8_Blitter&);
      80             : 
      81             :     typedef SkRasterBlitter INHERITED;
      82             : };
      83             : 
      84             : class SkA8_Shader_Blitter : public SkShaderBlitter {
      85             : public:
      86             :     SkA8_Shader_Blitter(const SkPixmap& device, const SkPaint& paint,
      87             :                         SkShader::Context* shaderContext);
      88             :     ~SkA8_Shader_Blitter() override;
      89             :     void blitH(int x, int y, int width) override;
      90             :     void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override;
      91             :     void blitMask(const SkMask&, const SkIRect&) override;
      92             : 
      93             : private:
      94             :     SkXfermode* fXfermode;
      95             :     SkPMColor*  fBuffer;
      96             :     uint8_t*    fAAExpand;
      97             : 
      98             :     // illegal
      99             :     SkA8_Shader_Blitter& operator=(const SkA8_Shader_Blitter&);
     100             : 
     101             :     typedef SkShaderBlitter INHERITED;
     102             : };
     103             : 
     104             : ////////////////////////////////////////////////////////////////
     105             : 
     106         144 : class SkARGB32_Blitter : public SkRasterBlitter {
     107             : public:
     108             :     SkARGB32_Blitter(const SkPixmap& device, const SkPaint& paint);
     109             :     void blitH(int x, int y, int width) override;
     110             :     void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override;
     111             :     void blitV(int x, int y, int height, SkAlpha alpha) override;
     112             :     void blitRect(int x, int y, int width, int height) override;
     113             :     void blitMask(const SkMask&, const SkIRect&) override;
     114             :     const SkPixmap* justAnOpaqueColor(uint32_t*) override;
     115             :     void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) override;
     116             :     void blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) override;
     117             : 
     118             : protected:
     119             :     SkColor                fColor;
     120             :     SkPMColor              fPMColor;
     121             : 
     122             : private:
     123             :     unsigned fSrcA, fSrcR, fSrcG, fSrcB;
     124             : 
     125             :     // illegal
     126             :     SkARGB32_Blitter& operator=(const SkARGB32_Blitter&);
     127             : 
     128             :     typedef SkRasterBlitter INHERITED;
     129             : };
     130             : 
     131          97 : class SkARGB32_Opaque_Blitter : public SkARGB32_Blitter {
     132             : public:
     133          97 :     SkARGB32_Opaque_Blitter(const SkPixmap& device, const SkPaint& paint)
     134          97 :         : INHERITED(device, paint) { SkASSERT(paint.getAlpha() == 0xFF); }
     135             :     void blitMask(const SkMask&, const SkIRect&) override;
     136             :     void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) override;
     137             :     void blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) override;
     138             : 
     139             : private:
     140             :     typedef SkARGB32_Blitter INHERITED;
     141             : };
     142             : 
     143           1 : class SkARGB32_Black_Blitter : public SkARGB32_Opaque_Blitter {
     144             : public:
     145           1 :     SkARGB32_Black_Blitter(const SkPixmap& device, const SkPaint& paint)
     146           1 :         : INHERITED(device, paint) {}
     147             :     void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override;
     148             :     void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) override;
     149             :     void blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) override;
     150             : 
     151             : private:
     152             :     typedef SkARGB32_Opaque_Blitter INHERITED;
     153             : };
     154             : 
     155             : class SkARGB32_Shader_Blitter : public SkShaderBlitter {
     156             : public:
     157             :     SkARGB32_Shader_Blitter(const SkPixmap& device, const SkPaint& paint,
     158             :                             SkShader::Context* shaderContext);
     159             :     ~SkARGB32_Shader_Blitter() override;
     160             :     void blitH(int x, int y, int width) override;
     161             :     void blitV(int x, int y, int height, SkAlpha alpha) override;
     162             :     void blitRect(int x, int y, int width, int height) override;
     163             :     void blitAntiH(int x, int y, const SkAlpha[], const int16_t[]) override;
     164             :     void blitMask(const SkMask&, const SkIRect&) override;
     165             : 
     166             : private:
     167             :     SkXfermode*         fXfermode;
     168             :     SkPMColor*          fBuffer;
     169             :     SkBlitRow::Proc32   fProc32;
     170             :     SkBlitRow::Proc32   fProc32Blend;
     171             :     bool                fShadeDirectlyIntoDevice;
     172             : 
     173             :     // illegal
     174             :     SkARGB32_Shader_Blitter& operator=(const SkARGB32_Shader_Blitter&);
     175             : 
     176             :     typedef SkShaderBlitter INHERITED;
     177             : };
     178             : 
     179             : SkBlitter* SkBlitter_ARGB32_Create(const SkPixmap& device, const SkPaint&, SkShader::Context*,
     180             :                                    SkArenaAlloc*);
     181             : 
     182             : SkBlitter* SkBlitter_F16_Create(const SkPixmap& device, const SkPaint&, SkShader::Context*,
     183             :                                 SkArenaAlloc*);
     184             : 
     185             : ///////////////////////////////////////////////////////////////////////////////
     186             : 
     187             : /*  These return the correct subclass of blitter for their device config.
     188             : 
     189             :     Currently, they make the following assumptions about the state of the
     190             :     paint:
     191             : 
     192             :     1. If there is an xfermode, there will also be a shader
     193             :     2. If there is a colorfilter, there will be a shader that itself handles
     194             :        calling the filter, so the blitter can always ignore the colorfilter obj
     195             : 
     196             :     These pre-conditions must be handled by the caller, in our case
     197             :     SkBlitter::Choose(...)
     198             :  */
     199             : 
     200             : SkBlitter* SkBlitter_ChooseD565(const SkPixmap& device, const SkPaint& paint,
     201             :                                 SkShader::Context* shaderContext,
     202             :                                 SkArenaAlloc* allocator);
     203             : 
     204             : 
     205             : // Returns nullptr if no SkRasterPipeline blitter can be constructed for this paint.
     206             : SkBlitter* SkCreateRasterPipelineBlitter(const SkPixmap&, const SkPaint&, const SkMatrix& ctm,
     207             :                                          SkArenaAlloc*);
     208             : 
     209             : #endif

Generated by: LCOV version 1.13