From 7b8646669f5b1e2daddf53764bcde62d743ff076 Mon Sep 17 00:00:00 2001 From: reed Date: Tue, 4 Nov 2014 13:24:47 -0800 Subject: update slides BUG=skia: Review URL: https://codereview.chromium.org/686853005 --- resources/slides.lua | 72 +++++++++++++++++----------------------- resources/slides_content2.lua | 72 +++++++++++++++++++++++++++++----------- resources/slides_transitions.lua | 4 ++- resources/slides_utils.lua | 3 +- 4 files changed, 89 insertions(+), 62 deletions(-) (limited to 'resources') diff --git a/resources/slides.lua b/resources/slides.lua index df9fc47bd6..43c9b3b32f 100644 --- a/resources/slides.lua +++ b/resources/slides.lua @@ -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) diff --git a/resources/slides_content2.lua b/resources/slides_content2.lua index 19d7203812..3b4eb09445 100644 --- a/resources/slides_content2.lua +++ b/resources/slides_content2.lua @@ -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 - diff --git a/resources/slides_transitions.lua b/resources/slides_transitions.lua index 4a838a4717..bab3827767 100644 --- a/resources/slides_transitions.lua +++ b/resources/slides_transitions.lua @@ -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 diff --git a/resources/slides_utils.lua b/resources/slides_utils.lua index f687d87586..3b1230c10b 100644 --- a/resources/slides_utils.lua +++ b/resources/slides_utils.lua @@ -95,7 +95,8 @@ function parse_file(file) end end end --- pretty_print_slides(slides) + flush(slides, block) + return slides end -- cgit v1.2.3