Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | |
michael@0 | 2 | /* |
michael@0 | 3 | * Copyright 2006 The Android Open Source Project |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | #ifndef SkAnimator_DEFINED |
michael@0 | 11 | #define SkAnimator_DEFINED |
michael@0 | 12 | |
michael@0 | 13 | #include "SkScalar.h" |
michael@0 | 14 | #include "SkKey.h" |
michael@0 | 15 | #include "SkEventSink.h" |
michael@0 | 16 | |
michael@0 | 17 | class SkAnimateMaker; |
michael@0 | 18 | class SkCanvas; |
michael@0 | 19 | class SkDisplayable; |
michael@0 | 20 | class SkEvent; |
michael@0 | 21 | class SkExtras; |
michael@0 | 22 | struct SkMemberInfo; |
michael@0 | 23 | class SkPaint; |
michael@0 | 24 | struct SkRect; |
michael@0 | 25 | class SkStream; |
michael@0 | 26 | class SkTypedArray; |
michael@0 | 27 | class SkXMLParserError; |
michael@0 | 28 | class SkDOM; |
michael@0 | 29 | struct SkDOMNode; |
michael@0 | 30 | |
michael@0 | 31 | /** SkElementType is the type of element: a rectangle, a color, an animator, and so on. |
michael@0 | 32 | This enum is incomplete and will be fleshed out in a future release */ |
michael@0 | 33 | enum SkElementType { |
michael@0 | 34 | kElementDummyType |
michael@0 | 35 | }; |
michael@0 | 36 | /** SkFieldType is the type of field: a scalar, a string, an integer, a boolean, and so on. |
michael@0 | 37 | This enum is incomplete and will be fleshed out in a future release */ |
michael@0 | 38 | enum SkFieldType { |
michael@0 | 39 | kFieldDummyType |
michael@0 | 40 | }; |
michael@0 | 41 | |
michael@0 | 42 | /** \class SkAnimator |
michael@0 | 43 | |
michael@0 | 44 | The SkAnimator class decodes an XML stream into a display list. The |
michael@0 | 45 | display list can be drawn statically as a picture, or can drawn |
michael@0 | 46 | different elements at different times to form a moving animation. |
michael@0 | 47 | |
michael@0 | 48 | SkAnimator does not read the system time on its own; it relies on the |
michael@0 | 49 | caller to pass the current time. The caller can pause, speed up, or |
michael@0 | 50 | reverse the animation by varying the time passed in. |
michael@0 | 51 | |
michael@0 | 52 | The XML describing the display list must conform to the schema |
michael@0 | 53 | described by SkAnimateSchema.xsd. |
michael@0 | 54 | |
michael@0 | 55 | The XML must contain an <event> element to draw. Usually, it contains |
michael@0 | 56 | an <event kind="onload" /> block to add some drawing elements to the |
michael@0 | 57 | display list when the document is first decoded. |
michael@0 | 58 | |
michael@0 | 59 | Here's an "Hello World" XML sample: |
michael@0 | 60 | |
michael@0 | 61 | <screenplay> |
michael@0 | 62 | <event kind="onload" > |
michael@0 | 63 | <text text="Hello World" y="20" /> |
michael@0 | 64 | </event> |
michael@0 | 65 | </screenplay> |
michael@0 | 66 | |
michael@0 | 67 | To read and draw this sample: |
michael@0 | 68 | |
michael@0 | 69 | // choose one of these two |
michael@0 | 70 | SkAnimator animator; // declare an animator instance on the stack |
michael@0 | 71 | // SkAnimator* animator = new SkAnimator() // or one could instantiate the class |
michael@0 | 72 | |
michael@0 | 73 | // choose one of these three |
michael@0 | 74 | animator.decodeMemory(buffer, size); // to read from RAM |
michael@0 | 75 | animator.decodeStream(stream); // to read from a user-defined stream (e.g., a zip file) |
michael@0 | 76 | animator.decodeURI(filename); // to read from a web location, or from a local text file |
michael@0 | 77 | |
michael@0 | 78 | // to draw to the current window: |
michael@0 | 79 | SkCanvas canvas(getBitmap()); // create a canvas |
michael@0 | 80 | animator.draw(canvas, &paint, 0); // draw the scene |
michael@0 | 81 | */ |
michael@0 | 82 | class SkAnimator : public SkEventSink { |
michael@0 | 83 | public: |
michael@0 | 84 | SkAnimator(); |
michael@0 | 85 | virtual ~SkAnimator(); |
michael@0 | 86 | |
michael@0 | 87 | /** Add a drawable extension to the graphics engine. Experimental. |
michael@0 | 88 | @param extras A derived class that implements methods that identify and instantiate the class |
michael@0 | 89 | */ |
michael@0 | 90 | void addExtras(SkExtras* extras); |
michael@0 | 91 | |
michael@0 | 92 | /** Read in XML from a stream, and append it to the current |
michael@0 | 93 | animator. Returns false if an error was encountered. |
michael@0 | 94 | Error diagnostics are stored in fErrorCode and fLineNumber. |
michael@0 | 95 | @param stream The stream to append. |
michael@0 | 96 | @return true if the XML was parsed successfully. |
michael@0 | 97 | */ |
michael@0 | 98 | bool appendStream(SkStream* stream); |
michael@0 | 99 | |
michael@0 | 100 | /** Read in XML from memory. Returns true if the file can be |
michael@0 | 101 | read without error. Returns false if an error was encountered. |
michael@0 | 102 | Error diagnostics are stored in fErrorCode and fLineNumber. |
michael@0 | 103 | @param buffer The XML text as UTF-8 characters. |
michael@0 | 104 | @param size The XML text length in bytes. |
michael@0 | 105 | @return true if the XML was parsed successfully. |
michael@0 | 106 | */ |
michael@0 | 107 | bool decodeMemory(const void* buffer, size_t size); |
michael@0 | 108 | |
michael@0 | 109 | /** Read in XML from a stream. Returns true if the file can be |
michael@0 | 110 | read without error. Returns false if an error was encountered. |
michael@0 | 111 | Error diagnostics are stored in fErrorCode and fLineNumber. |
michael@0 | 112 | @param stream The stream containg the XML text as UTF-8 characters. |
michael@0 | 113 | @return true if the XML was parsed successfully. |
michael@0 | 114 | */ |
michael@0 | 115 | virtual bool decodeStream(SkStream* stream); |
michael@0 | 116 | |
michael@0 | 117 | /** Parse the DOM tree starting at the specified node. Returns true if it can be |
michael@0 | 118 | parsed without error. Returns false if an error was encountered. |
michael@0 | 119 | Error diagnostics are stored in fErrorCode and fLineNumber. |
michael@0 | 120 | @return true if the DOM was parsed successfully. |
michael@0 | 121 | */ |
michael@0 | 122 | virtual bool decodeDOM(const SkDOM&, const SkDOMNode*); |
michael@0 | 123 | |
michael@0 | 124 | /** Read in XML from a URI. Returns true if the file can be |
michael@0 | 125 | read without error. Returns false if an error was encountered. |
michael@0 | 126 | Error diagnostics are stored in fErrorCode and fLineNumber. |
michael@0 | 127 | @param uri The complete url path to be read (either ftp, http or https). |
michael@0 | 128 | @return true if the XML was parsed successfully. |
michael@0 | 129 | */ |
michael@0 | 130 | bool decodeURI(const char uri[]); |
michael@0 | 131 | |
michael@0 | 132 | /** Pass a char event, usually a keyboard symbol, to the animator. |
michael@0 | 133 | This triggers events of the form <event kind="keyChar" key="... /> |
michael@0 | 134 | @param ch The character to match against <event> element "key" |
michael@0 | 135 | attributes. |
michael@0 | 136 | @return true if the event was dispatched successfully. |
michael@0 | 137 | */ |
michael@0 | 138 | bool doCharEvent(SkUnichar ch); |
michael@0 | 139 | |
michael@0 | 140 | /** Experimental: |
michael@0 | 141 | Pass a mouse click event along with the mouse coordinates to |
michael@0 | 142 | the animator. This triggers events of the form <event kind="mouseDown" ... /> |
michael@0 | 143 | and other mouse events. |
michael@0 | 144 | @param state The mouse state, described by SkView::Click::State : values are |
michael@0 | 145 | down == 0, moved == 1, up == 2 |
michael@0 | 146 | @param x The x-position of the mouse |
michael@0 | 147 | @param y The y-position of the mouse |
michael@0 | 148 | @return true if the event was dispatched successfully. |
michael@0 | 149 | */ |
michael@0 | 150 | bool doClickEvent(int state, SkScalar x, SkScalar y); |
michael@0 | 151 | |
michael@0 | 152 | /** Pass a meta-key event, such as an arrow , to the animator. |
michael@0 | 153 | This triggers events of the form <event kind="keyPress" code="... /> |
michael@0 | 154 | @param code The key to match against <event> element "code" |
michael@0 | 155 | attributes. |
michael@0 | 156 | @return true if the event was dispatched successfully. |
michael@0 | 157 | */ |
michael@0 | 158 | bool doKeyEvent(SkKey code); |
michael@0 | 159 | bool doKeyUpEvent(SkKey code); |
michael@0 | 160 | |
michael@0 | 161 | /** Send an event to the animator. The animator's clock is set |
michael@0 | 162 | relative to the current time. |
michael@0 | 163 | @return true if the event was dispatched successfully. |
michael@0 | 164 | */ |
michael@0 | 165 | bool doUserEvent(const SkEvent& evt); |
michael@0 | 166 | |
michael@0 | 167 | /** The possible results from the draw function. |
michael@0 | 168 | */ |
michael@0 | 169 | enum DifferenceType { |
michael@0 | 170 | kNotDifferent, |
michael@0 | 171 | kDifferent, |
michael@0 | 172 | kPartiallyDifferent |
michael@0 | 173 | }; |
michael@0 | 174 | /** Draws one frame of the animation. The first call to draw always |
michael@0 | 175 | draws the initial frame of the animation. Subsequent calls draw |
michael@0 | 176 | the offset into the animation by |
michael@0 | 177 | subtracting the initial time from the current time. |
michael@0 | 178 | @param canvas The canvas to draw into. |
michael@0 | 179 | @param paint The paint to draw with. |
michael@0 | 180 | @param time The offset into the current animation. |
michael@0 | 181 | @return kNotDifferent if there are no active animations; kDifferent if there are active animations; and |
michael@0 | 182 | kPartiallyDifferent if the document contains an active <bounds> element that specifies a minimal |
michael@0 | 183 | redraw area. |
michael@0 | 184 | */ |
michael@0 | 185 | DifferenceType draw(SkCanvas* canvas, SkPaint* paint, SkMSec time); |
michael@0 | 186 | |
michael@0 | 187 | /** Draws one frame of the animation, using a new Paint each time. |
michael@0 | 188 | The first call to draw always |
michael@0 | 189 | draws the initial frame of the animation. Subsequent calls draw |
michael@0 | 190 | the offset into the animation by |
michael@0 | 191 | subtracting the initial time from the current time. |
michael@0 | 192 | @param canvas The canvas to draw into. |
michael@0 | 193 | @param time The offset into the current animation. |
michael@0 | 194 | @return kNotDifferent if there are no active animations; kDifferent if there are active animations; and |
michael@0 | 195 | kPartiallyDifferent if the document contains an active <bounds> element that specifies a minimal |
michael@0 | 196 | redraw area. |
michael@0 | 197 | */ |
michael@0 | 198 | DifferenceType draw(SkCanvas* canvas, SkMSec time); |
michael@0 | 199 | |
michael@0 | 200 | /** Experimental: |
michael@0 | 201 | Helper to choose whether to return a SkView::Click handler. |
michael@0 | 202 | @param x ignored |
michael@0 | 203 | @param y ignored |
michael@0 | 204 | @return true if a mouseDown event handler is enabled. |
michael@0 | 205 | */ |
michael@0 | 206 | bool findClickEvent(SkScalar x, SkScalar y); |
michael@0 | 207 | |
michael@0 | 208 | |
michael@0 | 209 | /** Get the nested animator associated with this element, if any. |
michael@0 | 210 | Use this to access a movie's event sink, to send events to movies. |
michael@0 | 211 | @param element the value returned by getElement |
michael@0 | 212 | @return the internal animator. |
michael@0 | 213 | */ |
michael@0 | 214 | const SkAnimator* getAnimator(const SkDisplayable* element) const; |
michael@0 | 215 | |
michael@0 | 216 | /** Returns the scalar value of the specified element's attribute[index] |
michael@0 | 217 | @param element the value returned by getElement |
michael@0 | 218 | @param field the value returned by getField |
michael@0 | 219 | @param index the array entry |
michael@0 | 220 | @return the integer value to retrieve, or SK_NaN32 if unsuccessful |
michael@0 | 221 | */ |
michael@0 | 222 | int32_t getArrayInt(const SkDisplayable* element, const SkMemberInfo* field, int index); |
michael@0 | 223 | |
michael@0 | 224 | /** Returns the scalar value of the specified element's attribute[index] |
michael@0 | 225 | @param elementID is the value of the id attribute in the XML of this element |
michael@0 | 226 | @param fieldName specifies the name of the attribute |
michael@0 | 227 | @param index the array entry |
michael@0 | 228 | @return the integer value to retrieve, or SK_NaN32 if unsuccessful |
michael@0 | 229 | */ |
michael@0 | 230 | int32_t getArrayInt(const char* elementID, const char* fieldName, int index); |
michael@0 | 231 | |
michael@0 | 232 | /** Returns the scalar value of the specified element's attribute[index] |
michael@0 | 233 | @param element the value returned by getElement |
michael@0 | 234 | @param field the value returned by getField |
michael@0 | 235 | @param index the array entry |
michael@0 | 236 | @return the scalar value to retrieve, or SK_ScalarNaN if unsuccessful |
michael@0 | 237 | */ |
michael@0 | 238 | SkScalar getArrayScalar(const SkDisplayable* element, const SkMemberInfo* field, int index); |
michael@0 | 239 | |
michael@0 | 240 | /** Returns the scalar value of the specified element's attribute[index] |
michael@0 | 241 | @param elementID is the value of the id attribute in the XML of this element |
michael@0 | 242 | @param fieldName specifies the name of the attribute |
michael@0 | 243 | @param index the array entry |
michael@0 | 244 | @return the scalar value to retrieve, or SK_ScalarNaN if unsuccessful |
michael@0 | 245 | */ |
michael@0 | 246 | SkScalar getArrayScalar(const char* elementID, const char* fieldName, int index); |
michael@0 | 247 | |
michael@0 | 248 | /** Returns the string value of the specified element's attribute[index] |
michael@0 | 249 | @param element is a value returned by getElement |
michael@0 | 250 | @param field is a value returned by getField |
michael@0 | 251 | @param index the array entry |
michael@0 | 252 | @return the string value to retrieve, or null if unsuccessful |
michael@0 | 253 | */ |
michael@0 | 254 | const char* getArrayString(const SkDisplayable* element, const SkMemberInfo* field, int index); |
michael@0 | 255 | |
michael@0 | 256 | /** Returns the string value of the specified element's attribute[index] |
michael@0 | 257 | @param elementID is the value of the id attribute in the XML of this element |
michael@0 | 258 | @param fieldName specifies the name of the attribute |
michael@0 | 259 | @param index the array entry |
michael@0 | 260 | @return the string value to retrieve, or null if unsuccessful |
michael@0 | 261 | */ |
michael@0 | 262 | const char* getArrayString(const char* elementID, const char* fieldName, int index); |
michael@0 | 263 | |
michael@0 | 264 | /** Returns the XML element corresponding to the given ID. |
michael@0 | 265 | @param elementID is the value of the id attribute in the XML of this element |
michael@0 | 266 | @return the element matching the ID, or null if the element can't be found |
michael@0 | 267 | */ |
michael@0 | 268 | const SkDisplayable* getElement(const char* elementID); |
michael@0 | 269 | |
michael@0 | 270 | /** Returns the element type corresponding to the XML element. |
michael@0 | 271 | The element type matches the element name; for instance, <line> returns kElement_LineType |
michael@0 | 272 | @param element is a value returned by getElement |
michael@0 | 273 | @return element type, or 0 if the element can't be found |
michael@0 | 274 | */ |
michael@0 | 275 | SkElementType getElementType(const SkDisplayable* element); |
michael@0 | 276 | |
michael@0 | 277 | /** Returns the element type corresponding to the given ID. |
michael@0 | 278 | @param elementID is the value of the id attribute in the XML of this element |
michael@0 | 279 | @return element type, or 0 if the element can't be found |
michael@0 | 280 | */ |
michael@0 | 281 | SkElementType getElementType(const char* elementID); |
michael@0 | 282 | |
michael@0 | 283 | /** Returns the XML field of the named attribute in the XML element. |
michael@0 | 284 | @param element is a value returned by getElement |
michael@0 | 285 | @param fieldName is the attribute to return |
michael@0 | 286 | @return the attribute matching the fieldName, or null if the element can't be found |
michael@0 | 287 | */ |
michael@0 | 288 | const SkMemberInfo* getField(const SkDisplayable* element, const char* fieldName); |
michael@0 | 289 | |
michael@0 | 290 | /** Returns the XML field of the named attribute in the XML element matching the elementID. |
michael@0 | 291 | @param elementID is the value of the id attribute in the XML of this element |
michael@0 | 292 | @param fieldName is the attribute to return |
michael@0 | 293 | @return the attribute matching the fieldName, or null if the element can't be found |
michael@0 | 294 | */ |
michael@0 | 295 | const SkMemberInfo* getField(const char* elementID, const char* fieldName); |
michael@0 | 296 | |
michael@0 | 297 | /** Returns the value type coresponding to the element's attribute. |
michael@0 | 298 | The value type matches the XML schema: and may be kField_BooleanType, kField_ScalarType, etc. |
michael@0 | 299 | @param field is a value returned by getField |
michael@0 | 300 | @return the attribute type, or 0 if the element can't be found |
michael@0 | 301 | */ |
michael@0 | 302 | SkFieldType getFieldType(const SkMemberInfo* field); |
michael@0 | 303 | |
michael@0 | 304 | /** Returns the value type coresponding to the element's attribute. |
michael@0 | 305 | @param elementID is the value of the id attribute in the XML of this element |
michael@0 | 306 | @param fieldName specifies the name of the attribute |
michael@0 | 307 | @return the attribute type, or 0 if the element can't be found |
michael@0 | 308 | */ |
michael@0 | 309 | SkFieldType getFieldType(const char* elementID, const char* fieldName); |
michael@0 | 310 | |
michael@0 | 311 | /** Returns the recommended animation interval. Returns zero if no |
michael@0 | 312 | interval is specified. |
michael@0 | 313 | */ |
michael@0 | 314 | SkMSec getInterval(); |
michael@0 | 315 | |
michael@0 | 316 | /** Returns the partial rectangle to invalidate after drawing. Call after draw() returns |
michael@0 | 317 | kIsPartiallyDifferent to do a mimimal inval(). */ |
michael@0 | 318 | void getInvalBounds(SkRect* inval); |
michael@0 | 319 | |
michael@0 | 320 | /** Returns the details of any error encountered while parsing the XML. |
michael@0 | 321 | */ |
michael@0 | 322 | const SkXMLParserError* getParserError(); |
michael@0 | 323 | |
michael@0 | 324 | /** Returns the details of any error encountered while parsing the XML as string. |
michael@0 | 325 | */ |
michael@0 | 326 | const char* getParserErrorString(); |
michael@0 | 327 | |
michael@0 | 328 | /** Returns the scalar value of the specified element's attribute |
michael@0 | 329 | @param element is a value returned by getElement |
michael@0 | 330 | @param field is a value returned by getField |
michael@0 | 331 | @return the integer value to retrieve, or SK_NaN32 if not found |
michael@0 | 332 | */ |
michael@0 | 333 | int32_t getInt(const SkDisplayable* element, const SkMemberInfo* field); |
michael@0 | 334 | |
michael@0 | 335 | /** Returns the scalar value of the specified element's attribute |
michael@0 | 336 | @param elementID is the value of the id attribute in the XML of this element |
michael@0 | 337 | @param fieldName specifies the name of the attribute |
michael@0 | 338 | @return the integer value to retrieve, or SK_NaN32 if not found |
michael@0 | 339 | */ |
michael@0 | 340 | int32_t getInt(const char* elementID, const char* fieldName); |
michael@0 | 341 | |
michael@0 | 342 | /** Returns the scalar value of the specified element's attribute |
michael@0 | 343 | @param element is a value returned by getElement |
michael@0 | 344 | @param field is a value returned by getField |
michael@0 | 345 | @return the scalar value to retrieve, or SK_ScalarNaN if not found |
michael@0 | 346 | */ |
michael@0 | 347 | SkScalar getScalar(const SkDisplayable* element, const SkMemberInfo* field); |
michael@0 | 348 | |
michael@0 | 349 | /** Returns the scalar value of the specified element's attribute |
michael@0 | 350 | @param elementID is the value of the id attribute in the XML of this element |
michael@0 | 351 | @param fieldName specifies the name of the attribute |
michael@0 | 352 | @return the scalar value to retrieve, or SK_ScalarNaN if not found |
michael@0 | 353 | */ |
michael@0 | 354 | SkScalar getScalar(const char* elementID, const char* fieldName); |
michael@0 | 355 | |
michael@0 | 356 | /** Returns the string value of the specified element's attribute |
michael@0 | 357 | @param element is a value returned by getElement |
michael@0 | 358 | @param field is a value returned by getField |
michael@0 | 359 | @return the string value to retrieve, or null if not found |
michael@0 | 360 | */ |
michael@0 | 361 | const char* getString(const SkDisplayable* element, const SkMemberInfo* field); |
michael@0 | 362 | |
michael@0 | 363 | /** Returns the string value of the specified element's attribute |
michael@0 | 364 | @param elementID is the value of the id attribute in the XML of this element |
michael@0 | 365 | @param fieldName specifies the name of the attribute |
michael@0 | 366 | @return the string value to retrieve, or null if not found |
michael@0 | 367 | */ |
michael@0 | 368 | const char* getString(const char* elementID, const char* fieldName); |
michael@0 | 369 | |
michael@0 | 370 | /** Gets the file default directory of the URL base path set explicitly or by reading the last URL. */ |
michael@0 | 371 | const char* getURIBase(); |
michael@0 | 372 | |
michael@0 | 373 | /** Resets the animator to a newly created state with no animation data. */ |
michael@0 | 374 | void initialize(); |
michael@0 | 375 | |
michael@0 | 376 | /** Experimental. Resets any active animations so that the next time passed is treated as |
michael@0 | 377 | time zero. */ |
michael@0 | 378 | void reset(); |
michael@0 | 379 | |
michael@0 | 380 | /** Sets the scalar value of the specified element's attribute |
michael@0 | 381 | @param elementID is the value of the id attribute in the XML of this element |
michael@0 | 382 | @param fieldName specifies the name of the attribute |
michael@0 | 383 | @param array is the c-style array of integers |
michael@0 | 384 | @param count is the length of the array |
michael@0 | 385 | @return true if the value was set successfully |
michael@0 | 386 | */ |
michael@0 | 387 | bool setArrayInt(const char* elementID, const char* fieldName, const int* array, int count); |
michael@0 | 388 | |
michael@0 | 389 | /** Sets the scalar value of the specified element's attribute |
michael@0 | 390 | @param elementID is the value of the id attribute in the XML of this element |
michael@0 | 391 | @param fieldName specifies the name of the attribute |
michael@0 | 392 | @param array is the c-style array of strings |
michael@0 | 393 | @param count is the length of the array |
michael@0 | 394 | @return true if the value was set successfully |
michael@0 | 395 | */ |
michael@0 | 396 | bool setArrayString(const char* elementID, const char* fieldName, const char** array, int count); |
michael@0 | 397 | |
michael@0 | 398 | /** Sets the scalar value of the specified element's attribute |
michael@0 | 399 | @param elementID is the value of the id attribute in the XML of this element |
michael@0 | 400 | @param fieldName specifies the name of the attribute |
michael@0 | 401 | @param data the integer value to set |
michael@0 | 402 | @return true if the value was set successfully |
michael@0 | 403 | */ |
michael@0 | 404 | bool setInt(const char* elementID, const char* fieldName, int32_t data); |
michael@0 | 405 | |
michael@0 | 406 | /** Sets the scalar value of the specified element's attribute |
michael@0 | 407 | @param elementID is the value of the id attribute in the XML of this element |
michael@0 | 408 | @param fieldName specifies the name of the attribute |
michael@0 | 409 | @param data the scalar value to set |
michael@0 | 410 | @return true if the value was set successfully |
michael@0 | 411 | */ |
michael@0 | 412 | bool setScalar(const char* elementID, const char* fieldName, SkScalar data); |
michael@0 | 413 | |
michael@0 | 414 | /** Sets the string value of the specified element's attribute |
michael@0 | 415 | @param elementID is the value of the id attribute in the XML of this element |
michael@0 | 416 | @param fieldName specifies the name of the attribute |
michael@0 | 417 | @param data the string value to set |
michael@0 | 418 | @return true if the value was set successfully |
michael@0 | 419 | */ |
michael@0 | 420 | bool setString(const char* elementID, const char* fieldName, const char* data); |
michael@0 | 421 | |
michael@0 | 422 | /** Sets the file default directory of the URL base path |
michael@0 | 423 | @param path the directory path |
michael@0 | 424 | */ |
michael@0 | 425 | void setURIBase(const char* path); |
michael@0 | 426 | |
michael@0 | 427 | typedef void* Handler; |
michael@0 | 428 | // This guy needs to be exported to java, so don't make it virtual |
michael@0 | 429 | void setHostHandler(Handler handler) { |
michael@0 | 430 | this->onSetHostHandler(handler); |
michael@0 | 431 | } |
michael@0 | 432 | |
michael@0 | 433 | /** \class Timeline |
michael@0 | 434 | Returns current time to animator. To return a custom timeline, create a child |
michael@0 | 435 | class and override the getMSecs method. |
michael@0 | 436 | */ |
michael@0 | 437 | class Timeline { |
michael@0 | 438 | public: |
michael@0 | 439 | virtual ~Timeline() {} |
michael@0 | 440 | |
michael@0 | 441 | /** Returns the current time in milliseconds */ |
michael@0 | 442 | virtual SkMSec getMSecs() const = 0; |
michael@0 | 443 | }; |
michael@0 | 444 | |
michael@0 | 445 | /** Sets a user class to return the current time to the animator. |
michael@0 | 446 | Optional; if not called, the system clock will be used by calling SkTime::GetMSecs instead. |
michael@0 | 447 | @param callBack the time function |
michael@0 | 448 | */ |
michael@0 | 449 | void setTimeline(const Timeline& ); |
michael@0 | 450 | |
michael@0 | 451 | static void Init(bool runUnitTests); |
michael@0 | 452 | static void Term(); |
michael@0 | 453 | |
michael@0 | 454 | /** The event sink events generated by the animation are posted to. |
michael@0 | 455 | Screenplay also posts an inval event to this event sink after processing an |
michael@0 | 456 | event to force a redraw. |
michael@0 | 457 | @param target the event sink id |
michael@0 | 458 | */ |
michael@0 | 459 | void setHostEventSinkID(SkEventSinkID hostID); |
michael@0 | 460 | SkEventSinkID getHostEventSinkID() const; |
michael@0 | 461 | |
michael@0 | 462 | // helper |
michael@0 | 463 | void setHostEventSink(SkEventSink* sink) { |
michael@0 | 464 | this->setHostEventSinkID(sink ? sink->getSinkID() : 0); |
michael@0 | 465 | } |
michael@0 | 466 | |
michael@0 | 467 | virtual void setJavaOwner(Handler owner); |
michael@0 | 468 | |
michael@0 | 469 | #ifdef SK_DEBUG |
michael@0 | 470 | virtual void eventDone(const SkEvent& evt); |
michael@0 | 471 | virtual bool isTrackingEvents(); |
michael@0 | 472 | static bool NoLeaks(); |
michael@0 | 473 | #endif |
michael@0 | 474 | |
michael@0 | 475 | protected: |
michael@0 | 476 | virtual void onSetHostHandler(Handler handler); |
michael@0 | 477 | virtual void onEventPost(SkEvent*, SkEventSinkID); |
michael@0 | 478 | virtual void onEventPostTime(SkEvent*, SkEventSinkID, SkMSec time); |
michael@0 | 479 | |
michael@0 | 480 | private: |
michael@0 | 481 | // helper functions for setters |
michael@0 | 482 | bool setArray(SkDisplayable* element, const SkMemberInfo* field, SkTypedArray array); |
michael@0 | 483 | bool setArray(const char* elementID, const char* fieldName, SkTypedArray array); |
michael@0 | 484 | bool setInt(SkDisplayable* element, const SkMemberInfo* field, int32_t data); |
michael@0 | 485 | bool setScalar(SkDisplayable* element, const SkMemberInfo* field, SkScalar data); |
michael@0 | 486 | bool setString(SkDisplayable* element, const SkMemberInfo* field, const char* data); |
michael@0 | 487 | |
michael@0 | 488 | virtual bool onEvent(const SkEvent&); |
michael@0 | 489 | SkAnimateMaker* fMaker; |
michael@0 | 490 | friend class SkAnimateMaker; |
michael@0 | 491 | friend class SkAnimatorScript; |
michael@0 | 492 | friend class SkAnimatorScript2; |
michael@0 | 493 | friend class SkApply; |
michael@0 | 494 | friend class SkDisplayMovie; |
michael@0 | 495 | friend class SkDisplayType; |
michael@0 | 496 | friend class SkPost; |
michael@0 | 497 | friend class SkXMLAnimatorWriter; |
michael@0 | 498 | }; |
michael@0 | 499 | |
michael@0 | 500 | #endif |