gfx/skia/trunk/src/animator/SkDrawSaveLayer.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/animator/SkDrawSaveLayer.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2006 The Android Open Source Project
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +
    1.12 +
    1.13 +#include "SkDrawSaveLayer.h"
    1.14 +#include "SkAnimateMaker.h"
    1.15 +#include "SkCanvas.h"
    1.16 +#include "SkDrawPaint.h"
    1.17 +#include "SkDrawRectangle.h"
    1.18 +
    1.19 +#if SK_USE_CONDENSED_INFO == 0
    1.20 +
    1.21 +const SkMemberInfo SkSaveLayer::fInfo[] = {
    1.22 +    SK_MEMBER(bounds, Rect),
    1.23 +    SK_MEMBER(paint, Paint)
    1.24 +};
    1.25 +
    1.26 +#endif
    1.27 +
    1.28 +DEFINE_GET_MEMBER(SkSaveLayer);
    1.29 +
    1.30 +SkSaveLayer::SkSaveLayer() : paint(NULL), bounds(NULL) {
    1.31 +}
    1.32 +
    1.33 +SkSaveLayer::~SkSaveLayer(){
    1.34 +}
    1.35 +
    1.36 +bool SkSaveLayer::draw(SkAnimateMaker& maker)
    1.37 +{
    1.38 +    if (!bounds) {
    1.39 +        return false;
    1.40 +    }
    1.41 +    SkPaint* save = maker.fPaint;
    1.42 +    //paint is an SkDrawPaint
    1.43 +    if (paint)
    1.44 +    {
    1.45 +        SkPaint realPaint;
    1.46 +        paint->setupPaint(&realPaint);
    1.47 +        maker.fCanvas->saveLayer(&bounds->fRect, &realPaint, SkCanvas::kHasAlphaLayer_SaveFlag);
    1.48 +    }
    1.49 +    else
    1.50 +        maker.fCanvas->saveLayer(&bounds->fRect, save, SkCanvas::kHasAlphaLayer_SaveFlag);
    1.51 +    SkPaint local = SkPaint(*maker.fPaint);
    1.52 +    maker.fPaint = &local;
    1.53 +    bool result = INHERITED::draw(maker);
    1.54 +    maker.fPaint = save;
    1.55 +    maker.fCanvas->restore();
    1.56 +    return result;
    1.57 +}
    1.58 +
    1.59 +#ifdef SK_DUMP_ENABLED
    1.60 +void SkSaveLayer::dump(SkAnimateMaker* maker)
    1.61 +{
    1.62 +    dumpBase(maker);
    1.63 +    //would dump enabled be defined but not debug?
    1.64 +#ifdef SK_DEBUG
    1.65 +    if (paint)
    1.66 +        SkDebugf("paint=\"%s\" ", paint->id);
    1.67 +    if (bounds)
    1.68 +        SkDebugf("bounds=\"%s\" ", bounds->id);
    1.69 +#endif
    1.70 +    dumpDrawables(maker);
    1.71 +}
    1.72 +#endif
    1.73 +
    1.74 +void SkSaveLayer::onEndElement(SkAnimateMaker& maker)
    1.75 +{
    1.76 +    if (!bounds)
    1.77 +        maker.setErrorCode(SkDisplayXMLParserError::kSaveLayerNeedsBounds);
    1.78 +    INHERITED::onEndElement(maker);
    1.79 +}

mercurial