Leon Scroggins III | 9febd0b | 2018-05-30 14:41:11 -0400 | [diff] [blame] | 1 | /* |
Leon Scroggins III | 22f673d | 2018-05-30 15:33:46 -0400 | [diff] [blame] | 2 | * Copyright 2009 The Android Open Source Project |
Leon Scroggins III | 9febd0b | 2018-05-30 14:41:11 -0400 | [diff] [blame] | 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 | |
Leon Scroggins III | 22f673d | 2018-05-30 15:33:46 -0400 | [diff] [blame] | 8 | #include "SkColorTable.h" |
| 9 | #include "../private/SkMalloc.h" |
| 10 | |
| 11 | SkColorTable::SkColorTable(const SkPMColor colors[], int count) { |
| 12 | SkASSERT(0 == count || colors); |
| 13 | SkASSERT(count >= 0 && count <= 256); |
| 14 | |
| 15 | fCount = count; |
| 16 | fColors = reinterpret_cast<SkPMColor*>(sk_malloc_throw(count * sizeof(SkPMColor))); |
| 17 | |
| 18 | memcpy(fColors, colors, count * sizeof(SkPMColor)); |
| 19 | } |
| 20 | |
| 21 | SkColorTable::~SkColorTable() { |
| 22 | sk_free(fColors); |
| 23 | } |