Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSpriteBlitter_ARGB32.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2006 The Android Open Source Project
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
14#include "src/core/SkBlitRow.h"
16
17#include <cstddef>
18#include <cstdint>
19
20///////////////////////////////////////////////////////////////////////////////
21
23public:
24 Sprite_D32_S32(const SkPixmap& src, U8CPU alpha) : INHERITED(src) {
25 SkASSERT(src.colorType() == kN32_SkColorType);
26
27 unsigned flags32 = 0;
28 if (255 != alpha) {
30 }
31 if (!src.isOpaque()) {
33 }
34
35 fProc32 = SkBlitRow::Factory32(flags32);
36 fAlpha = alpha;
37 }
38
39 void blitRect(int x, int y, int width, int height) override {
40 SkASSERT(width > 0 && height > 0);
41 uint32_t* SK_RESTRICT dst = fDst.writable_addr32(x, y);
42 const uint32_t* SK_RESTRICT src = fSource.addr32(x - fLeft, y - fTop);
43 size_t dstRB = fDst.rowBytes();
44 size_t srcRB = fSource.rowBytes();
45 SkBlitRow::Proc32 proc = fProc32;
46 U8CPU alpha = fAlpha;
47
48 do {
49 proc(dst, src, width, alpha);
50 dst = (uint32_t* SK_RESTRICT)((char*)dst + dstRB);
51 src = (const uint32_t* SK_RESTRICT)((const char*)src + srcRB);
52 } while (--height != 0);
53 }
54
55private:
56 SkBlitRow::Proc32 fProc32;
57 U8CPU fAlpha;
58
59 using INHERITED = SkSpriteBlitter;
60};
61
62///////////////////////////////////////////////////////////////////////////////
63
65 SkArenaAlloc* allocator) {
66 SkASSERT(allocator != nullptr);
67
68 if (paint.getColorFilter() != nullptr) {
69 return nullptr;
70 }
71 if (paint.getMaskFilter() != nullptr) {
72 return nullptr;
73 }
74 if (source.colorType() == kN32_SkColorType && paint.isSrcOver()) {
75 // this can handle alpha, but not xfermode
76 return allocator->make<Sprite_D32_S32>(source, paint.getAlpha());
77 }
78 return nullptr;
79}
#define SkASSERT(cond)
Definition SkAssert.h:116
unsigned U8CPU
Definition SkCPUTypes.h:18
#define SK_RESTRICT
Definition SkFeatures.h:42
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
SkColorType colorType() const
Definition SkBitmap.h:160
static Proc32 Factory32(unsigned flags32)
void(* Proc32)(uint32_t dst[], const SkPMColor src[], int count, U8CPU alpha)
Definition SkBlitRow.h:27
@ kSrcPixelAlpha_Flag32
Definition SkBlitRow.h:18
@ kGlobalAlpha_Flag32
Definition SkBlitRow.h:17
const uint32_t * addr32() const
Definition SkPixmap.h:352
size_t rowBytes() const
Definition SkPixmap.h:145
uint32_t * writable_addr32(int x, int y) const
Definition SkPixmap.h:537
const SkPixmap fSource
static SkSpriteBlitter * ChooseL32(const SkPixmap &source, const SkPaint &, SkArenaAlloc *)
Sprite_D32_S32(const SkPixmap &src, U8CPU alpha)
void blitRect(int x, int y, int width, int height) override
Blit a solid rectangle one or more pixels wide.
const Paint & paint
SkBitmap source
Definition examples.cpp:28
double y
double x
int32_t height
int32_t width