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 SkPerspIter_DEFINED 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkPerspIter_DEFINED 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkMatrix.h" 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkPerspIter { 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Iterate a line through the matrix [x,y] ... [x+count-1, y]. 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param m The matrix we will be iterating a line through 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x The initial X coordinate to be mapped through the matrix 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y The initial Y coordinate to be mapped through the matrix 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param count The number of points (x,y) (x+1,y) (x+2,y) ... we will eventually map 228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkPerspIter(const SkMatrix& m, SkScalar x, SkScalar y, int count); 24fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the buffer of [x,y] fixed point values we will be filling. 268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com This always returns the same value, so it can be saved across calls to 278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com next(). 288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkFixed* getXY() const { return fStorage; } 308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the number of [x,y] pairs that have been filled in the getXY() buffer. 328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com When this returns 0, the iterator is finished. 338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int next(); 35fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum { 388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kShift = 4, 398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kCount = (1 << kShift) 408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkMatrix& fMatrix; 428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkFixed fStorage[kCount * 2]; 438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkFixed fX, fY; 448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar fSX, fSY; 458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int fCount; 468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 49