GrDistanceFieldAdjustTable.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright 2015 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 GrDistanceFieldAdjustTable_DEFINED
  8. #define GrDistanceFieldAdjustTable_DEFINED
  9. #include "include/core/SkRefCnt.h"
  10. #include "include/core/SkScalar.h"
  11. // Distance field text needs this table to compute a value for use in the fragment shader.
  12. // Because the GrTextContext can go out of scope before the final flush, this needs to be
  13. // refcnted and malloced
  14. struct GrDistanceFieldAdjustTable : public SkNVRefCnt<GrDistanceFieldAdjustTable> {
  15. GrDistanceFieldAdjustTable() { this->buildDistanceAdjustTables(); }
  16. ~GrDistanceFieldAdjustTable() {
  17. delete[] fTable;
  18. delete[] fGammaCorrectTable;
  19. }
  20. const SkScalar& getAdjustment(int i, bool useGammaCorrectTable) const {
  21. return useGammaCorrectTable ? fGammaCorrectTable[i] : fTable[i];
  22. }
  23. private:
  24. void buildDistanceAdjustTables();
  25. SkScalar* fTable;
  26. SkScalar* fGammaCorrectTable;
  27. };
  28. #endif