• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright 2006 The Android Open Source Project
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 
9 
10 #ifndef SkImageView_DEFINED
11 #define SkImageView_DEFINED
12 
13 #include "SkView.h"
14 #include "SkString.h"
15 
16 class SkAnimator;
17 class SkBitmap;
18 class SkMatrix;
19 
20 class SkImageView : public SkView {
21 public:
22             SkImageView();
23     virtual ~SkImageView();
24 
25     void    getUri(SkString*) const;
26     void    setUri(const char []);
27     void    setUri(const SkString&);
28 
29 
30     enum ScaleType {
31         kMatrix_ScaleType,
32         kFitXY_ScaleType,
33         kFitStart_ScaleType,
34         kFitCenter_ScaleType,
35         kFitEnd_ScaleType
36     };
getScaleType()37     ScaleType   getScaleType() const { return (ScaleType)fScaleType; }
38     void        setScaleType(ScaleType);
39 
40     bool    getImageMatrix(SkMatrix*) const;
41     void    setImageMatrix(const SkMatrix*);
42 
43 protected:
44     // overrides
45     virtual bool    onEvent(const SkEvent&);
46     virtual void    onDraw(SkCanvas*);
47     virtual void    onInflate(const SkDOM&, const SkDOMNode*);
48 
49 private:
50     SkString    fUri;
51     SkMatrix*   fMatrix;    // null or copy of caller's matrix ,,,,,
52     union {
53         SkAnimator* fAnim;
54         SkBitmap* fBitmap;
55     } fData;
56     uint8_t     fScaleType;
57     SkBool8     fDataIsAnim;    // as opposed to bitmap
58     SkBool8     fUriIsValid;
59 
60     void    onUriChange();
61     bool    getDataBounds(SkRect* bounds);
62     bool    freeData();
63     bool    ensureUriIsLoaded();
64 
65     typedef SkView INHERITED;
66 };
67 
68 #endif
69