| 1 |
/* |
| 2 |
* Copyright 2009 The Android Open Source Project |
| 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 |
#include "src/codec/SkColorPalette.h" |
| 8 |
|
| 9 |
#include "include/private/base/SkMalloc.h" |
| 10 |
|
| 11 |
#include <cstring> |
| 12 |
|
| 13 |
SkColorPalette::SkColorPalette(const SkPMColor colors[], int count) { |
| 14 |
SkASSERT(0 == count || colors); |
| 15 |
SkASSERT(count >= 0 && count <= 256); |
| 16 |
|
| 17 |
fCount = count; |
| 18 |
fColors = reinterpret_cast<SkPMColor*>(sk_malloc_throw(count * sizeof(SkPMColor))); |
| 19 |
|
| 20 |
memcpy(fColors, colors, count * sizeof(SkPMColor)); |
| 21 |
} |
| 22 |
|
| 23 |
SkColorPalette::~SkColorPalette() { |
| 24 |
sk_free(fColors); |
| 25 |
} |