From 628c2194955690fbde0d28662bf5af348310910a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 15 Feb 2009 04:33:43 -0600 Subject: [PATCH] opengl.texture-cache is not necessary; simplify code --- basis/opengl/texture-cache/authors.txt | 1 - .../texture-cache/texture-cache-tests.factor | 4 --- .../opengl/texture-cache/texture-cache.factor | 25 ------------------- basis/ui/gadgets/worlds/worlds.factor | 10 ++++---- basis/ui/images/images.factor | 14 +++-------- basis/ui/text/core-text/core-text.factor | 11 +++----- 6 files changed, 13 insertions(+), 52 deletions(-) delete mode 100644 basis/opengl/texture-cache/authors.txt delete mode 100644 basis/opengl/texture-cache/texture-cache-tests.factor delete mode 100644 basis/opengl/texture-cache/texture-cache.factor diff --git a/basis/opengl/texture-cache/authors.txt b/basis/opengl/texture-cache/authors.txt deleted file mode 100644 index d4f5d6b3ae..0000000000 --- a/basis/opengl/texture-cache/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Slava Pestov \ No newline at end of file diff --git a/basis/opengl/texture-cache/texture-cache-tests.factor b/basis/opengl/texture-cache/texture-cache-tests.factor deleted file mode 100644 index 4ae2e80bb6..0000000000 --- a/basis/opengl/texture-cache/texture-cache-tests.factor +++ /dev/null @@ -1,4 +0,0 @@ -! Copyright (C) 2009 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: tools.test opengl.texture-cache ; -IN: opengl.texture-cache.tests diff --git a/basis/opengl/texture-cache/texture-cache.factor b/basis/opengl/texture-cache/texture-cache.factor deleted file mode 100644 index e3774e26f4..0000000000 --- a/basis/opengl/texture-cache/texture-cache.factor +++ /dev/null @@ -1,25 +0,0 @@ -! Copyright (C) 2009 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs cache colors.constants destructors fry -opengl.textures kernel ; -IN: opengl.texture-cache - -TUPLE: texture-cache renderer cache disposed ; - -: ( renderer -- cache ) - texture-cache new - swap >>renderer - >>cache ; - -GENERIC: render-texture ( key renderer -- image ) - -: get-texture ( key texture-cache -- texture ) - dup check-disposed - [ cache>> ] keep - '[ _ renderer>> render-texture ] cache ; - -M: texture-cache dispose* - cache>> values dispose-each ; - -: purge-texture-cache ( texture-cache -- ) - cache>> purge-cache ; \ No newline at end of file diff --git a/basis/ui/gadgets/worlds/worlds.factor b/basis/ui/gadgets/worlds/worlds.factor index f35a17583d..aedd7a8985 100644 --- a/basis/ui/gadgets/worlds/worlds.factor +++ b/basis/ui/gadgets/worlds/worlds.factor @@ -1,10 +1,10 @@ ! Copyright (C) 2005, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays assocs continuations kernel math models call -namespaces opengl opengl.texture-cache sequences io combinators +USING: accessors arrays assocs continuations kernel math models +call namespaces opengl sequences io combinators combinators.short-circuit fry math.vectors math.rectangles cache -ui.gadgets ui.gestures ui.render ui.text ui.text.private ui.backend -ui.gadgets.tracks ; +ui.gadgets ui.gestures ui.render ui.text ui.text.private +ui.backend ui.gadgets.tracks ; IN: ui.gadgets.worlds TUPLE: world < track @@ -67,7 +67,7 @@ M: world children-on nip children>> ; [ init-gl ] [ draw-gadget ] [ finish-text-rendering ] - [ images>> [ purge-texture-cache ] when* ] + [ images>> [ purge-cache ] when* ] } cleave ] with-gl-context ; diff --git a/basis/ui/images/images.factor b/basis/ui/images/images.factor index af98476176..f483367e62 100644 --- a/basis/ui/images/images.factor +++ b/basis/ui/images/images.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: namespaces cache images images.loader accessors assocs kernel -opengl opengl.gl opengl.textures opengl.texture-cache ui.gadgets.worlds ; +USING: namespaces cache images images.loader accessors assocs +kernel opengl opengl.gl opengl.textures ui.gadgets.worlds ; IN: ui.images TUPLE: image-name path ; @@ -21,21 +21,15 @@ PRIVATE> ] unless* ] change-images - images>> ; + [ [ ] unless* ] change-images images>> ; PRIVATE> : rendered-image ( path -- texture ) - world get image-texture-cache get-texture ; + world get image-texture-cache [ cached-image ] cache ; : draw-image ( image-name -- ) rendered-image display-list>> glCallList ; diff --git a/basis/ui/text/core-text/core-text.factor b/basis/ui/text/core-text/core-text.factor index 6bce483342..606990a941 100644 --- a/basis/ui/text/core-text/core-text.factor +++ b/basis/ui/text/core-text/core-text.factor @@ -3,7 +3,7 @@ USING: assocs accessors alien core-graphics.types core-text core-text.fonts kernel hashtables namespaces sequences ui.gadgets.worlds ui.text ui.text.private opengl opengl.gl -opengl.texture-cache destructors combinators core-foundation +opengl.textures destructors combinators core-foundation core-foundation.strings math math.vectors init colors colors.constants cache arrays ; IN: ui.text.core-text @@ -11,22 +11,19 @@ IN: ui.text.core-text SINGLETON: core-text-renderer M: core-text-renderer init-text-rendering - core-text-renderer >>text-handle drop ; + >>text-handle drop ; M: core-text-renderer string-dim [ " " string-dim { 0 1 } v* ] [ cached-line image>> dim>> ] if-empty ; -M: core-text-renderer render-texture - drop first2 cached-line image>> ; - M: core-text-renderer finish-text-rendering - text-handle>> purge-texture-cache + text-handle>> purge-cache cached-lines get purge-cache ; : rendered-line ( font string -- texture ) - 2array world get text-handle>> get-texture ; + world get text-handle>> [ cached-line image>> ] 2cache ; M: core-text-renderer draw-string ( font string -- ) rendered-line display-list>> glCallList ;