summaryrefslogtreecommitdiffstats
path: root/libs/hwui/PixelBuffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/PixelBuffer.h')
-rw-r--r--libs/hwui/PixelBuffer.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/libs/hwui/PixelBuffer.h b/libs/hwui/PixelBuffer.h
index 32d5417..9725a61 100644
--- a/libs/hwui/PixelBuffer.h
+++ b/libs/hwui/PixelBuffer.h
@@ -112,13 +112,25 @@ public:
virtual uint8_t* getMappedPointer() const = 0;
/**
- * Upload the specified rectangle of this pixe buffer as a
+ * Upload the specified rectangle of this pixel buffer as a
* GL_TEXTURE_2D texture. Calling this method will trigger
* an unmap() if necessary.
*/
virtual void upload(uint32_t x, uint32_t y, uint32_t width, uint32_t height, int offset) = 0;
/**
+ * Upload the specified rectangle of this pixel buffer as a
+ * GL_TEXTURE_2D texture. Calling this method will trigger
+ * an unmap() if necessary.
+ *
+ * This is a convenience function provided to save callers the
+ * trouble of computing the offset parameter.
+ */
+ void upload(uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
+ upload(x, y, width, height, getOffset(x, y));
+ }
+
+ /**
* Returns the width of the render buffer in pixels.
*/
uint32_t getWidth() const {
@@ -140,6 +152,13 @@ public:
}
/**
+ * Returns the offset of a pixel in this pixel buffer, in bytes.
+ */
+ uint32_t getOffset(uint32_t x, uint32_t y) const {
+ return (y * mWidth + x) * formatSize(mFormat);
+ }
+
+ /**
* Returns the number of bytes per pixel in the specified format.
*
* Supported formats: