SkScalerContext_win_dw.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. #ifndef SkScalarContext_win_dw_DEFINED
  8. #define SkScalarContext_win_dw_DEFINED
  9. #include "include/core/SkScalar.h"
  10. #include "include/core/SkTypes.h"
  11. #include "src/core/SkScalerContext.h"
  12. #include "src/ports/SkTypeface_win_dw.h"
  13. #include <dwrite.h>
  14. #include <dwrite_2.h>
  15. class SkGlyph;
  16. class SkDescriptor;
  17. class SkScalerContext_DW : public SkScalerContext {
  18. public:
  19. SkScalerContext_DW(sk_sp<DWriteFontTypeface>,
  20. const SkScalerContextEffects&,
  21. const SkDescriptor*);
  22. ~SkScalerContext_DW() override;
  23. protected:
  24. unsigned generateGlyphCount() override;
  25. bool generateAdvance(SkGlyph* glyph) override;
  26. void generateMetrics(SkGlyph* glyph) override;
  27. void generateImage(const SkGlyph& glyph) override;
  28. bool generatePath(SkGlyphID glyph, SkPath* path) override;
  29. void generateFontMetrics(SkFontMetrics*) override;
  30. private:
  31. static void BilevelToBW(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph);
  32. template<bool APPLY_PREBLEND>
  33. static void GrayscaleToA8(const uint8_t* SK_RESTRICT src,
  34. const SkGlyph& glyph,
  35. const uint8_t* table8);
  36. template<bool APPLY_PREBLEND>
  37. static void RGBToA8(const uint8_t* SK_RESTRICT src,
  38. const SkGlyph& glyph,
  39. const uint8_t* table8);
  40. template<bool APPLY_PREBLEND, bool RGB>
  41. static void RGBToLcd16(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph,
  42. const uint8_t* tableR, const uint8_t* tableG, const uint8_t* tableB);
  43. const void* drawDWMask(const SkGlyph& glyph,
  44. DWRITE_RENDERING_MODE renderingMode,
  45. DWRITE_TEXTURE_TYPE textureType);
  46. HRESULT getBoundingBox(SkGlyph* glyph,
  47. DWRITE_RENDERING_MODE renderingMode,
  48. DWRITE_TEXTURE_TYPE textureType,
  49. RECT* bbox);
  50. bool isColorGlyph(const SkGlyph& glyph);
  51. bool isPngGlyph(const SkGlyph& glyph);
  52. DWriteFontTypeface* getDWriteTypeface() {
  53. return static_cast<DWriteFontTypeface*>(this->getTypeface());
  54. }
  55. bool getColorGlyphRun(const SkGlyph& glyph, IDWriteColorGlyphRunEnumerator** colorGlyph);
  56. void generateColorMetrics(SkGlyph* glyph);
  57. void generateColorGlyphImage(const SkGlyph& glyph);
  58. void generatePngMetrics(SkGlyph* glyph);
  59. void generatePngGlyphImage(const SkGlyph& glyph);
  60. SkTDArray<uint8_t> fBits;
  61. /** The total matrix without the text height scale. */
  62. SkMatrix fSkXform;
  63. /** The total matrix without the text height scale. */
  64. DWRITE_MATRIX fXform;
  65. /** The text size to render with. */
  66. SkScalar fTextSizeRender;
  67. /** The text size to measure with. */
  68. SkScalar fTextSizeMeasure;
  69. int fGlyphCount;
  70. DWRITE_RENDERING_MODE fRenderingMode;
  71. DWRITE_TEXTURE_TYPE fTextureType;
  72. DWRITE_MEASURING_MODE fMeasuringMode;
  73. DWRITE_TEXT_ANTIALIAS_MODE fAntiAliasMode;
  74. DWRITE_GRID_FIT_MODE fGridFitMode;
  75. bool fIsColorFont;
  76. };
  77. #endif