1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project 48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkAnimator_DEFINED 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkAnimator_DEFINED 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkScalar.h" 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkKey.h" 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkEventSink.h" 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkAnimateMaker; 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkCanvas; 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkDisplayable; 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkEvent; 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkExtras; 228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstruct SkMemberInfo; 238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkPaint; 248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstruct SkRect; 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkStream; 268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkTypedArray; 278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkXMLParserError; 288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkDOM; 298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstruct SkDOMNode; 308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** SkElementType is the type of element: a rectangle, a color, an animator, and so on. 328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com This enum is incomplete and will be fleshed out in a future release */ 338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comenum SkElementType { 348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kElementDummyType 358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** SkFieldType is the type of field: a scalar, a string, an integer, a boolean, and so on. 378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com This enum is incomplete and will be fleshed out in a future release */ 388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comenum SkFieldType { 398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kFieldDummyType 408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkAnimator 438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com The SkAnimator class decodes an XML stream into a display list. The 45fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com display list can be drawn statically as a picture, or can drawn 468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com different elements at different times to form a moving animation. 478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkAnimator does not read the system time on its own; it relies on the 498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com caller to pass the current time. The caller can pause, speed up, or 508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com reverse the animation by varying the time passed in. 518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 52fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com The XML describing the display list must conform to the schema 53fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com described by SkAnimateSchema.xsd. 548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com The XML must contain an <event> element to draw. Usually, it contains 568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com an <event kind="onload" /> block to add some drawing elements to the 578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com display list when the document is first decoded. 588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Here's an "Hello World" XML sample: 608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com <screenplay> 628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com <event kind="onload" > 638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com <text text="Hello World" y="20" /> 648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com </event> 658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com </screenplay> 668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com To read and draw this sample: 688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // choose one of these two 708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkAnimator animator; // declare an animator instance on the stack 718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // SkAnimator* animator = new SkAnimator() // or one could instantiate the class 728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // choose one of these three 748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com animator.decodeMemory(buffer, size); // to read from RAM 758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com animator.decodeStream(stream); // to read from a user-defined stream (e.g., a zip file) 768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com animator.decodeURI(filename); // to read from a web location, or from a local text file 778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // to draw to the current window: 798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkCanvas canvas(getBitmap()); // create a canvas 808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com animator.draw(canvas, &paint, 0); // draw the scene 818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/ 828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkAnimator : public SkEventSink { 838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkAnimator(); 858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual ~SkAnimator(); 868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 87fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com /** Add a drawable extension to the graphics engine. Experimental. 888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param extras A derived class that implements methods that identify and instantiate the class 898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void addExtras(SkExtras* extras); 918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Read in XML from a stream, and append it to the current 938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com animator. Returns false if an error was encountered. 948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Error diagnostics are stored in fErrorCode and fLineNumber. 958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param stream The stream to append. 968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the XML was parsed successfully. 978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool appendStream(SkStream* stream); 998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 100fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com /** Read in XML from memory. Returns true if the file can be 1018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com read without error. Returns false if an error was encountered. 1028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Error diagnostics are stored in fErrorCode and fLineNumber. 1038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param buffer The XML text as UTF-8 characters. 1048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param size The XML text length in bytes. 1058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the XML was parsed successfully. 1068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool decodeMemory(const void* buffer, size_t size); 1088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 109fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com /** Read in XML from a stream. Returns true if the file can be 1108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com read without error. Returns false if an error was encountered. 1118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Error diagnostics are stored in fErrorCode and fLineNumber. 1128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param stream The stream containg the XML text as UTF-8 characters. 1138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the XML was parsed successfully. 1148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool decodeStream(SkStream* stream); 1168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 117fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com /** Parse the DOM tree starting at the specified node. Returns true if it can be 1188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com parsed without error. Returns false if an error was encountered. 1198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Error diagnostics are stored in fErrorCode and fLineNumber. 1208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the DOM was parsed successfully. 1218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool decodeDOM(const SkDOM&, const SkDOMNode*); 1238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 124fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com /** Read in XML from a URI. Returns true if the file can be 1258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com read without error. Returns false if an error was encountered. 1268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Error diagnostics are stored in fErrorCode and fLineNumber. 1278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param uri The complete url path to be read (either ftp, http or https). 1288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the XML was parsed successfully. 1298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool decodeURI(const char uri[]); 1318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Pass a char event, usually a keyboard symbol, to the animator. 1338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com This triggers events of the form <event kind="keyChar" key="... /> 134fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param ch The character to match against <event> element "key" 1358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com attributes. 1368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the event was dispatched successfully. 1378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool doCharEvent(SkUnichar ch); 1398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Experimental: 141fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com Pass a mouse click event along with the mouse coordinates to 1428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the animator. This triggers events of the form <event kind="mouseDown" ... /> 1438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com and other mouse events. 1448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param state The mouse state, described by SkView::Click::State : values are 1458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com down == 0, moved == 1, up == 2 1468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x The x-position of the mouse 1478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y The y-position of the mouse 1488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the event was dispatched successfully. 1498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool doClickEvent(int state, SkScalar x, SkScalar y); 1518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Pass a meta-key event, such as an arrow , to the animator. 1538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com This triggers events of the form <event kind="keyPress" code="... /> 154fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param code The key to match against <event> element "code" 1558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com attributes. 1568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the event was dispatched successfully. 1578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool doKeyEvent(SkKey code); 1598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool doKeyUpEvent(SkKey code); 160fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 161fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com /** Send an event to the animator. The animator's clock is set 1628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com relative to the current time. 1638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the event was dispatched successfully. 1648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool doUserEvent(const SkEvent& evt); 1668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 167fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com /** The possible results from the draw function. 1688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum DifferenceType { 1708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kNotDifferent, 1718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kDifferent, 1728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kPartiallyDifferent 1738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 174fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com /** Draws one frame of the animation. The first call to draw always 175fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com draws the initial frame of the animation. Subsequent calls draw 176fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com the offset into the animation by 1778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com subtracting the initial time from the current time. 1788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param canvas The canvas to draw into. 1798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint to draw with. 1808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param time The offset into the current animation. 1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return kNotDifferent if there are no active animations; kDifferent if there are active animations; and 182fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com kPartiallyDifferent if the document contains an active <bounds> element that specifies a minimal 1838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com redraw area. 1848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com DifferenceType draw(SkCanvas* canvas, SkPaint* paint, SkMSec time); 1868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draws one frame of the animation, using a new Paint each time. 188fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com The first call to draw always 189fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com draws the initial frame of the animation. Subsequent calls draw 190fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com the offset into the animation by 1918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com subtracting the initial time from the current time. 1928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param canvas The canvas to draw into. 1938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param time The offset into the current animation. 1948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return kNotDifferent if there are no active animations; kDifferent if there are active animations; and 195fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com kPartiallyDifferent if the document contains an active <bounds> element that specifies a minimal 1968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com redraw area. 1978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com DifferenceType draw(SkCanvas* canvas, SkMSec time); 1998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Experimental: 2018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Helper to choose whether to return a SkView::Click handler. 2028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x ignored 2038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y ignored 2048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if a mouseDown event handler is enabled. 2058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 206fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com bool findClickEvent(SkScalar x, SkScalar y); 2078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Get the nested animator associated with this element, if any. 2108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Use this to access a movie's event sink, to send events to movies. 2118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param element the value returned by getElement 2128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the internal animator. 2138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkAnimator* getAnimator(const SkDisplayable* element) const; 2158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the scalar value of the specified element's attribute[index] 2178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param element the value returned by getElement 2188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param field the value returned by getField 2198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param index the array entry 2208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the integer value to retrieve, or SK_NaN32 if unsuccessful 2218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int32_t getArrayInt(const SkDisplayable* element, const SkMemberInfo* field, int index); 2238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the scalar value of the specified element's attribute[index] 2258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param elementID is the value of the id attribute in the XML of this element 226fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param fieldName specifies the name of the attribute 2278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param index the array entry 2288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the integer value to retrieve, or SK_NaN32 if unsuccessful 2298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int32_t getArrayInt(const char* elementID, const char* fieldName, int index); 2318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the scalar value of the specified element's attribute[index] 2338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param element the value returned by getElement 2348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param field the value returned by getField 2358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param index the array entry 2368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the scalar value to retrieve, or SK_ScalarNaN if unsuccessful 2378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar getArrayScalar(const SkDisplayable* element, const SkMemberInfo* field, int index); 2398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the scalar value of the specified element's attribute[index] 2418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param elementID is the value of the id attribute in the XML of this element 242fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param fieldName specifies the name of the attribute 2438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param index the array entry 2448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the scalar value to retrieve, or SK_ScalarNaN if unsuccessful 2458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar getArrayScalar(const char* elementID, const char* fieldName, int index); 2478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the string value of the specified element's attribute[index] 2498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param element is a value returned by getElement 250fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param field is a value returned by getField 2518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param index the array entry 2528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the string value to retrieve, or null if unsuccessful 2538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const char* getArrayString(const SkDisplayable* element, const SkMemberInfo* field, int index); 2558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the string value of the specified element's attribute[index] 2578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param elementID is the value of the id attribute in the XML of this element 258fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param fieldName specifies the name of the attribute 2598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param index the array entry 2608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the string value to retrieve, or null if unsuccessful 2618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const char* getArrayString(const char* elementID, const char* fieldName, int index); 2638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the XML element corresponding to the given ID. 265fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param elementID is the value of the id attribute in the XML of this element 2668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the element matching the ID, or null if the element can't be found 2678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkDisplayable* getElement(const char* elementID); 2698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the element type corresponding to the XML element. 2718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com The element type matches the element name; for instance, <line> returns kElement_LineType 272fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param element is a value returned by getElement 2738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return element type, or 0 if the element can't be found 2748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkElementType getElementType(const SkDisplayable* element); 2768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the element type corresponding to the given ID. 278fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param elementID is the value of the id attribute in the XML of this element 2798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return element type, or 0 if the element can't be found 2808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkElementType getElementType(const char* elementID); 2828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the XML field of the named attribute in the XML element. 2848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param element is a value returned by getElement 285fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param fieldName is the attribute to return 2868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the attribute matching the fieldName, or null if the element can't be found 2878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkMemberInfo* getField(const SkDisplayable* element, const char* fieldName); 2898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the XML field of the named attribute in the XML element matching the elementID. 2918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param elementID is the value of the id attribute in the XML of this element 292fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param fieldName is the attribute to return 2938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the attribute matching the fieldName, or null if the element can't be found 2948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkMemberInfo* getField(const char* elementID, const char* fieldName); 2968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the value type coresponding to the element's attribute. 2988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com The value type matches the XML schema: and may be kField_BooleanType, kField_ScalarType, etc. 299fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param field is a value returned by getField 3008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the attribute type, or 0 if the element can't be found 3018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkFieldType getFieldType(const SkMemberInfo* field); 3038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the value type coresponding to the element's attribute. 3058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param elementID is the value of the id attribute in the XML of this element 306fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param fieldName specifies the name of the attribute 3078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the attribute type, or 0 if the element can't be found 3088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkFieldType getFieldType(const char* elementID, const char* fieldName); 3108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the recommended animation interval. Returns zero if no 3128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com interval is specified. 3138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkMSec getInterval(); 3158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the partial rectangle to invalidate after drawing. Call after draw() returns 3178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kIsPartiallyDifferent to do a mimimal inval(). */ 318fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com void getInvalBounds(SkRect* inval); 3198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 320fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com /** Returns the details of any error encountered while parsing the XML. 3218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkXMLParserError* getParserError(); 323fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 324fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com /** Returns the details of any error encountered while parsing the XML as string. 3258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const char* getParserErrorString(); 327fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 3288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the scalar value of the specified element's attribute 3298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param element is a value returned by getElement 330fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param field is a value returned by getField 3318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the integer value to retrieve, or SK_NaN32 if not found 3328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int32_t getInt(const SkDisplayable* element, const SkMemberInfo* field); 3348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the scalar value of the specified element's attribute 3368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param elementID is the value of the id attribute in the XML of this element 337fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param fieldName specifies the name of the attribute 3388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the integer value to retrieve, or SK_NaN32 if not found 3398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int32_t getInt(const char* elementID, const char* fieldName); 3418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the scalar value of the specified element's attribute 3438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param element is a value returned by getElement 344fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param field is a value returned by getField 3458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the scalar value to retrieve, or SK_ScalarNaN if not found 3468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar getScalar(const SkDisplayable* element, const SkMemberInfo* field); 3488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the scalar value of the specified element's attribute 3508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param elementID is the value of the id attribute in the XML of this element 351fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param fieldName specifies the name of the attribute 3528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the scalar value to retrieve, or SK_ScalarNaN if not found 3538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar getScalar(const char* elementID, const char* fieldName); 3558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the string value of the specified element's attribute 3578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param element is a value returned by getElement 358fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param field is a value returned by getField 3598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the string value to retrieve, or null if not found 3608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const char* getString(const SkDisplayable* element, const SkMemberInfo* field); 3628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the string value of the specified element's attribute 3648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param elementID is the value of the id attribute in the XML of this element 365fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param fieldName specifies the name of the attribute 3668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the string value to retrieve, or null if not found 3678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const char* getString(const char* elementID, const char* fieldName); 3698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Gets the file default directory of the URL base path set explicitly or by reading the last URL. */ 3718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const char* getURIBase(); 3728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Resets the animator to a newly created state with no animation data. */ 3748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void initialize(); 3758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 376fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com /** Experimental. Resets any active animations so that the next time passed is treated as 3778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com time zero. */ 3788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void reset(); 379fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 3808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Sets the scalar value of the specified element's attribute 3818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param elementID is the value of the id attribute in the XML of this element 382fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param fieldName specifies the name of the attribute 3838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param array is the c-style array of integers 3848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param count is the length of the array 3858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the value was set successfully 3868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool setArrayInt(const char* elementID, const char* fieldName, const int* array, int count); 388fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 3898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Sets the scalar value of the specified element's attribute 3908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param elementID is the value of the id attribute in the XML of this element 391fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param fieldName specifies the name of the attribute 3928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param array is the c-style array of strings 3938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param count is the length of the array 3948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the value was set successfully 3958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool setArrayString(const char* elementID, const char* fieldName, const char** array, int count); 397fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 3988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Sets the scalar value of the specified element's attribute 3998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param elementID is the value of the id attribute in the XML of this element 400fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param fieldName specifies the name of the attribute 4018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param data the integer value to set 4028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the value was set successfully 4038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool setInt(const char* elementID, const char* fieldName, int32_t data); 4058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Sets the scalar value of the specified element's attribute 4078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param elementID is the value of the id attribute in the XML of this element 408fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param fieldName specifies the name of the attribute 4098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param data the scalar value to set 4108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the value was set successfully 4118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool setScalar(const char* elementID, const char* fieldName, SkScalar data); 4138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Sets the string value of the specified element's attribute 4158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param elementID is the value of the id attribute in the XML of this element 416fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param fieldName specifies the name of the attribute 4178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param data the string value to set 4188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the value was set successfully 4198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool setString(const char* elementID, const char* fieldName, const char* data); 4218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 422fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com /** Sets the file default directory of the URL base path 423fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com @param path the directory path 4248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setURIBase(const char* path); 4268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com typedef void* Handler; 4288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // This guy needs to be exported to java, so don't make it virtual 4298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setHostHandler(Handler handler) { 4308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->onSetHostHandler(handler); 4318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 4328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** \class Timeline 4348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Returns current time to animator. To return a custom timeline, create a child 4358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com class and override the getMSecs method. 4368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com class Timeline { 4388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com public: 4398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual ~Timeline() {} 4408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the current time in milliseconds */ 4428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual SkMSec getMSecs() const = 0; 4438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 4448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 445fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com /** Sets a user class to return the current time to the animator. 4468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Optional; if not called, the system clock will be used by calling SkTime::GetMSecs instead. 4478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param callBack the time function 4488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setTimeline(const Timeline& ); 4508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static void Init(bool runUnitTests); 4528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static void Term(); 453fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 454fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com /** The event sink events generated by the animation are posted to. 4558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Screenplay also posts an inval event to this event sink after processing an 4568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com event to force a redraw. 4578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param target the event sink id 4588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setHostEventSinkID(SkEventSinkID hostID); 4608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkEventSinkID getHostEventSinkID() const; 461fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 4628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // helper 4638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setHostEventSink(SkEventSink* sink) { 4648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->setHostEventSinkID(sink ? sink->getSinkID() : 0); 4658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 466fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 4678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void setJavaOwner(Handler owner); 468fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 4698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifdef SK_DEBUG 4708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void eventDone(const SkEvent& evt); 4718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool isTrackingEvents(); 4728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static bool NoLeaks(); 473fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#endif 474fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 4758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprotected: 4768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void onSetHostHandler(Handler handler); 4778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void onEventPost(SkEvent*, SkEventSinkID); 4788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void onEventPostTime(SkEvent*, SkEventSinkID, SkMSec time); 4798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 4818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// helper functions for setters 4828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool setArray(SkDisplayable* element, const SkMemberInfo* field, SkTypedArray array); 4838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool setArray(const char* elementID, const char* fieldName, SkTypedArray array); 4848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool setInt(SkDisplayable* element, const SkMemberInfo* field, int32_t data); 4858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool setScalar(SkDisplayable* element, const SkMemberInfo* field, SkScalar data); 4868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool setString(SkDisplayable* element, const SkMemberInfo* field, const char* data); 487fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 4888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool onEvent(const SkEvent&); 4898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkAnimateMaker* fMaker; 4908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend class SkAnimateMaker; 4918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend class SkAnimatorScript; 4928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend class SkAnimatorScript2; 4938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend class SkApply; 4948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend class SkDisplayMovie; 4958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend class SkDisplayType; 4968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend class SkPost; 4978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend class SkXMLAnimatorWriter; 4988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 4998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 501