blob: 21fe8343af2b366ce9b5636330e86babe1f57a0f [file] [log] [blame]
Brian Salomon217522c2019-06-11 15:55:30 -04001/*
2 * Copyright 2019 Google LLC
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
8#include "src/gpu/GrSwizzle.h"
9#include "src/core/SkRasterPipeline.h"
10
11void GrSwizzle::apply(SkRasterPipeline* pipeline) const {
12 SkASSERT(pipeline);
13 switch (fKey) {
14 case GrSwizzle::RGBA().asKey():
15 return;
16 case GrSwizzle::BGRA().asKey():
17 pipeline->append(SkRasterPipeline::swap_rb);
18 return;
19 default: {
20 GR_STATIC_ASSERT(sizeof(uintptr_t) >= 4 * sizeof(char));
21 // Rather than allocate the 4 control bytes on the heap somewhere, just jam them right
22 // into a uintptr_t context.
23 uintptr_t ctx;
24 memcpy(&ctx, fSwiz, 4 * sizeof(char));
25 pipeline->append(SkRasterPipeline::swizzle, ctx);
26 return;
27 }
28 }
29}