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

Side by Side Diff: src/codec/SkMasks.cpp

Issue 1364463005: Avoid copies in SkMasks constructor (Closed) Base URL: https://skia.googlesource.com/skia.git@codecSDmerge
Patch Set: Rebase Created 5 years, 2 months 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
« no previous file with comments | « src/codec/SkMasks.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCodecPriv.h" 8 #include "SkCodecPriv.h"
9 #include "SkMasks.h" 9 #include "SkMasks.h"
10 #include "SkTypes.h" 10 #include "SkTypes.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 static uint8_t get_comp(uint32_t pixel, uint32_t mask, uint32_t shift, 61 static uint8_t get_comp(uint32_t pixel, uint32_t mask, uint32_t shift,
62 uint32_t size) { 62 uint32_t size) {
63 return convert_to_8((pixel & mask) >> shift, size); 63 return convert_to_8((pixel & mask) >> shift, size);
64 } 64 }
65 65
66 /* 66 /*
67 * 67 *
68 * Get a color component 68 * Get a color component
69 * 69 *
70 */ 70 */
71 uint8_t SkMasks::getRed(uint32_t pixel) { 71 uint8_t SkMasks::getRed(uint32_t pixel) const {
72 return get_comp(pixel, fRed.mask, fRed.shift, fRed.size); 72 return get_comp(pixel, fRed.mask, fRed.shift, fRed.size);
73 } 73 }
74 uint8_t SkMasks::getGreen(uint32_t pixel) { 74 uint8_t SkMasks::getGreen(uint32_t pixel) const {
75 return get_comp(pixel, fGreen.mask, fGreen.shift, fGreen.size); 75 return get_comp(pixel, fGreen.mask, fGreen.shift, fGreen.size);
76 } 76 }
77 uint8_t SkMasks::getBlue(uint32_t pixel) { 77 uint8_t SkMasks::getBlue(uint32_t pixel) const {
78 return get_comp(pixel, fBlue.mask, fBlue.shift, fBlue.size); 78 return get_comp(pixel, fBlue.mask, fBlue.shift, fBlue.size);
79 } 79 }
80 uint8_t SkMasks::getAlpha(uint32_t pixel) { 80 uint8_t SkMasks::getAlpha(uint32_t pixel) const {
81 return get_comp(pixel, fAlpha.mask, fAlpha.shift, fAlpha.size); 81 return get_comp(pixel, fAlpha.mask, fAlpha.shift, fAlpha.size);
82 } 82 }
83 83
84 /* 84 /*
85 * 85 *
86 * Process an input mask to obtain the necessary information 86 * Process an input mask to obtain the necessary information
87 * 87 *
88 */ 88 */
89 const SkMasks::MaskInfo process_mask(uint32_t mask, uint32_t bpp) { 89 const SkMasks::MaskInfo process_mask(uint32_t mask, uint32_t bpp) {
90 // Trim the masks to the allowed number of bits 90 // Trim the masks to the allowed number of bits
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // Collect information about the masks 145 // Collect information about the masks
146 const MaskInfo red = process_mask(masks.red, bitsPerPixel); 146 const MaskInfo red = process_mask(masks.red, bitsPerPixel);
147 const MaskInfo green = process_mask(masks.green, bitsPerPixel); 147 const MaskInfo green = process_mask(masks.green, bitsPerPixel);
148 const MaskInfo blue = process_mask(masks.blue, bitsPerPixel); 148 const MaskInfo blue = process_mask(masks.blue, bitsPerPixel);
149 const MaskInfo alpha = process_mask(masks.alpha, bitsPerPixel); 149 const MaskInfo alpha = process_mask(masks.alpha, bitsPerPixel);
150 150
151 return new SkMasks(red, green, blue, alpha); 151 return new SkMasks(red, green, blue, alpha);
152 } 152 }
153 153
154 154
155 SkMasks::SkMasks(const MaskInfo red, const MaskInfo green, 155 SkMasks::SkMasks(const MaskInfo& red, const MaskInfo& green,
156 const MaskInfo blue, const MaskInfo alpha) 156 const MaskInfo& blue, const MaskInfo& alpha)
157 : fRed(red) 157 : fRed(red)
158 , fGreen(green) 158 , fGreen(green)
159 , fBlue(blue) 159 , fBlue(blue)
160 , fAlpha(alpha) 160 , fAlpha(alpha)
161 {} 161 {}
OLDNEW
« no previous file with comments | « src/codec/SkMasks.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698