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
Brian Salomon3ec1f542019-06-17 17:54:57 +00008#include "src/gpu/GrSwizzle.h"
Brian Salomon217522c2019-06-11 15:55:30 -04009#include "src/core/SkRasterPipeline.h"
10
11void GrSwizzle::apply(SkRasterPipeline* pipeline) const {
12 SkASSERT(pipeline);
13 switch (fKey) {
Robert Phillipsc34d9932019-06-18 11:57:12 +000014 case GrSwizzle::RGBA().asKey():
Brian Salomon217522c2019-06-11 15:55:30 -040015 return;
Robert Phillipsc34d9932019-06-18 11:57:12 +000016 case GrSwizzle::BGRA().asKey():
Brian Salomon217522c2019-06-11 15:55:30 -040017 pipeline->append(SkRasterPipeline::swap_rb);
18 return;
Brian Salomon217522c2019-06-11 15:55:30 -040019 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}