update slides
authorreed <reed@google.com>
Tue, 4 Nov 2014 21:24:47 +0000 (13:24 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 4 Nov 2014 21:24:47 +0000 (13:24 -0800)
BUG=skia:

Review URL: https://codereview.chromium.org/686853005

resources/slides.lua
resources/slides_content2.lua
resources/slides_transitions.lua
resources/slides_utils.lua
src/utils/SkLua.cpp

index df9fc47..43c9b3b 100644 (file)
@@ -1,4 +1,5 @@
 gShowBounds = false
+gUseBlurInTransitions = false
 
 gPath = "/skia/trunk/resources/"
 
@@ -27,32 +28,6 @@ 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
@@ -165,6 +140,8 @@ local gCurrAnimation
 
 gSlideIndex = 1
 
+-----------------------------------------------------------------------------
+
 function new_drawable_picture(pic)
     return {
         picture = pic,
@@ -187,6 +164,18 @@ function new_drawable_image(img)
     }
 end
 
+function convert_to_picture_drawable(slide)
+    local rec = Sk.newPictureRecorder()
+    drawSlide(rec:beginRecording(640, 480), slide, gTemplate)
+    return new_drawable_picture(rec:endRecording())
+end
+
+function convert_to_image_drawable(slide)
+    local surf = Sk.newRasterSurface(640, 480)
+    drawSlide(surf:getCanvas(), slide, gTemplate)
+    return new_drawable_image(surf:newImageSnapshot())
+end
+
 function new_drawable_slide(slide)
     return {
         slide = slide,
@@ -203,6 +192,14 @@ function new_drawable_slide(slide)
     }
 end
 
+gNewDrawableFactory = {
+    default = new_drawable_slide,
+    picture = convert_to_picture_drawable,
+    image = convert_to_image_drawable,
+}
+
+-----------------------------------------------------------------------------
+
 function next_slide()
     local prev = gSlides[gSlideIndex]
 
@@ -221,19 +218,7 @@ function prev_slide()
     end
 end
 
-function convert_to_picture_drawable(slide)
-    local rec = Sk.newPictureRecorder()
-    drawSlide(rec:beginRecording(640, 480), slide, gTemplate)
-    return new_drawable_picture(rec:endRecording())
-end
-
-function convert_to_image_drawable(slide)
-    local surf = Sk.newRasterSurface(640, 480)
-    drawSlide(surf:getCanvas(), slide, gTemplate)
-    return new_drawable_image(surf:newImageSnapshot())
-end
-
-gMakeDrawable = new_drawable_slide
+gDrawableType = "default"
 
 load_file("slides_transitions")
 
@@ -249,8 +234,8 @@ function spawn_transition(prevSlide, nextSlide, is_forward)
         transition = fade_slide_transition
     end
 
-    local prevDrawable = gMakeDrawable(prevSlide)
-    local nextDrawable = gMakeDrawable(nextSlide)
+    local prevDrawable = gNewDrawableFactory[gDrawableType](prevSlide)
+    local nextDrawable = gNewDrawableFactory[gDrawableType](nextSlide)
     gCurrAnimation = transition(prevDrawable, nextDrawable, is_forward)
 end
 
@@ -352,6 +337,11 @@ local keyProcs = {
     ["-"] = function () scale_text_delta(gTemplate, -1) end,
 
     b = function () gShowBounds = not gShowBounds end,
+    B = function () gUseBlurInTransitions = not gUseBlurInTransitions end,
+
+    ["1"] = function () gDrawableType = "default" end,
+    ["2"] = function () gDrawableType = "picture" end,
+    ["3"] = function () gDrawableType = "image" end,
 }
 
 function onCharHandler(uni)
index 19d7203..3b4eb09 100644 (file)
@@ -1,10 +1,14 @@
 Skia Update
 
+Skia : Access
+- code.google.com/p/skia
+- sites.google.com/site/skiadocs
+
 Skia : Overview
-- portable 2D graphics engine
-- src : geometry, images, text
-- attr: shaders, filters, antialiasing, blending
-- dst : raster, gpu, pdf, picture
+- portable graphics engine
+- 2D transformations + perspective
+- primitives: text, geometry, images
+- effects: shaders, filters, antialiasing, blending
 
 Skia : Porting
 - C++ and some SIMD assembly
@@ -12,12 +16,21 @@ Skia : Porting
 - Threads : wrappers for native apis
 - Memory : wrappers for [new, malloc, discardable]
 
+Skia : Backends
+- Surface
+-- raster : ARGB, RGB16, A8 in software
+-- gpu : transcribe to OpenGL
+- Document
+-- transcribe to PDF or XPS
+- Record and Playback
+-- Picture
+-- Pipe
+
 Skia : Clients
 - Blink : under the GraphicsContext hood
 - Chrome : ui/gfx and compositor
-- Android framework
+- Android framework
 - third parties : e.g. Mozilla
-- sites.google.com/site/skiadocs
 
 Skia In Blink
 
@@ -28,7 +41,7 @@ Skia In Blink : Fonts
 - Push LCD decision-making out of Blink
 
 Skia In Blink : Record-Time-Rasterization
-- Direct rendering during “Paint” pass
+- What? : direct rendering during “Paint” pass
 -- Image scaling, filters
 -- SVG patterns, masks
 - Problematic in modern Blink
@@ -38,18 +51,19 @@ Skia In Blink : Record-Time-Rasterization
 
 Skia In Blink : RTR response
 - SkImageFilter w/ CPU and GPU implementations
-- FilterLevel : none, low, medium (mipmaps), high
+- Bitmap scaling : bilerp, mipmaps, fancy
 - 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
+- GraphicsContext (now) 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
+-- from different thread(s)
 
 Skia In Blink : Recording response
 - New implementation
@@ -66,24 +80,44 @@ Skia In Blink : Playback
 -- can be done outside of Blink thread
 - GPU optimizations
 -- layer "hoisting"
--- distance field fonts
+-- distance fields : fonts and concave paths
+
+Skia In Blink : multi-picture-draw
+- mpd(canvas[], picture[], matrix[], paint[])
+- Requires independent canvas objects
+-- all other parameters can be shared
+-- draw order is unspecified
+- Examples
+-- 1 picture drawing to multiple tiles (canvases)
+-- multiple pictures each drawing to its own layer
+
+Skia In Blink : MPD optimizations*
+- GPU
+-- "layer hoisting" to reduce rendertarget switching
+-- layer atlasing (also applies to imagefilters)
+-- pre-uploading of textures
+-- atlas yuv (from jpeg) to convert on gpu
+- CPU
+-- parallel execution using thread pool
+-- pre-decoding of images based on visibility
 
 Skia : Roadmap
 
-Skia In Blink : Roadmap
-- GPU performance
+Skia : Roadmap - performance
+- GPU
 -- 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
+- CPU
+-- SIMD applied to floats
+-- smarter culling in pictures
 
-Skia API Roadmap
+Skia : Roadmap - API
+- Cross process support
 - Direct support for sRGB
-- Stable C API / ABI
--- bindings for JS, Go, Python, Lua
 - Robust file format
+- Support PDF viewing
+- Stable C ABI
+-- bindings for JS, Go, Python, Lua
 
 Demo
-
index 4a838a4..bab3827 100644 (file)
@@ -39,7 +39,9 @@ function sqr(value) return value * value end
 
 function set_blur(paint, alpha)
     local sigma = sqr(1 - alpha) * 20
---    paint:setImageFilter(Sk.newBlurImageFilter(sigma, sigma))
+    if gUseBlurInTransitions then
+        paint:setImageFilter(Sk.newBlurImageFilter(sigma, sigma))
+    end
     paint:setAlpha(alpha)
 end
 
index f687d87..3b1230c 100644 (file)
@@ -95,7 +95,8 @@ function parse_file(file)
             end
         end
     end
---    pretty_print_slides(slides)
+    flush(slides, block)
+
     return slides
 end
 
index 967233d..b12e3e9 100644 (file)
@@ -1906,7 +1906,7 @@ static int lsk_newTypeface(lua_State* L) {
 }
 
 static int lsk_newRasterSurface(lua_State* L) {
-    int width = lua2int_def(L, 2, 0);
+    int width = lua2int_def(L, 1, 0);
     int height = lua2int_def(L, 2, 0);
     SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
     SkSurface* surface = SkSurface::NewRaster(info);