blob: e02f0ecd14e9d84ad0776c8741f0756b2b692465 [file] [log] [blame]
reed@google.comf6627b72012-07-27 18:02:50 +00001/*
2 * Copyright 2012 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#include "SkDataPixelRef.h"
9#include "SkData.h"
10
11SkDataPixelRef::SkDataPixelRef(SkData* data) : fData(data) {
12 fData->ref();
13 this->setPreLocked(const_cast<void*>(fData->data()), NULL);
14}
15
16SkDataPixelRef::~SkDataPixelRef() {
17 fData->unref();
18}
19
20void* SkDataPixelRef::onLockPixels(SkColorTable** ct) {
21 *ct = NULL;
22 return const_cast<void*>(fData->data());
23}
24
25void SkDataPixelRef::onUnlockPixels() {
26 // nothing to do
27}
28
29void SkDataPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const {
30 this->INHERITED::flatten(buffer);
31
32// fData->flatten(buffer);
33}
34
35SkDataPixelRef::SkDataPixelRef(SkFlattenableReadBuffer& buffer)
36 : INHERITED(buffer, NULL) {
37
38// fData = buffer.readData();
39 this->setPreLocked(const_cast<void*>(fData->data()), NULL);
40}
41
42SK_DEFINE_FLATTENABLE_REGISTRAR(SkDataPixelRef)