1685cfc0ee13d7c355ae2f4f3d225ad45e945763fepoger@google.com 2685cfc0ee13d7c355ae2f4f3d225ad45e945763fepoger@google.com/* 3685cfc0ee13d7c355ae2f4f3d225ad45e945763fepoger@google.com * Copyright 2006 The Android Open Source Project 4685cfc0ee13d7c355ae2f4f3d225ad45e945763fepoger@google.com * 5685cfc0ee13d7c355ae2f4f3d225ad45e945763fepoger@google.com * Use of this source code is governed by a BSD-style license that can be 6685cfc0ee13d7c355ae2f4f3d225ad45e945763fepoger@google.com * found in the LICENSE file. 7685cfc0ee13d7c355ae2f4f3d225ad45e945763fepoger@google.com */ 8685cfc0ee13d7c355ae2f4f3d225ad45e945763fepoger@google.com 9bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com#include "SkPathEffect.h" 10bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com#include "SkPath.h" 119ce78f26f529fd3e10a3eb4f044bc3f0037ead56djsollen@google.com#include "SkFlattenableBuffers.h" 12d49b87f7307690e47c5cb093ff9d7cce4f009e87reed@google.com 13d49b87f7307690e47c5cb093ff9d7cce4f009e87reed@google.com/////////////////////////////////////////////////////////////////////////////// 14bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com 15dd5bdc371595475625776483ad67d591c86bc9b2reed@google.comvoid SkPathEffect::computeFastBounds(SkRect* dst, const SkRect& src) const { 16389574dc0e731b8e008d575a4af69600cc0015d4reed@google.com *dst = src; 17389574dc0e731b8e008d575a4af69600cc0015d4reed@google.com} 18389574dc0e731b8e008d575a4af69600cc0015d4reed@google.com 19b4bea53c7ba4b801545c334603ff487c1b3f50daskia.committer@gmail.combool SkPathEffect::asPoints(PointData* results, const SkPath& src, 20bb77acf17c4eb4f58b6bfbe48d750d018485ecf2reed@google.com const SkStrokeRec&, const SkMatrix&, const SkRect*) const { 21f624cf053b92a6e53bbb7dac2bccc494911478f8robertphillips@google.com return false; 22f624cf053b92a6e53bbb7dac2bccc494911478f8robertphillips@google.com} 23f624cf053b92a6e53bbb7dac2bccc494911478f8robertphillips@google.com 24e3acc8d54824d72e1ee5248098392e068fef979areed@google.com/////////////////////////////////////////////////////////////////////////////// 25bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com 26bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.comSkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1) 27e3acc8d54824d72e1ee5248098392e068fef979areed@google.com : fPE0(pe0), fPE1(pe1) { 28bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com SkASSERT(pe0); 29bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com SkASSERT(pe1); 30bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com fPE0->ref(); 31bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com fPE1->ref(); 32bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com} 33bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com 34e3acc8d54824d72e1ee5248098392e068fef979areed@google.comSkPairPathEffect::~SkPairPathEffect() { 354079b3b1a4e9d99740a245692f530600879aa7c5reed@google.com SkSafeUnref(fPE0); 364079b3b1a4e9d99740a245692f530600879aa7c5reed@google.com SkSafeUnref(fPE1); 37bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com} 38bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com 39bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com/* 40bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data] 41bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com*/ 42cd2e444e946f5cfec4723f5bc46e9487d82e8e54djsollen@google.comvoid SkPairPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const { 43cd2e444e946f5cfec4723f5bc46e9487d82e8e54djsollen@google.com this->INHERITED::flatten(buffer); 44bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com buffer.writeFlattenable(fPE0); 45bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com buffer.writeFlattenable(fPE1); 46bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com} 47bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com 48e3acc8d54824d72e1ee5248098392e068fef979areed@google.comSkPairPathEffect::SkPairPathEffect(SkFlattenableReadBuffer& buffer) { 495e901c8c1bea70be7fc2c39112746891e38f72c9reed@google.com fPE0 = buffer.readPathEffect(); 505e901c8c1bea70be7fc2c39112746891e38f72c9reed@google.com fPE1 = buffer.readPathEffect(); 514079b3b1a4e9d99740a245692f530600879aa7c5reed@google.com // either of these may fail, so we have to check for nulls later on 52bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com} 53bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com 54e3acc8d54824d72e1ee5248098392e068fef979areed@google.com/////////////////////////////////////////////////////////////////////////////// 55bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com 56e3acc8d54824d72e1ee5248098392e068fef979areed@google.combool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src, 57bb77acf17c4eb4f58b6bfbe48d750d018485ecf2reed@google.com SkStrokeRec* rec, const SkRect* cullRect) const { 584079b3b1a4e9d99740a245692f530600879aa7c5reed@google.com // we may have failed to unflatten these, so we have to check 594079b3b1a4e9d99740a245692f530600879aa7c5reed@google.com if (!fPE0 || !fPE1) { 604079b3b1a4e9d99740a245692f530600879aa7c5reed@google.com return false; 614079b3b1a4e9d99740a245692f530600879aa7c5reed@google.com } 624079b3b1a4e9d99740a245692f530600879aa7c5reed@google.com 63bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com SkPath tmp; 64bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com const SkPath* ptr = &src; 65bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com 66bb77acf17c4eb4f58b6bfbe48d750d018485ecf2reed@google.com if (fPE1->filterPath(&tmp, src, rec, cullRect)) { 67bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com ptr = &tmp; 68e3acc8d54824d72e1ee5248098392e068fef979areed@google.com } 69bb77acf17c4eb4f58b6bfbe48d750d018485ecf2reed@google.com return fPE0->filterPath(dst, *ptr, rec, cullRect); 70bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com} 71bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com 72e3acc8d54824d72e1ee5248098392e068fef979areed@google.com/////////////////////////////////////////////////////////////////////////////// 73bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com 74e3acc8d54824d72e1ee5248098392e068fef979areed@google.combool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src, 75bb77acf17c4eb4f58b6bfbe48d750d018485ecf2reed@google.com SkStrokeRec* rec, const SkRect* cullRect) const { 76bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com // use bit-or so that we always call both, even if the first one succeeds 77bb77acf17c4eb4f58b6bfbe48d750d018485ecf2reed@google.com return fPE0->filterPath(dst, src, rec, cullRect) | 78bb77acf17c4eb4f58b6bfbe48d750d018485ecf2reed@google.com fPE1->filterPath(dst, src, rec, cullRect); 79bcd4d5ab12df062500a4df90ec90d0f2d764931reed@android.com} 80