Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Side by Side Diff: src/lazy/SkLazyCachingPixelRef.cpp

Issue 68973005: Expand pixelref to return SkImageInfo and rowbytes (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 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 "Sk64.h"
9 #include "SkColorTable.h"
10 #include "SkData.h"
11 #include "SkImageDecoder.h"
12 #include "SkImagePriv.h"
13 #include "SkLazyCachingPixelRef.h"
14 #include "SkPostConfig.h"
15
16 SkLazyCachingPixelRef::SkLazyCachingPixelRef(const SkImageInfo& info,
scroggo 2013/12/06 14:50:33 Deleted by Hal?
17 SkData* data,
18 SkBitmapFactory::DecodeProc proc)
19 : INHERITED(info)
20 , fDecodeProc(proc)
21 {
22 if (NULL == data) {
23 fData = SkData::NewEmpty();
24 } else {
25 fData = data;
26 fData->ref();
27 }
28 if (NULL == fDecodeProc) { // use a reasonable default.
29 fDecodeProc = SkImageDecoder::DecodeMemoryToTarget;
30 }
31 this->setImmutable();
32 }
33
34 SkLazyCachingPixelRef::~SkLazyCachingPixelRef() {
35 SkASSERT(fData != NULL);
36 fData->unref();
37 }
38
39 bool SkLazyCachingPixelRef::onDecodePixels(void* pixels, size_t rowBytes) {
40 SkASSERT(pixels);
41 SkImageInfo info = this->info();
42 SkBitmapFactory::Target target = { pixels, rowBytes };
43 return fDecodeProc(fData->data(), fData->size(), &info, &target);
44 }
45
46 bool SkLazyCachingPixelRef::Install(SkBitmapFactory::DecodeProc proc,
47 SkData* data,
48 SkBitmap* destination) {
49 SkImageInfo info;
50 if (!proc(data->data(), data->size(), &info, NULL)) {
51 return false;
52 }
53
54 SkAutoTUnref<SkLazyCachingPixelRef> ref(
55 SkNEW_ARGS(SkLazyCachingPixelRef, (info, data, proc)));
56 return ref->configure(destination) && destination->setPixelRef(ref);
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698