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

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

Issue 74793011: Add SkImageGenerator Interface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: whitespace 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
« no previous file with comments | « src/images/SkDecodingImageGenerator.h ('k') | src/lazy/SkDiscardablePixelRef.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "SkDiscardablePixelRef.h"
13 #include "SkImageDecoder.h"
14
15 SkDecodingImageGenerator::SkDecodingImageGenerator(SkData* data)
16 : fData(data) {
17 SkASSERT(fData != NULL);
18 fData->ref();
19 }
20
21 SkDecodingImageGenerator::~SkDecodingImageGenerator() {
22 fData->unref();
23 }
24
25 SkData* SkDecodingImageGenerator::refEncodedData() {
26 fData->ref();
27 return fData;
28 }
29
30 bool SkDecodingImageGenerator::getInfo(SkImageInfo* info) {
31 SkASSERT(info != NULL);
32 return SkImageDecoder::DecodeMemoryToTarget(fData->data(),
33 fData->size(),
34 info, NULL);
35 }
36
37 bool SkDecodingImageGenerator::getPixels(const SkImageInfo& info,
38 void* pixels,
39 size_t rowBytes) {
40 SkASSERT(pixels != NULL);
41 SkBitmapFactory::Target target = {pixels, rowBytes};
42 SkImageInfo tmpInfo = info;
43 return SkImageDecoder::DecodeMemoryToTarget(fData->data(),
44 fData->size(),
45 &tmpInfo, &target);
46 }
47 bool SkDecodingImageGenerator::Install(SkData* data, SkBitmap* dst) {
48 SkASSERT(data != NULL);
49 SkASSERT(dst != NULL);
50 SkImageGenerator* gen(SkNEW_ARGS(SkDecodingImageGenerator, (data)));
51 return SkDiscardablePixelRef::Install(gen, dst);
52 }
OLDNEW
« no previous file with comments | « src/images/SkDecodingImageGenerator.h ('k') | src/lazy/SkDiscardablePixelRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698