aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@google.com>2015-09-30 12:26:49 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-30 12:26:49 -0700
commit8b17dcb72cfbfb1e9451a311f927291a48a84d79 (patch)
treec75c66ff35b58bb7e4fb8b8a5d5d98bc781fd006
parentf32602921aba5b54b64d9fa3b6479914034b4d5a (diff)
Avoid copies in SkMasks constructor
Also mark const methods as const. Review URL: https://codereview.chromium.org/1364463005
-rw-r--r--src/codec/SkMasks.cpp12
-rw-r--r--src/codec/SkMasks.h16
2 files changed, 14 insertions, 14 deletions
diff --git a/src/codec/SkMasks.cpp b/src/codec/SkMasks.cpp
index b8603148b9..3126672f22 100644
--- a/src/codec/SkMasks.cpp
+++ b/src/codec/SkMasks.cpp
@@ -68,16 +68,16 @@ static uint8_t get_comp(uint32_t pixel, uint32_t mask, uint32_t shift,
* Get a color component
*
*/
-uint8_t SkMasks::getRed(uint32_t pixel) {
+uint8_t SkMasks::getRed(uint32_t pixel) const {
return get_comp(pixel, fRed.mask, fRed.shift, fRed.size);
}
-uint8_t SkMasks::getGreen(uint32_t pixel) {
+uint8_t SkMasks::getGreen(uint32_t pixel) const {
return get_comp(pixel, fGreen.mask, fGreen.shift, fGreen.size);
}
-uint8_t SkMasks::getBlue(uint32_t pixel) {
+uint8_t SkMasks::getBlue(uint32_t pixel) const {
return get_comp(pixel, fBlue.mask, fBlue.shift, fBlue.size);
}
-uint8_t SkMasks::getAlpha(uint32_t pixel) {
+uint8_t SkMasks::getAlpha(uint32_t pixel) const {
return get_comp(pixel, fAlpha.mask, fAlpha.shift, fAlpha.size);
}
@@ -152,8 +152,8 @@ SkMasks* SkMasks::CreateMasks(InputMasks masks, uint32_t bitsPerPixel) {
}
-SkMasks::SkMasks(const MaskInfo red, const MaskInfo green,
- const MaskInfo blue, const MaskInfo alpha)
+SkMasks::SkMasks(const MaskInfo& red, const MaskInfo& green,
+ const MaskInfo& blue, const MaskInfo& alpha)
: fRed(red)
, fGreen(green)
, fBlue(blue)
diff --git a/src/codec/SkMasks.h b/src/codec/SkMasks.h
index 0823704668..9606cbfbeb 100644
--- a/src/codec/SkMasks.h
+++ b/src/codec/SkMasks.h
@@ -52,10 +52,10 @@ public:
* Get a color component
*
*/
- uint8_t getRed(uint32_t pixel);
- uint8_t getGreen(uint32_t pixel);
- uint8_t getBlue(uint32_t pixel);
- uint8_t getAlpha(uint32_t pixel);
+ uint8_t getRed(uint32_t pixel) const;
+ uint8_t getGreen(uint32_t pixel) const;
+ uint8_t getBlue(uint32_t pixel) const;
+ uint8_t getAlpha(uint32_t pixel) const;
/*
*
@@ -63,7 +63,7 @@ public:
* The alpha mask may be used in other decoding modes
*
*/
- uint32_t getAlphaMask() {
+ uint32_t getAlphaMask() const {
return fAlpha.mask;
}
@@ -71,11 +71,11 @@ private:
/*
*
- * Constrcutor
+ * Constructor
*
*/
- SkMasks(const MaskInfo red, const MaskInfo green, const MaskInfo blue,
- const MaskInfo alpha);
+ SkMasks(const MaskInfo& red, const MaskInfo& green, const MaskInfo& blue,
+ const MaskInfo& alpha);
const MaskInfo fRed;
const MaskInfo fGreen;