1 /* 2 * Copyright 2017 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 SkAutoBlitterChoose_DEFINED 9 #define SkAutoBlitterChoose_DEFINED 10 11 #include "include/private/base/SkMacros.h" 12 #include "src/base/SkArenaAlloc.h" 13 #include "src/core/SkBlitter.h" 14 #include "src/core/SkDrawBase.h" 15 #include "src/core/SkRasterClip.h" 16 #include "src/core/SkSurfacePriv.h" 17 18 class SkMatrix; 19 class SkPaint; 20 class SkPixmap; 21 22 class SkAutoBlitterChoose : SkNoncopyable { 23 public: SkAutoBlitterChoose()24 SkAutoBlitterChoose() {} 25 SkAutoBlitterChoose(const SkDrawBase& draw, 26 const SkMatrix* ctm, 27 const SkPaint& paint, 28 bool drawCoverage = false) { 29 this->choose(draw, ctm, paint, drawCoverage); 30 } 31 32 SkBlitter* operator->() { return fBlitter; } get()33 SkBlitter* get() const { return fBlitter; } 34 35 SkBlitter* choose(const SkDrawBase& draw, const SkMatrix* ctm, 36 const SkPaint& paint, bool drawCoverage = false) { 37 SkASSERT(!fBlitter); 38 fBlitter = draw.fBlitterChooser(draw.fDst, 39 ctm ? *ctm : *draw.fCTM, 40 paint, 41 &fAlloc, 42 drawCoverage, 43 draw.fRC->clipShader(), 44 SkSurfacePropsCopyOrDefault(draw.fProps)); 45 return fBlitter; 46 } 47 48 private: 49 // Owned by fAlloc, which will handle the delete. 50 SkBlitter* fBlitter = nullptr; 51 52 SkSTArenaAlloc<kSkBlitterContextSize> fAlloc; 53 }; 54 55 #endif 56