aboutsummaryrefslogtreecommitdiffhomepage
path: root/resources
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-11-03 22:32:07 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-03 22:32:08 -0800
commitbb8a0ababab1aa2693a2a97733524ee367da1791 (patch)
tree8472cabc18c38e6c6b7c66f67a7c73ba41bde47f /resources
parent1b6ab4417e0edef3b91d150e6650205f49f04d17 (diff)
update slide content
BUG=skia: TBR= Review URL: https://codereview.chromium.org/698563004
Diffstat (limited to 'resources')
-rw-r--r--resources/slides.lua53
-rw-r--r--resources/slides_content2.lua123
-rw-r--r--resources/slides_utils.lua22
3 files changed, 111 insertions, 87 deletions
diff --git a/resources/slides.lua b/resources/slides.lua
index f706a29659..cf1a1a6229 100644
--- a/resources/slides.lua
+++ b/resources/slides.lua
@@ -27,6 +27,32 @@ function make_paint(typefacename, stylebits, size, color)
return paint
end
+function center_rect(sw, sh, dst)
+ local dw = dst.right - dst.left
+ local dh = dst.bottom - dst.top
+
+ local rw, rh
+
+ if sw / sh > dw / dh then
+ rw = dw
+ rh = sh * dw / sw
+ else
+ rh = dh
+ rw = sw * dh / sh
+ end
+
+ local x = dst.left + ((sw - rw) / 2)
+ local y = dst.top + ((sh - rh) / 2)
+ return make_rect(x, y, x + rw, y + rh)
+end
+
+function draw_image_centered(canvas, image)
+ local sw = image:width()
+ local sh = image:height()
+ local dstR = center_rect(image:width(), image:height(), make_rect(20, 20, 620, 460))
+ canvas:drawImageRect(image, nil, dstR)
+end
+
function draw_bullet(canvas, x, y, paint, indent)
if 0 == indent then
return
@@ -46,7 +72,14 @@ function stroke_rect(canvas, rect, color)
end
function drawSlide(canvas, slide, master_template)
- template = master_template.slide -- need to sniff the slide to know if we're title or slide
+
+ if #slide == 1 then
+ template = master_template.title
+ canvas:drawText(slide[1].text, 320, 240, template[1])
+ return
+ end
+
+ template = master_template.slide
local x = template.margin_x
local y = template.margin_y
@@ -173,23 +206,19 @@ end
function next_slide()
local prev = gSlides[gSlideIndex]
- gSlideIndex = gSlideIndex + 1
- if gSlideIndex > #gSlides then
- gSlideIndex = 1
+ if gSlideIndex < #gSlides then
+ gSlideIndex = gSlideIndex + 1
+ spawn_transition(prev, gSlides[gSlideIndex], true)
end
-
- spawn_transition(prev, gSlides[gSlideIndex], true)
end
function prev_slide()
local prev = gSlides[gSlideIndex]
- gSlideIndex = gSlideIndex - 1
- if gSlideIndex < 1 then
- gSlideIndex = #gSlides
+ if gSlideIndex > 1 then
+ gSlideIndex = gSlideIndex - 1
+ spawn_transition(prev, gSlides[gSlideIndex], false)
end
-
- spawn_transition(prev, gSlides[gSlideIndex], false)
end
function convert_to_picture_drawable(slide)
@@ -204,7 +233,6 @@ function convert_to_image_drawable(slide)
return new_drawable_image(surf:newImageSnapshot())
end
--- gMakeDrawable = convert_to_picture_drawable
gMakeDrawable = new_drawable_slide
load_file("slides_transitions")
@@ -285,6 +313,7 @@ function draw_bg(canvas)
local grad = Sk.newLinearGradient( 0, 0, { a=1, r=0, g=0, b=.3 },
640, 480, { a=1, r=0, g=0, b=.8 })
bgPaint:setShader(grad)
+ bgPaint:setDither(true)
end
canvas:drawPaint(bgPaint)
diff --git a/resources/slides_content2.lua b/resources/slides_content2.lua
index d2a4016fbd..19d7203812 100644
--- a/resources/slides_content2.lua
+++ b/resources/slides_content2.lua
@@ -2,80 +2,29 @@ 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
+- src : geometry, images, text
+- attr: shaders, filters, antialiasing, blending
+- dst : raster, gpu, pdf, picture
Skia : Porting
- C++ and some SIMD assembly
-- Fonts : CoreText, FreeType, GDI, DirectWrite, *user-define
+- Fonts : CoreText, FreeType, GDI, DirectWrite
- 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 : Clients
+- Blink : under the GraphicsContext hood
+- Chrome : ui/gfx and compositor
+- Android framework
+- third parties : e.g. Mozilla
+- sites.google.com/site/skiadocs
-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
Skia In Blink : Fonts
-- Assist with code-sharing between platforms
+- SkTypeface and SkFontMgr : platform agnostic
- Runtime switch between GDI and DirectWrite
-- Add SkFontMgr for selection
+- SkTextBlob to encapsulate runs of text
- Push LCD decision-making out of Blink
Skia In Blink : Record-Time-Rasterization
@@ -89,8 +38,52 @@ Skia In Blink : Record-Time-Rasterization
Skia In Blink : RTR response
- SkImageFilter w/ CPU and GPU implementations
-- SkPaint::FilterLevel : none, low, medium (mipmaps), high
+- FilterLevel : none, low, medium (mipmaps), high
- SkPicture for caching SVG
- SkPicture + saveLayer() for masks
-- PathOps for resolving complex paths
- SkPictureShader for device-independent patterns
+
+Skia In Blink : Recording
+- GraphicsContext usuaually backed by SkPicture
+-- draw commands are recorded for later playback
+-- all parameters must be copied or (safely) ref'd
+-- may record more than is currently visible
+- Resulting picture may be replayed multiple times
+
+Skia In Blink : Recording response
+- New implementation
+- Optimized for recording speed
+-- shallow copies whenever possible
+-- rearchitect all Skia effects to be immutable
+- Reentrant-safe for playback in multiple threads
+-- also affected effect subclasses
+
+Skia In Blink : Playback
+- Separate pass for optimizations (optional)
+-- peep-holes rewrites
+-- compute bounding-box hierarchy for faster tiling
+-- can be done outside of Blink thread
+- GPU optimizations
+-- layer "hoisting"
+-- distance field fonts
+
+Skia : Roadmap
+
+Skia In Blink : Roadmap
+- GPU performance
+-- extended OpenGL features (e.g. geometry shaders)
+-- reordering for increased batching
+-- support for new low-level OpenGL APIs
+- Cross process support
+-- immediate mode ala SkGPipe
+-- serialize pictures
+
+Skia API Roadmap
+- Direct support for sRGB
+- Stable C API / ABI
+-- bindings for JS, Go, Python, Lua
+- Robust file format
+
+Demo
+
diff --git a/resources/slides_utils.lua b/resources/slides_utils.lua
index 24e58cee51..f687d87586 100644
--- a/resources/slides_utils.lua
+++ b/resources/slides_utils.lua
@@ -54,12 +54,17 @@ function pretty_print_slides(slides)
io.write("}\n")
end
-function parse_transition_type(s)
- return s:match("^<%s*transition%s*=%s*(%a+)%s*>$")
+function parse_attr(s, lvalue)
+ local ts = "^<%s*" .. lvalue .. "%s*=%s*(%a+)%s*>$"
+ return s:match(ts)
end
-function parse_blockstyle_type(s)
- return s:match("^<%s*blockstyle%s*=%s*(%a+)%s*>$")
+function flush(slides, block)
+ if #block > 0 then
+ slides[#slides + 1] = block
+ return {}
+ end
+ return block
end
function parse_file(file)
@@ -69,13 +74,10 @@ function parse_file(file)
for line in file:lines() do
local s = trim_ws(line)
if #s == 0 then -- done with a block
- if #block > 0 then
- slides[#slides + 1] = block
- block = {}
- end
+ block = flush(slides, block)
else
- local transition_type = parse_transition_type(s)
- local blockstyle = parse_blockstyle_type(s)
+ local transition_type = parse_attr(s, "transition")
+ local blockstyle = parse_attr(s, "blockstyle")
if transition_type then
block["transition"] = transition_type
elseif blockstyle then