1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* 3c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Copyright 2011 Google Inc. 4b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be 6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * found in the LICENSE file. 7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "SkPictureFlat.h" 9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "SkChecksum.h" 11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "SkColorFilter.h" 12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "SkDrawLooper.h" 13b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru#include "SkMaskFilter.h" 1450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#include "SkRasterizer.h" 151b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert#include "SkShader.h" 16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "SkTypeface.h" 17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "SkXfermode.h" 18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/////////////////////////////////////////////////////////////////////////////// 20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 21b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruSkTypefacePlayback::SkTypefacePlayback() : fCount(0), fArray(nullptr) {} 22b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 23b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruSkTypefacePlayback::~SkTypefacePlayback() { 24b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru this->reset(nullptr); 25b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 26b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 27b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid SkTypefacePlayback::reset(const SkRefCntSet* rec) { 28b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru for (int i = 0; i < fCount; i++) { 29b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru SkASSERT(fArray[i]); 30b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru fArray[i]->unref(); 31b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 32c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru delete[] fArray; 33b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 3450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if (rec!= nullptr && rec->count() > 0) { 35b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho fCount = rec->count(); 368393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius fArray = new SkRefCnt* [fCount]; 37fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius rec->copyToArray(fArray); 38f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius for (int i = 0; i < fCount; i++) { 39f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius fArray[i]->ref(); 40c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 41c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } else { 42b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru fCount = 0; 43b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru fArray = nullptr; 44b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 45b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 46b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 47b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid SkTypefacePlayback::setCount(int count) { 48b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru this->reset(nullptr); 49b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 50b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru fCount = count; 51b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru fArray = new SkRefCnt* [count]; 52b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru sk_bzero(fArray, count * sizeof(SkRefCnt*)); 53b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 54b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 55b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruSkRefCnt* SkTypefacePlayback::set(int index, SkRefCnt* obj) { 5627f654740f2a26ad62a5c155af9199af9e69b889claireho SkASSERT((unsigned)index < (unsigned)fCount); 5727f654740f2a26ad62a5c155af9199af9e69b889claireho SkRefCnt_SafeAssign(fArray[index], obj); 5827f654740f2a26ad62a5c155af9199af9e69b889claireho return obj; 5927f654740f2a26ad62a5c155af9199af9e69b889claireho} 6027f654740f2a26ad62a5c155af9199af9e69b889claireho 6127f654740f2a26ad62a5c155af9199af9e69b889claireho/////////////////////////////////////////////////////////////////////////////// 6227f654740f2a26ad62a5c155af9199af9e69b889claireho 6327f654740f2a26ad62a5c155af9199af9e69b889clairehoSkFlatController::SkFlatController(uint32_t writeBufferFlags) 6427f654740f2a26ad62a5c155af9199af9e69b889claireho: fBitmapHeap(nullptr) 6527f654740f2a26ad62a5c155af9199af9e69b889claireho, fTypefaceSet(nullptr) 6627f654740f2a26ad62a5c155af9199af9e69b889claireho, fTypefacePlayback(nullptr) 6727f654740f2a26ad62a5c155af9199af9e69b889claireho, fFactorySet(nullptr) 6827f654740f2a26ad62a5c155af9199af9e69b889claireho, fWriteBufferFlags(writeBufferFlags) {} 6927f654740f2a26ad62a5c155af9199af9e69b889claireho 70b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste QueruSkFlatController::~SkFlatController() { 71b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru SkSafeUnref(fBitmapHeap); 7250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho SkSafeUnref(fTypefaceSet); 7350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho SkSafeUnref(fFactorySet); 7450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho} 7550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 7650294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehovoid SkFlatController::setBitmapHeap(SkBitmapHeap* heap) { 7750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho SkRefCnt_SafeAssign(fBitmapHeap, heap); 7850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho} 7950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 80b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehovoid SkFlatController::setTypefaceSet(SkRefCntSet *set) { 81b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho SkRefCnt_SafeAssign(fTypefaceSet, set); 82b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho} 83b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 84b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehovoid SkFlatController::setTypefacePlayback(SkTypefacePlayback* playback) { 85b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho fTypefacePlayback = playback; 86b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho} 87b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 88b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoSkNamedFactorySet* SkFlatController::setNamedFactorySet(SkNamedFactorySet* set) { 89b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho SkRefCnt_SafeAssign(fFactorySet, set); 90b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho return set; 91b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho} 92b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho