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

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

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 #ifndef SkLazyCachingPixelRef_DEFINED
9 #define SkLazyCachingPixelRef_DEFINED
10
11 #include "SkBitmapFactory.h"
12 #include "SkCachingPixelRef.h"
13
14 class SkData;
15
16 /**
17 * PixelRef which defers decoding until SkBitmap::lockPixels() is
18 * called. Makes use of a supplied decode procedure. Will decode at
19 * the procedure's preferred size.
20 */
21 class SkLazyCachingPixelRef : public SkCachingPixelRef {
scroggo 2013/12/06 14:50:33 I think Hal deleted this file?
reed1 2013/12/06 15:48:46 Done.
22 public:
23 /**
24 * @param data Encoded data representing the pixels. NULL is
25 * equivalent to an empty data, and will be passed to
26 * DecodeProc with length zero.
27 *
28 * @param procedure Called to decode the pixels when
29 * needed. If NULL, use SkImageDecoder::DecodeMemoryToTarget.
30 */
31 SkLazyCachingPixelRef(const SkImageInfo&, SkData* data,
32 SkBitmapFactory::DecodeProc procedure);
33
34 virtual ~SkLazyCachingPixelRef();
35
36 virtual SkData* onRefEncodedData() SK_OVERRIDE { return SkSafeRef(fData); }
37
38 /**
39 * A simplified version of SkBitmapFactory. Installs a new
40 * SkLazyCachingPixelRef into the provided bitmap. Will
41 * immediately call onDecodeInfo() to configure the bitmap, but
42 * will defer decoding until the first time the bitmap's pixels
43 * are locked.
44 *
45 * @param data Encoded data representing the pixels. NULL is
46 * equivalent to an empty data, and will be passed to
47 * DecodeProc with length zero.
48 *
49 * @param procedure Called to decode the pixels when
50 * needed. If NULL, use SkImageDecoder::DecodeMemoryToTarget.
51 *
52 * @param destination Bitmap that will be modified on success.
53 *
54 * @returns true on success.
55 */
56 static bool Install(SkBitmapFactory::DecodeProc procedure,
57 SkData* data,
58 SkBitmap* destination);
59
60 // No need to flatten this object. When flattening an SkBitmap,
61 // SkOrderedWriteBuffer will check the encoded data and write that
62 // instead.
63 // Future implementations of SkFlattenableWriteBuffer will need to
64 // special case for onRefEncodedData as well.
65 SK_DECLARE_UNFLATTENABLE_OBJECT()
66
67 protected:
68 /**
69 * Decode into the given pixels, a block of memory of size
70 * (info.fHeight * rowBytes) bytes.
71 *
72 * @param info Should be identical to the info returned by
73 * onDecodeInfo so that the implementation can confirm
74 * that the caller knows what its asking for (config,
75 * size).
76 *
77 * @return false if anything goes wrong.
78 */
79 virtual bool onDecodePixels(void* pixels,
80 size_t rowBytes) SK_OVERRIDE;
81
82 private:
83 SkData* fData;
84 SkBitmapFactory::DecodeProc fDecodeProc;
85
86 typedef SkCachingPixelRef INHERITED;
87 };
88
89 #endif // SkLazyCachingPixelRef_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698