OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #ifndef SkBitmapTransformer_DEFINED | 9 #ifndef SkBitmapTransformer_DEFINED |
10 #define SkBitmapTransformer_DEFINED | 10 #define SkBitmapTransformer_DEFINED |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 * Returns true iff we can convert between fBitmap and fPixelFormat. | 55 * Returns true iff we can convert between fBitmap and fPixelFormat. |
56 * If this returns false, the return values of any other methods will | 56 * If this returns false, the return values of any other methods will |
57 * be meaningless! | 57 * be meaningless! |
58 * | 58 * |
59 * @param logReason whether to log the reason why this combination | 59 * @param logReason whether to log the reason why this combination |
60 * is unsupported (only applies in debug mode) | 60 * is unsupported (only applies in debug mode) |
61 */ | 61 */ |
62 bool isValid(bool logReason=false) const; | 62 bool isValid(bool logReason=false) const; |
63 | 63 |
64 /** | 64 /** |
| 65 * Returns the number of rows in the bitmap. |
| 66 */ |
| 67 int numRows() const { |
| 68 return fBitmap.height(); |
| 69 } |
| 70 |
| 71 /** |
65 * Returns the number of bytes needed to store a single row of the | 72 * Returns the number of bytes needed to store a single row of the |
66 * bitmap's pixels if converted to pixelFormat. | 73 * bitmap's pixels if converted to pixelFormat. |
67 */ | 74 */ |
68 size_t bytesNeededPerRow() const { | 75 size_t bytesNeededPerRow() const { |
69 // This is hard-coded for the single supported PixelFormat. | 76 // This is hard-coded for the single supported PixelFormat. |
70 return fBitmap.width() * 4; | 77 return fBitmap.width() * 4; |
71 } | 78 } |
72 | 79 |
73 /** | 80 /** |
74 * Returns the number of bytes needed to store the entire bitmap | 81 * Returns the number of bytes needed to store the entire bitmap |
(...skipping 14 matching lines...) Expand all Loading... |
89 * will fail immediately and return false. | 96 * will fail immediately and return false. |
90 * We force the caller to pass this in to avoid buffer overruns in | 97 * We force the caller to pass this in to avoid buffer overruns in |
91 * unanticipated cases. | 98 * unanticipated cases. |
92 * | 99 * |
93 * All pixels for all rows will be written into dstBuffer as a | 100 * All pixels for all rows will be written into dstBuffer as a |
94 * single contiguous blob (no skipped pixels at the end of each | 101 * single contiguous blob (no skipped pixels at the end of each |
95 * row). | 102 * row). |
96 */ | 103 */ |
97 bool copyBitmapToPixelBuffer (void *dstBuffer, size_t dstBufferSize) const; | 104 bool copyBitmapToPixelBuffer (void *dstBuffer, size_t dstBufferSize) const; |
98 | 105 |
| 106 /** |
| 107 * Writes a single row of the bitmap into dstBuffer, using the |
| 108 * already-specified pixelFormat. Returns true if successful. |
| 109 * |
| 110 * row is the 0-indexed row number within the bitmap; if the row |
| 111 * specified is outside of the range [0, numRows()-1], then this method |
| 112 * will fail. |
| 113 * |
| 114 * dstBufferSize is the maximum allowable bytes to write into dstBuffer; |
| 115 * if that is not large enough to hold the row, then this |
| 116 * will fail immediately and return false. |
| 117 * We force the caller to pass this in to avoid buffer overruns in |
| 118 * unanticipated cases. |
| 119 */ |
| 120 bool copyRowToPixelBuffer (int row, void *dstBuffer, size_t dstBufferSize) c
onst; |
| 121 |
99 private: | 122 private: |
100 const SkBitmap& fBitmap; | 123 const SkBitmap& fBitmap; |
101 const PixelFormat fPixelFormat; | 124 const PixelFormat fPixelFormat; |
102 }; | 125 }; |
103 | 126 |
104 #endif | 127 #endif |
OLD | NEW |