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 SkImageView_DEFINED
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkImageView_DEFINED
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkView.h"
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkString.h"
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkAnimator;
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkBitmap;
1848cf8ac1442e62edc6fcd4af37e869326186d25ereed@android.comclass SkMatrix;
198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkImageView : public SkView {
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            SkImageView();
238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual ~SkImageView();
248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    getUri(SkString*) const;
268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    setUri(const char []);
278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    setUri(const SkString&);
28fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum ScaleType {
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kMatrix_ScaleType,
328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kFitXY_ScaleType,
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kFitStart_ScaleType,
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kFitCenter_ScaleType,
358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kFitEnd_ScaleType
368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    ScaleType   getScaleType() const { return (ScaleType)fScaleType; }
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void        setScaleType(ScaleType);
39fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool    getImageMatrix(SkMatrix*) const;
418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    setImageMatrix(const SkMatrix*);
428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprotected:
448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    // overrides
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual bool    onEvent(const SkEvent&);
468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual void    onDraw(SkCanvas*);
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual void    onInflate(const SkDOM&, const SkDOMNode*);
48fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate:
508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkString    fUri;
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkMatrix*   fMatrix;    // null or copy of caller's matrix ,,,,,
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    union {
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkAnimator* fAnim;
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkBitmap* fBitmap;
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    } fData;
568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    uint8_t     fScaleType;
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkBool8     fDataIsAnim;    // as opposed to bitmap
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkBool8     fUriIsValid;
59fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    onUriChange();
618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool    getDataBounds(SkRect* bounds);
628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool    freeData();
638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool    ensureUriIsLoaded();
648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef SkView INHERITED;
668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
69