00001 /* 00002 * Copyright (C) 2006 The Android Open Source Project 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef SkLayerRasterizer_DEFINED 00018 #define SkLayerRasterizer_DEFINED 00019 00020 #include "SkRasterizer.h" 00021 #include "SkDeque.h" 00022 #include "SkScalar.h" 00023 00024 class SkPaint; 00025 00026 class SkLayerRasterizer : public SkRasterizer { 00027 public: 00028 SkLayerRasterizer(); 00029 virtual ~SkLayerRasterizer(); 00030 00031 void addLayer(const SkPaint& paint) 00032 { 00033 this->addLayer(paint, 0, 0); 00034 } 00035 00041 void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy); 00042 00043 // overrides from SkFlattenable 00044 virtual Factory getFactory(); 00045 virtual void flatten(SkFlattenableWriteBuffer&); 00046 00047 protected: 00048 SkLayerRasterizer(SkFlattenableReadBuffer&); 00049 00050 // override from SkRasterizer 00051 virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix, 00052 const SkIRect* clipBounds, 00053 SkMask* mask, SkMask::CreateMode mode); 00054 00055 private: 00056 SkDeque fLayers; 00057 00058 static SkFlattenable* CreateProc(SkFlattenableReadBuffer&); 00059 00060 typedef SkRasterizer INHERITED; 00061 }; 00062 00063 #endif