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

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

     2 /*
     3  * Copyright 2006 The Android Open Source Project
     4  *
     5  * Use of this source code is governed by a BSD-style license that can be
     6  * found in the LICENSE file.
     7  */
    10 #include "SkDrawSaveLayer.h"
    11 #include "SkAnimateMaker.h"
    12 #include "SkCanvas.h"
    13 #include "SkDrawPaint.h"
    14 #include "SkDrawRectangle.h"
    16 #if SK_USE_CONDENSED_INFO == 0
    18 const SkMemberInfo SkSaveLayer::fInfo[] = {
    19     SK_MEMBER(bounds, Rect),
    20     SK_MEMBER(paint, Paint)
    21 };
    23 #endif
    25 DEFINE_GET_MEMBER(SkSaveLayer);
    27 SkSaveLayer::SkSaveLayer() : paint(NULL), bounds(NULL) {
    28 }
    30 SkSaveLayer::~SkSaveLayer(){
    31 }
    33 bool SkSaveLayer::draw(SkAnimateMaker& maker)
    34 {
    35     if (!bounds) {
    36         return false;
    37     }
    38     SkPaint* save = maker.fPaint;
    39     //paint is an SkDrawPaint
    40     if (paint)
    41     {
    42         SkPaint realPaint;
    43         paint->setupPaint(&realPaint);
    44         maker.fCanvas->saveLayer(&bounds->fRect, &realPaint, SkCanvas::kHasAlphaLayer_SaveFlag);
    45     }
    46     else
    47         maker.fCanvas->saveLayer(&bounds->fRect, save, SkCanvas::kHasAlphaLayer_SaveFlag);
    48     SkPaint local = SkPaint(*maker.fPaint);
    49     maker.fPaint = &local;
    50     bool result = INHERITED::draw(maker);
    51     maker.fPaint = save;
    52     maker.fCanvas->restore();
    53     return result;
    54 }
    56 #ifdef SK_DUMP_ENABLED
    57 void SkSaveLayer::dump(SkAnimateMaker* maker)
    58 {
    59     dumpBase(maker);
    60     //would dump enabled be defined but not debug?
    61 #ifdef SK_DEBUG
    62     if (paint)
    63         SkDebugf("paint=\"%s\" ", paint->id);
    64     if (bounds)
    65         SkDebugf("bounds=\"%s\" ", bounds->id);
    66 #endif
    67     dumpDrawables(maker);
    68 }
    69 #endif
    71 void SkSaveLayer::onEndElement(SkAnimateMaker& maker)
    72 {
    73     if (!bounds)
    74         maker.setErrorCode(SkDisplayXMLParserError::kSaveLayerNeedsBounds);
    75     INHERITED::onEndElement(maker);
    76 }

mercurial