aboutsummaryrefslogtreecommitdiffhomepage
path: root/resources/slides_content2.lua
blob: d2a4016fbd1ae3489a6b06a61486e8b52f82deb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Skia Update

Skia : Overview
- portable 2D graphics engine
- src: geometry, images, text
- dst : raster, gpu, pdf, displaylist, *user-defined
- attr: shaders, filters, antialiasing, blending, *user-defined

Skia : Clients
- Blink : direct and via GraphicsContext
- Chrome : ui/gfx and compositor
- Android framework
- third parties : e.g. Mozilla
- code.google.com/p/skia

Skia : Porting
- C++ and some SIMD assembly
- Fonts : CoreText, FreeType, GDI, DirectWrite, *user-define
- Threads : wrappers for native apis
- Memory : wrappers for [new, malloc, discardable]

Skia : API
- SkCanvas
-- save, saveLayer, restore
-- translate, scale, rotate, concat
-- clipRect, clipPath
- SkPaint
-- color, stroking, antialiasing, filtering
-- typeface, textSize, text-flags
-- effects: shader, color-filter, image-filter, mask-filter, xfermode

<blockstyle = code>
void onDraw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setFoo(...);
    canvas->drawRect(..., paint);
    paint.setBar(...);
    canvas->drawOval(..., paint);
}

<blockstyle = code>
void onDraw(SkCanvas* canvas) {
    canvas->drawRect(..., fPaint0);
    canvas->drawOval(..., fPaint1);
}

Skia In Blink : GraphicsContext
- Similar
-- rects, paths, images, text
-- matrices, clips
- Different
-- save/restore affect matrix+clip PLUS all paint settings
-- both fill and stroke settings are specified
-- hence: fillRect(), strokeRect(), drawRect()

<blockstyle = code>
void onDraw(GraphicsContext* gc) {
    gc->save();
    gc->setFoo(...);
    gc->fillRect(...);
    gc->setBar(...);
    gc->fillOval(...);
    gc->restore();
}

Skia In Blink : more than GraphicsContext
- Simple wrappers
-- FloatRect -- SkRect
-- Path -- SkPath
- Font.h + 21 others
-- SkTypeface + flags
- Image.h + 25 others
-- SkBitmap, SkImage

Skia In Blink : Fonts
- Assist with code-sharing between platforms
- Runtime switch between GDI and DirectWrite
- Add SkFontMgr for selection
- Push LCD decision-making out of Blink

Skia In Blink : Record-Time-Rasterization
- Direct rendering during “Paint” pass
-- Image scaling, filters
-- SVG patterns, masks
- Problematic in modern Blink
-- CTM not always known/knowable
-- Rendering backend not always known (gpu or cpu)
-- Rasterization takes (too much) time

Skia In Blink : RTR response
- SkImageFilter w/ CPU and GPU implementations
- SkPaint::FilterLevel : none, low, medium (mipmaps), high
- SkPicture for caching SVG
- SkPicture + saveLayer() for masks
-- PathOps for resolving complex paths
- SkPictureShader for device-independent patterns