blob: f9b5161e95a7b3739d8aa7ae9161b592631820ea [file] [log] [blame]
joshualitt1acabf32015-12-10 09:10:10 -08001/*
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
8#ifndef GrDistanceFieldAdjustTable_DEFINED
9#define GrDistanceFieldAdjustTable_DEFINED
10
11#include "SkRefCnt.h"
12#include "SkScalar.h"
13
14// Distance field text needs this table to compute a value for use in the fragment shader.
15// Because the GrAtlasTextContext can go out of scope before the final flush, this needs to be
16// refcnted and malloced
17struct GrDistanceFieldAdjustTable : public SkNVRefCnt<GrDistanceFieldAdjustTable> {
brianosman0586f5c2016-04-12 12:48:21 -070018 GrDistanceFieldAdjustTable() { this->buildDistanceAdjustTables(); }
19 ~GrDistanceFieldAdjustTable() {
20 delete[] fTable;
21 delete[] fSRGBTable;
22 }
joshualitt1acabf32015-12-10 09:10:10 -080023
brianosman0586f5c2016-04-12 12:48:21 -070024 const SkScalar& getAdjustment(int i, bool useSRGBTable) const {
25 return useSRGBTable ? fSRGBTable[i] : fTable[i];
joshualitt1acabf32015-12-10 09:10:10 -080026 }
27
28private:
brianosman0586f5c2016-04-12 12:48:21 -070029 void buildDistanceAdjustTables();
joshualitt1acabf32015-12-10 09:10:10 -080030
31 SkScalar* fTable;
brianosman0586f5c2016-04-12 12:48:21 -070032 SkScalar* fSRGBTable;
joshualitt1acabf32015-12-10 09:10:10 -080033};
34
35#endif