blob: 5eef81bc3df279db7f1336ec6b778e3cf0db5027 [file] [log] [blame]
bsalomon@google.com798c8c42013-03-27 19:50:27 +00001/*
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
joshualitt30ba4362014-08-21 20:18:45 -07008#include "gl/builders/GrGLProgramBuilder.h"
bsalomon@google.com798c8c42013-03-27 19:50:27 +00009#include "GrGLProgramDesc.h"
10#include "GrBackendEffectFactory.h"
bsalomon@google.com798c8c42013-03-27 19:50:27 +000011#include "GrEffect.h"
12#include "GrGpuGL.h"
egdaniel170f90b2014-09-16 12:54:40 -070013#include "GrOptDrawState.h"
bsalomon@google.com798c8c42013-03-27 19:50:27 +000014
bsalomon@google.com2db3ded2013-05-22 14:34:04 +000015#include "SkChecksum.h"
16
joshualitt23e280d2014-09-18 12:26:38 -070017/**
18 * The key for an individual coord transform is made up of a matrix type and a bit that
19 * indicates the source of the input coords.
20 */
21enum {
22 kMatrixTypeKeyBits = 1,
23 kMatrixTypeKeyMask = (1 << kMatrixTypeKeyBits) - 1,
24 kPositionCoords_Flag = (1 << kMatrixTypeKeyBits),
25 kTransformKeyBits = kMatrixTypeKeyBits + 1,
26};
27
28/**
29 * We specialize the vertex code for each of these matrix types.
30 */
31enum MatrixType {
32 kNoPersp_MatrixType = 0,
33 kGeneral_MatrixType = 1,
34};
35
36/**
37 * Do we need to either map r,g,b->a or a->r. configComponentMask indicates which channels are
38 * present in the texture's config. swizzleComponentMask indicates the channels present in the
39 * shader swizzle.
40 */
41static bool swizzle_requires_alpha_remapping(const GrGLCaps& caps,
42 uint32_t configComponentMask,
43 uint32_t swizzleComponentMask) {
44 if (caps.textureSwizzleSupport()) {
45 // Any remapping is handled using texture swizzling not shader modifications.
46 return false;
47 }
48 // check if the texture is alpha-only
49 if (kA_GrColorComponentFlag == configComponentMask) {
50 if (caps.textureRedSupport() && (kA_GrColorComponentFlag & swizzleComponentMask)) {
51 // we must map the swizzle 'a's to 'r'.
52 return true;
53 }
54 if (kRGB_GrColorComponentFlags & swizzleComponentMask) {
55 // The 'r', 'g', and/or 'b's must be mapped to 'a' according to our semantics that
56 // alpha-only textures smear alpha across all four channels when read.
57 return true;
58 }
59 }
60 return false;
61}
62
63static uint32_t gen_attrib_key(const GrEffect* effect) {
64 uint32_t key = 0;
65
66 const GrEffect::VertexAttribArray& vars = effect->getVertexAttribs();
67 int numAttributes = vars.count();
68 SkASSERT(numAttributes <= 2);
69 for (int a = 0; a < numAttributes; ++a) {
70 uint32_t value = 1 << a;
71 key |= value;
72 }
73 return key;
74}
75
76static uint32_t gen_transform_key(const GrEffectStage& effectStage,
77 bool useExplicitLocalCoords) {
78 uint32_t totalKey = 0;
79 int numTransforms = effectStage.getEffect()->numTransforms();
80 for (int t = 0; t < numTransforms; ++t) {
81 uint32_t key = 0;
82 if (effectStage.isPerspectiveCoordTransform(t, useExplicitLocalCoords)) {
83 key |= kGeneral_MatrixType;
84 } else {
85 key |= kNoPersp_MatrixType;
86 }
87
88 const GrCoordTransform& coordTransform = effectStage.getEffect()->coordTransform(t);
89 if (kLocal_GrCoordSet != coordTransform.sourceCoords() && useExplicitLocalCoords) {
90 key |= kPositionCoords_Flag;
91 }
92 key <<= kTransformKeyBits * t;
93 SkASSERT(0 == (totalKey & key)); // keys for each transform ought not to overlap
94 totalKey |= key;
95 }
96 return totalKey;
97}
98
99static uint32_t gen_texture_key(const GrEffect* effect, const GrGLCaps& caps) {
100 uint32_t key = 0;
101 int numTextures = effect->numTextures();
102 for (int t = 0; t < numTextures; ++t) {
103 const GrTextureAccess& access = effect->textureAccess(t);
104 uint32_t configComponentMask = GrPixelConfigComponentMask(access.getTexture()->config());
105 if (swizzle_requires_alpha_remapping(caps, configComponentMask, access.swizzleMask())) {
106 key |= 1 << t;
107 }
108 }
109 return key;
110}
111
112/**
113 * A function which emits a meta key into the key builder. This is required because shader code may
114 * be dependent on properties of the effect that the effect itself doesn't use
115 * in its key (e.g. the pixel format of textures used). So we create a meta-key for
116 * every effect using this function. It is also responsible for inserting the effect's class ID
117 * which must be different for every GrEffect subclass. It can fail if an effect uses too many
118 * textures, attributes, etc for the space allotted in the meta-key.
119 */
120
121static bool gen_effect_meta_key(const GrEffectStage& effectStage,
122 bool useExplicitLocalCoords,
123 const GrGLCaps& caps,
124 GrEffectKeyBuilder* b) {
125
126 uint32_t textureKey = gen_texture_key(effectStage.getEffect(), caps);
127 uint32_t transformKey = gen_transform_key(effectStage,useExplicitLocalCoords);
128 uint32_t attribKey = gen_attrib_key(effectStage.getEffect());
129 uint32_t classID = effectStage.getEffect()->getFactory().effectClassID();
130
131 // Currently we allow 16 bits for each of the above portions of the meta-key. Fail if they
132 // don't fit.
133 static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16);
134 if ((textureKey | transformKey | attribKey | classID) & kMetaKeyInvalidMask) {
135 return false;
136 }
137
138 uint32_t* key = b->add32n(2);
139 key[0] = (textureKey << 16 | transformKey);
140 key[1] = (classID << 16 | attribKey);
141 return true;
142}
143
egdaniela7dc0a82014-09-17 08:25:05 -0700144bool GrGLProgramDesc::GetEffectKey(const GrEffectStage& stage, const GrGLCaps& caps,
145 bool useExplicitLocalCoords, GrEffectKeyBuilder* b,
146 uint16_t* effectKeySize) {
bsalomon848faf02014-07-11 10:01:02 -0700147 const GrBackendEffectFactory& factory = stage.getEffect()->getFactory();
joshualitt49586be2014-09-16 08:21:41 -0700148 const GrEffect& effect = *stage.getEffect();
joshualitt49586be2014-09-16 08:21:41 -0700149 factory.getGLEffectKey(effect, caps, b);
bsalomon929f29a2014-07-17 07:55:11 -0700150 size_t size = b->size();
151 if (size > SK_MaxU16) {
152 *effectKeySize = 0; // suppresses a warning.
153 return false;
154 }
155 *effectKeySize = SkToU16(size);
joshualitt23e280d2014-09-18 12:26:38 -0700156 if (!gen_effect_meta_key(stage, useExplicitLocalCoords, caps, b)) {
bsalomon929f29a2014-07-17 07:55:11 -0700157 return false;
158 }
159 return true;
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000160}
bsalomon848faf02014-07-11 10:01:02 -0700161
egdaniel170f90b2014-09-16 12:54:40 -0700162bool GrGLProgramDesc::Build(const GrOptDrawState& optState,
commit-bot@chromium.org0a6fe712014-04-23 19:26:26 +0000163 GrGpu::DrawType drawType,
bsalomon@google.com798c8c42013-03-27 19:50:27 +0000164 GrBlendCoeff srcCoeff,
165 GrBlendCoeff dstCoeff,
egdanielae444962014-09-22 12:29:52 -0700166 GrGpuGL* gpu,
bsalomon@google.com26e18b52013-03-29 19:22:36 +0000167 const GrDeviceCoordTexture* dstCopy,
joshualittbd769d02014-09-04 08:56:46 -0700168 const GrEffectStage** geometryProcessor,
bsalomon@google.com2c84aa32013-06-06 20:28:57 +0000169 SkTArray<const GrEffectStage*, true>* colorStages,
170 SkTArray<const GrEffectStage*, true>* coverageStages,
bsalomon@google.com798c8c42013-03-27 19:50:27 +0000171 GrGLProgramDesc* desc) {
bsalomon@google.com2c84aa32013-06-06 20:28:57 +0000172 colorStages->reset();
173 coverageStages->reset();
174
egdaniel170f90b2014-09-16 12:54:40 -0700175 bool inputColorIsUsed = optState.inputColorIsUsed();
egdaniel033ea7f2014-09-23 08:14:13 -0700176 bool inputCoverageIsUsed = optState.inputCoverageIsUsed();
bsalomon@google.com798c8c42013-03-27 19:50:27 +0000177
178 // The descriptor is used as a cache key. Thus when a field of the
179 // descriptor will not affect program generation (because of the attribute
180 // bindings in use or other descriptor field settings) it should be set
181 // to a canonical value to avoid duplicate programs with different keys.
182
egdaniela7dc0a82014-09-17 08:25:05 -0700183 bool requiresLocalCoordAttrib = optState.requiresLocalCoordAttrib();
kkinnunenec56e452014-08-25 22:21:16 -0700184
egdaniel170f90b2014-09-16 12:54:40 -0700185 int numStages = optState.numTotalStages();
186
bsalomon929f29a2014-07-17 07:55:11 -0700187 GR_STATIC_ASSERT(0 == kEffectKeyOffsetsAndLengthOffset % sizeof(uint32_t));
bsalomon848faf02014-07-11 10:01:02 -0700188 // Make room for everything up to and including the array of offsets to effect keys.
189 desc->fKey.reset();
bsalomon929f29a2014-07-17 07:55:11 -0700190 desc->fKey.push_back_n(kEffectKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_t) * numStages);
commit-bot@chromium.org0a6fe712014-04-23 19:26:26 +0000191
bsalomon929f29a2014-07-17 07:55:11 -0700192 int offsetAndSizeIndex = 0;
bsalomon848faf02014-07-11 10:01:02 -0700193 bool effectKeySuccess = true;
joshualittbd769d02014-09-04 08:56:46 -0700194
195 KeyHeader* header = desc->header();
196 // make sure any padding in the header is zeroed.
197 memset(desc->header(), 0, kHeaderSize);
198
199 // We can only have one effect which touches the vertex shader
egdaniel170f90b2014-09-16 12:54:40 -0700200 if (optState.hasGeometryProcessor()) {
joshualittbd769d02014-09-04 08:56:46 -0700201 uint16_t* offsetAndSize =
bsalomon929f29a2014-07-17 07:55:11 -0700202 reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset +
203 offsetAndSizeIndex * 2 * sizeof(uint16_t));
bsalomon848faf02014-07-11 10:01:02 -0700204
205 GrEffectKeyBuilder b(&desc->fKey);
bsalomon929f29a2014-07-17 07:55:11 -0700206 uint16_t effectKeySize;
207 uint32_t effectOffset = desc->fKey.count();
egdaniela7dc0a82014-09-17 08:25:05 -0700208 effectKeySuccess |= GetEffectKey(*optState.getGeometryProcessor(), gpu->glCaps(),
209 requiresLocalCoordAttrib, &b, &effectKeySize);
bsalomon929f29a2014-07-17 07:55:11 -0700210 effectKeySuccess |= (effectOffset <= SK_MaxU16);
211
212 offsetAndSize[0] = SkToU16(effectOffset);
213 offsetAndSize[1] = effectKeySize;
214 ++offsetAndSizeIndex;
egdaniel170f90b2014-09-16 12:54:40 -0700215 *geometryProcessor = optState.getGeometryProcessor();
joshualittbd769d02014-09-04 08:56:46 -0700216 header->fHasGeometryProcessor = true;
217 }
218
egdaniel170f90b2014-09-16 12:54:40 -0700219 for (int s = 0; s < optState.numColorStages(); ++s) {
220 uint16_t* offsetAndSize =
221 reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset +
222 offsetAndSizeIndex * 2 * sizeof(uint16_t));
joshualittbd769d02014-09-04 08:56:46 -0700223
egdaniel170f90b2014-09-16 12:54:40 -0700224 GrEffectKeyBuilder b(&desc->fKey);
225 uint16_t effectKeySize;
226 uint32_t effectOffset = desc->fKey.count();
egdaniela7dc0a82014-09-17 08:25:05 -0700227 effectKeySuccess |= GetEffectKey(optState.getColorStage(s), gpu->glCaps(),
228 requiresLocalCoordAttrib, &b, &effectKeySize);
egdaniel170f90b2014-09-16 12:54:40 -0700229 effectKeySuccess |= (effectOffset <= SK_MaxU16);
joshualittbd769d02014-09-04 08:56:46 -0700230
egdaniel170f90b2014-09-16 12:54:40 -0700231 offsetAndSize[0] = SkToU16(effectOffset);
232 offsetAndSize[1] = effectKeySize;
233 ++offsetAndSizeIndex;
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000234 }
bsalomon929f29a2014-07-17 07:55:11 -0700235
egdaniel170f90b2014-09-16 12:54:40 -0700236 for (int s = 0; s < optState.numCoverageStages(); ++s) {
237 uint16_t* offsetAndSize =
238 reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset +
239 offsetAndSizeIndex * 2 * sizeof(uint16_t));
bsalomon929f29a2014-07-17 07:55:11 -0700240
egdaniel170f90b2014-09-16 12:54:40 -0700241 GrEffectKeyBuilder b(&desc->fKey);
242 uint16_t effectKeySize;
243 uint32_t effectOffset = desc->fKey.count();
egdaniela7dc0a82014-09-17 08:25:05 -0700244 effectKeySuccess |= GetEffectKey(optState.getCoverageStage(s), gpu->glCaps(),
245 requiresLocalCoordAttrib, &b, &effectKeySize);
egdaniel170f90b2014-09-16 12:54:40 -0700246 effectKeySuccess |= (effectOffset <= SK_MaxU16);
247
248 offsetAndSize[0] = SkToU16(effectOffset);
249 offsetAndSize[1] = effectKeySize;
250 ++offsetAndSizeIndex;
bsalomon@google.com798c8c42013-03-27 19:50:27 +0000251 }
egdaniel170f90b2014-09-16 12:54:40 -0700252
bsalomon848faf02014-07-11 10:01:02 -0700253 if (!effectKeySuccess) {
254 desc->fKey.reset();
255 return false;
256 }
257
bsalomon848faf02014-07-11 10:01:02 -0700258 // Because header is a pointer into the dynamic array, we can't push any new data into the key
259 // below here.
bsalomon@google.com798c8c42013-03-27 19:50:27 +0000260
egdanielae444962014-09-22 12:29:52 -0700261
commit-bot@chromium.org0a6fe712014-04-23 19:26:26 +0000262 header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType;
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000263
264 // Currently the experimental GS will only work with triangle prims (and it doesn't do anything
265 // other than pass through values from the VS to the FS anyway).
266#if GR_GL_EXPERIMENTAL_GS
267#if 0
268 header->fExperimentalGS = gpu->caps().geometryShaderSupport();
269#else
270 header->fExperimentalGS = false;
271#endif
272#endif
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +0000273
bsalomoncd523eb2014-09-23 08:19:00 -0700274 if (gpu->caps()->pathRenderingSupport() &&
275 GrGpu::IsPathRenderingDrawType(drawType) &&
276 gpu->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunction_TexturingMode) {
277 header->fUseFragShaderOnly = true;
278 SkASSERT(!optState.hasGeometryProcessor());
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000279 } else {
egdanielae444962014-09-22 12:29:52 -0700280 header->fUseFragShaderOnly = false;
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000281 }
282
bsalomoncd523eb2014-09-23 08:19:00 -0700283 bool defaultToUniformInputs = GrGpu::IsPathRenderingDrawType(drawType) ||
284 GR_GL_NO_CONSTANT_ATTRIBUTES;
285
286 if (!inputColorIsUsed) {
287 header->fColorInput = kAllOnes_ColorInput;
288 } else if (defaultToUniformInputs && !optState.hasColorVertexAttribute()) {
289 header->fColorInput = kUniform_ColorInput;
290 } else {
291 header->fColorInput = kAttribute_ColorInput;
292 SkASSERT(!header->fUseFragShaderOnly);
293 }
294
295 bool covIsSolidWhite = !optState.hasCoverageVertexAttribute() &&
296 0xffffffff == optState.getCoverageColor();
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000297
egdaniel170f90b2014-09-16 12:54:40 -0700298 if (covIsSolidWhite || !inputCoverageIsUsed) {
egdaniel842b0862014-09-02 10:01:30 -0700299 header->fCoverageInput = kAllOnes_ColorInput;
bsalomoncd523eb2014-09-23 08:19:00 -0700300 } else if (defaultToUniformInputs && !optState.hasCoverageVertexAttribute()) {
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000301 header->fCoverageInput = kUniform_ColorInput;
302 } else {
303 header->fCoverageInput = kAttribute_ColorInput;
bsalomoncd523eb2014-09-23 08:19:00 -0700304 SkASSERT(!header->fUseFragShaderOnly);
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000305 }
306
egdaniela7dc0a82014-09-17 08:25:05 -0700307 if (optState.readsDst()) {
bsalomon49f085d2014-09-05 13:34:00 -0700308 SkASSERT(dstCopy || gpu->caps()->dstReadInShaderSupport());
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000309 const GrTexture* dstCopyTexture = NULL;
bsalomon49f085d2014-09-05 13:34:00 -0700310 if (dstCopy) {
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000311 dstCopyTexture = dstCopy->texture();
312 }
joshualitt30ba4362014-08-21 20:18:45 -0700313 header->fDstReadKey = GrGLFragmentShaderBuilder::KeyForDstRead(dstCopyTexture,
314 gpu->glCaps());
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000315 SkASSERT(0 != header->fDstReadKey);
bsalomon@google.com26e18b52013-03-29 19:22:36 +0000316 } else {
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000317 header->fDstReadKey = 0;
bsalomon@google.comb5158812013-05-13 18:50:25 +0000318 }
319
egdaniela7dc0a82014-09-17 08:25:05 -0700320 if (optState.readsFragPosition()) {
joshualitt30ba4362014-08-21 20:18:45 -0700321 header->fFragPosKey = GrGLFragmentShaderBuilder::KeyForFragmentPosition(
egdaniel170f90b2014-09-16 12:54:40 -0700322 optState.getRenderTarget(), gpu->glCaps());
bsalomon@google.comb5158812013-05-13 18:50:25 +0000323 } else {
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000324 header->fFragPosKey = 0;
bsalomon@google.com26e18b52013-03-29 19:22:36 +0000325 }
326
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000327 // Record attribute indices
egdaniel170f90b2014-09-16 12:54:40 -0700328 header->fPositionAttributeIndex = optState.positionAttributeIndex();
329 header->fLocalCoordAttributeIndex = optState.localCoordAttributeIndex();
skia.committer@gmail.com2d816ad2013-05-23 07:01:22 +0000330
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000331 // For constant color and coverage we need an attribute with an index beyond those already set
egdaniel170f90b2014-09-16 12:54:40 -0700332 int availableAttributeIndex = optState.getVertexAttribCount();
bsalomoncd523eb2014-09-23 08:19:00 -0700333 if (optState.hasColorVertexAttribute()) {
egdaniel170f90b2014-09-16 12:54:40 -0700334 header->fColorAttributeIndex = optState.colorVertexAttributeIndex();
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000335 } else if (GrGLProgramDesc::kAttribute_ColorInput == header->fColorInput) {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000336 SkASSERT(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt);
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000337 header->fColorAttributeIndex = availableAttributeIndex;
338 availableAttributeIndex++;
339 } else {
340 header->fColorAttributeIndex = -1;
341 }
skia.committer@gmail.com2d816ad2013-05-23 07:01:22 +0000342
bsalomoncd523eb2014-09-23 08:19:00 -0700343 if (optState.hasCoverageVertexAttribute()) {
egdaniel170f90b2014-09-16 12:54:40 -0700344 header->fCoverageAttributeIndex = optState.coverageVertexAttributeIndex();
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000345 } else if (GrGLProgramDesc::kAttribute_ColorInput == header->fCoverageInput) {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000346 SkASSERT(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt);
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000347 header->fCoverageAttributeIndex = availableAttributeIndex;
348 } else {
349 header->fCoverageAttributeIndex = -1;
bsalomon@google.com798c8c42013-03-27 19:50:27 +0000350 }
351
egdanielc0648242014-09-22 13:17:02 -0700352 header->fPrimaryOutputType = optState.getPrimaryOutputType();
353 header->fSecondaryOutputType = optState.getSecondaryOutputType();
joshualittbd769d02014-09-04 08:56:46 -0700354
egdaniel170f90b2014-09-16 12:54:40 -0700355 for (int s = 0; s < optState.numColorStages(); ++s) {
356 colorStages->push_back(&optState.getColorStage(s));
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000357 }
egdaniel170f90b2014-09-16 12:54:40 -0700358 for (int s = 0; s < optState.numCoverageStages(); ++s) {
egdanielc0648242014-09-22 13:17:02 -0700359 coverageStages->push_back(&optState.getCoverageStage(s));
egdaniel170f90b2014-09-16 12:54:40 -0700360 }
361
commit-bot@chromium.orga34995e2013-10-23 05:42:03 +0000362 header->fColorEffectCnt = colorStages->count();
363 header->fCoverageEffectCnt = coverageStages->count();
bsalomon@google.com798c8c42013-03-27 19:50:27 +0000364
bsalomon848faf02014-07-11 10:01:02 -0700365 desc->finalize();
366 return true;
367}
368
369void GrGLProgramDesc::finalize() {
370 int keyLength = fKey.count();
371 SkASSERT(0 == (keyLength % 4));
372 *this->atOffset<uint32_t, kLengthOffset>() = SkToU32(keyLength);
373
374 uint32_t* checksum = this->atOffset<uint32_t, kChecksumOffset>();
375 *checksum = 0;
376 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), keyLength);
bsalomon@google.com798c8c42013-03-27 19:50:27 +0000377}
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000378
379GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) {
bsalomon848faf02014-07-11 10:01:02 -0700380 size_t keyLength = other.keyLength();
381 fKey.reset(keyLength);
382 memcpy(fKey.begin(), other.fKey.begin(), keyLength);
bsalomon@google.com2db3ded2013-05-22 14:34:04 +0000383 return *this;
384}