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

Side by Side Diff: src/images/SkDecodingImageGenerator.cpp

Issue 74793011: Add SkImageGenerator Interface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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 "SkDecodingImageGenerator.h"
9
10 #include "SkBitmapFactory.h"
11 #include "SkData.h"
12 #include "SkImageDecoder.h"
13
14 SkDecodingImageGenerator::SkDecodingImageGenerator(SkData* data)
15 : fData(data) {
16 SkASSERT(fData != NULL);
17 fData->ref();
18 }
19
20 SkDecodingImageGenerator::~SkDecodingImageGenerator() {
21 fData->unref();
22 }
23
24 SkData* SkDecodingImageGenerator::refEncodedData() {
25 fData->ref();
26 return fData;
27 }
28
29 bool SkDecodingImageGenerator::getInfo(SkImageInfo* info) {
30 return SkImageDecoder::DecodeMemoryToTarget(fData->data(),
31 fData->size(),
32 info, NULL);
33 }
34
35 bool SkDecodingImageGenerator::getPixels(const SkImageInfo& info,
36 void* pixels,
37 size_t rowBytes) {
38 SkBitmapFactory::Target target = {pixels, rowBytes};
39 SkImageInfo tmpInfo = info;
40 return SkImageDecoder::DecodeMemoryToTarget(fData->data(),
41 fData->size(),
42 &tmpInfo, &target);
43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698