1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/* 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project 4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.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. 7ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com */ 8ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkDrawTo.h" 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkAnimateMaker.h" 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkCanvas.h" 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkDrawBitmap.h" 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if SK_USE_CONDENSED_INFO == 0 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comconst SkMemberInfo SkDrawTo::fInfo[] = { 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SK_MEMBER(drawOnce, Boolean), 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SK_MEMBER(use, Bitmap) 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comDEFINE_GET_MEMBER(SkDrawTo); 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comSkDrawTo::SkDrawTo() : drawOnce(false), use(NULL), fDrawnOnce(false) { 278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if 0 308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comSkDrawTo::~SkDrawTo() { 318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkASSERT(0); 328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.combool SkDrawTo::draw(SkAnimateMaker& maker) { 368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (fDrawnOnce) 378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return false; 388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkCanvas canvas(use->fBitmap); 398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkCanvas* save = maker.fCanvas; 408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com maker.fCanvas = &canvas; 418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com INHERITED::draw(maker); 428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com maker.fCanvas = save; 438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com fDrawnOnce = drawOnce; 448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return false; 458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifdef SK_DUMP_ENABLED 488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDrawTo::dump(SkAnimateMaker* maker) { 498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com dumpBase(maker); 508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com dumpAttrs(maker); 518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (use) 528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDebugf("use=\"%s\" ", use->id); 538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com dumpDrawables(maker); 548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 56