RenderProperties.cpp revision 8c271ca63b62061fd22cfee78fd6a574b44476fd
1acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck/*
2acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck * Copyright (C) 2014 The Android Open Source Project
3acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck *
4acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck * Licensed under the Apache License, Version 2.0 (the "License");
5d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck * you mPrimitiveFields.may not use this file except in compliance with the License.
6d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck * You mPrimitiveFields.may obtain a copy of the License at
7acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck *
8acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck *      http://www.apache.org/licenses/LICENSE-2.0
9acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck *
10acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck * Unless required by applicable law or agreed to in writing, software
11acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck * distributed under the License is distributed on an "AS IS" BASIS,
12acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck * See the License for the specific language governing permissions and
14acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck * limitations under the License.
15acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck */
16d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck
17d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck#define LOG_TAG "OpenGLRenderer"
18d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck
19acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck#include "RenderProperties.h"
20acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck
21d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck#include <utils/Trace.h>
22d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck
23d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck#include <SkCanvas.h>
24acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck#include <SkMatrix.h>
258c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik#include <SkPath.h>
268c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik#include <SkPathOps.h>
27acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck
28acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck#include "Matrix.h"
29acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck
30acb6f07623b7df3d4179f70ae03ade574616ffa6John Recknamespace android {
31acb6f07623b7df3d4179f70ae03ade574616ffa6John Recknamespace uirenderer {
32acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck
33d0a0b2a3140bfb1819a116413ce9d81886697a07John ReckRenderProperties::PrimitiveFields::PrimitiveFields()
34acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        : mClipToBounds(true)
35acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        , mProjectBackwards(false)
36acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        , mProjectionReceiver(false)
37acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        , mAlpha(1)
38acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        , mHasOverlappingRendering(true)
39acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        , mTranslationX(0), mTranslationY(0), mTranslationZ(0)
40acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        , mRotation(0), mRotationX(0), mRotationY(0)
41acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        , mScaleX(1), mScaleY(1)
42acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        , mPivotX(0), mPivotY(0)
43acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        , mLeft(0), mTop(0), mRight(0), mBottom(0)
44acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        , mWidth(0), mHeight(0)
45acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        , mPrevWidth(-1), mPrevHeight(-1)
46acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        , mPivotExplicitlySet(false)
47acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        , mMatrixDirty(false)
48acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        , mMatrixIsIdentity(true)
49acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        , mMatrixFlags(0)
50acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        , mCaching(false) {
51acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck}
52acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck
53d0a0b2a3140bfb1819a116413ce9d81886697a07John ReckRenderProperties::ComputedFields::ComputedFields()
54d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        : mTransformMatrix(NULL)
55d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        , mTransformCamera(NULL)
568c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik        , mTransformMatrix3D(NULL)
578c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik        , mClipPath(NULL) {
58d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck}
59d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck
60d0a0b2a3140bfb1819a116413ce9d81886697a07John ReckRenderProperties::ComputedFields::~ComputedFields() {
61acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck    delete mTransformMatrix;
62acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck    delete mTransformCamera;
63acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck    delete mTransformMatrix3D;
648c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik    delete mClipPath;
65d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck}
66d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck
67d0a0b2a3140bfb1819a116413ce9d81886697a07John ReckRenderProperties::RenderProperties()
68d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        : mCameraDistance(0)
69d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        , mStaticMatrix(NULL)
70d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        , mAnimationMatrix(NULL) {
71d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck}
72d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck
73d0a0b2a3140bfb1819a116413ce9d81886697a07John ReckRenderProperties::~RenderProperties() {
74acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck    delete mStaticMatrix;
75acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck    delete mAnimationMatrix;
76acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck}
77acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck
78d0a0b2a3140bfb1819a116413ce9d81886697a07John ReckRenderProperties& RenderProperties::operator=(const RenderProperties& other) {
79d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    if (this != &other) {
80d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        mPrimitiveFields = other.mPrimitiveFields;
81d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        setStaticMatrix(other.getStaticMatrix());
82d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        setAnimationMatrix(other.getAnimationMatrix());
83d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        setCameraDistance(other.getCameraDistance());
84d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck
85d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        // Update the computed fields
86d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        updateMatrix();
878c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik        updateClipPath();
88d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    }
89d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    return *this;
90acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck}
91acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck
92d0a0b2a3140bfb1819a116413ce9d81886697a07John Reckvoid RenderProperties::debugOutputProperties(const int level) const {
93d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    if (mPrimitiveFields.mLeft != 0 || mPrimitiveFields.mTop != 0) {
94d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        ALOGD("%*sTranslate (left, top) %d, %d", level * 2, "", mPrimitiveFields.mLeft, mPrimitiveFields.mTop);
95d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    }
96d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    if (mStaticMatrix) {
97d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        ALOGD("%*sConcatMatrix (static) %p: " SK_MATRIX_STRING,
98d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                level * 2, "", mStaticMatrix, SK_MATRIX_ARGS(mStaticMatrix));
99d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    }
100d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    if (mAnimationMatrix) {
101d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        ALOGD("%*sConcatMatrix (animation) %p: " SK_MATRIX_STRING,
102d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                level * 2, "", mAnimationMatrix, SK_MATRIX_ARGS(mAnimationMatrix));
103d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    }
104d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    if (mPrimitiveFields.mMatrixFlags != 0) {
105d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        if (mPrimitiveFields.mMatrixFlags == TRANSLATION) {
106d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck            ALOGD("%*sTranslate %.2f, %.2f, %.2f",
107d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                    level * 2, "", mPrimitiveFields.mTranslationX, mPrimitiveFields.mTranslationY, mPrimitiveFields.mTranslationZ);
108d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        } else {
109d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck            ALOGD("%*sConcatMatrix %p: " MATRIX_4_STRING,
110d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                    level * 2, "", mComputedFields.mTransformMatrix, MATRIX_4_ARGS(mComputedFields.mTransformMatrix));
111d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        }
112d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    }
113d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck
114d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    bool clipToBoundsNeeded = mPrimitiveFields.mCaching ? false : mPrimitiveFields.mClipToBounds;
115d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    if (mPrimitiveFields.mAlpha < 1) {
116d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        if (mPrimitiveFields.mCaching) {
117d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck            ALOGD("%*sSetOverrideLayerAlpha %.2f", level * 2, "", mPrimitiveFields.mAlpha);
118d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        } else if (!mPrimitiveFields.mHasOverlappingRendering) {
119d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck            ALOGD("%*sScaleAlpha %.2f", level * 2, "", mPrimitiveFields.mAlpha);
120d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        } else {
121d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck            int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
122d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck            if (clipToBoundsNeeded) {
123d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                flags |= SkCanvas::kClipToLayer_SaveFlag;
124d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                clipToBoundsNeeded = false; // clipping done by save layer
125d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck            }
12678ce1c5247de60a4247d81d168fd9fa97c7591d0John Reck            ALOGD("%*sSaveLayerAlpha %d, %d, %d, %d, %d, 0x%x", level * 2, "",
12778ce1c5247de60a4247d81d168fd9fa97c7591d0John Reck                    0, 0, getWidth(), getHeight(),
128d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                    (int)(mPrimitiveFields.mAlpha * 255), flags);
129d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        }
130d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    }
131d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    if (clipToBoundsNeeded) {
13278ce1c5247de60a4247d81d168fd9fa97c7591d0John Reck        ALOGD("%*sClipRect %d, %d, %d, %d", level * 2, "",
13378ce1c5247de60a4247d81d168fd9fa97c7591d0John Reck                0, 0, getWidth(), getHeight());
134d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    }
135acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck}
136acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck
137acb6f07623b7df3d4179f70ae03ade574616ffa6John Reckvoid RenderProperties::updateMatrix() {
138d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    if (mPrimitiveFields.mMatrixDirty) {
139d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        // NOTE: mComputedFields.mTransformMatrix won't be up to date if a DisplayList goes from a complex transform
140d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        // to a pure translate. This is safe because the mPrimitiveFields.matrix isn't read in pure translate cases.
141d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        if (mPrimitiveFields.mMatrixFlags && mPrimitiveFields.mMatrixFlags != TRANSLATION) {
142d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck            if (!mComputedFields.mTransformMatrix) {
143d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                // only allocate a mPrimitiveFields.matrix if we have a complex transform
144d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                mComputedFields.mTransformMatrix = new Matrix4();
145acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck            }
146d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck            if (!mPrimitiveFields.mPivotExplicitlySet) {
147d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                if (mPrimitiveFields.mWidth != mPrimitiveFields.mPrevWidth || mPrimitiveFields.mHeight != mPrimitiveFields.mPrevHeight) {
148d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                    mPrimitiveFields.mPrevWidth = mPrimitiveFields.mWidth;
149d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                    mPrimitiveFields.mPrevHeight = mPrimitiveFields.mHeight;
150d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                    mPrimitiveFields.mPivotX = mPrimitiveFields.mPrevWidth / 2.0f;
151d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                    mPrimitiveFields.mPivotY = mPrimitiveFields.mPrevHeight / 2.0f;
152acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck                }
153acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck            }
154acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck
155d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck            if ((mPrimitiveFields.mMatrixFlags & ROTATION_3D) == 0) {
156d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                mComputedFields.mTransformMatrix->loadTranslate(
157d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                        mPrimitiveFields.mPivotX + mPrimitiveFields.mTranslationX,
158d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                        mPrimitiveFields.mPivotY + mPrimitiveFields.mTranslationY,
159acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck                        0);
160d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                mComputedFields.mTransformMatrix->rotate(mPrimitiveFields.mRotation, 0, 0, 1);
161d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                mComputedFields.mTransformMatrix->scale(mPrimitiveFields.mScaleX, mPrimitiveFields.mScaleY, 1);
162d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                mComputedFields.mTransformMatrix->translate(-mPrimitiveFields.mPivotX, -mPrimitiveFields.mPivotY);
163acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck            } else {
164d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                if (!mComputedFields.mTransformCamera) {
165d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                    mComputedFields.mTransformCamera = new Sk3DView();
166d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                    mComputedFields.mTransformMatrix3D = new SkMatrix();
167acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck                }
168acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck                SkMatrix transformMatrix;
169acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck                transformMatrix.reset();
170d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                mComputedFields.mTransformCamera->save();
171d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                transformMatrix.preScale(mPrimitiveFields.mScaleX, mPrimitiveFields.mScaleY, mPrimitiveFields.mPivotX, mPrimitiveFields.mPivotY);
172d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                mComputedFields.mTransformCamera->rotateX(mPrimitiveFields.mRotationX);
173d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                mComputedFields.mTransformCamera->rotateY(mPrimitiveFields.mRotationY);
174d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                mComputedFields.mTransformCamera->rotateZ(-mPrimitiveFields.mRotation);
175d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                mComputedFields.mTransformCamera->getMatrix(mComputedFields.mTransformMatrix3D);
176d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                mComputedFields.mTransformMatrix3D->preTranslate(-mPrimitiveFields.mPivotX, -mPrimitiveFields.mPivotY);
177d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                mComputedFields.mTransformMatrix3D->postTranslate(mPrimitiveFields.mPivotX + mPrimitiveFields.mTranslationX,
178d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                        mPrimitiveFields.mPivotY + mPrimitiveFields.mTranslationY);
179d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                transformMatrix.postConcat(*mComputedFields.mTransformMatrix3D);
180d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                mComputedFields.mTransformCamera->restore();
181d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck
182d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck                mComputedFields.mTransformMatrix->load(transformMatrix);
183acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck            }
184acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck        }
185d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        mPrimitiveFields.mMatrixDirty = false;
186acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck    }
187acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck}
188acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck
1898c271ca63b62061fd22cfee78fd6a574b44476fdChris Craikvoid RenderProperties::updateClipPath() {
1908c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik    const SkPath* outlineClipPath = mPrimitiveFields.mOutline.willClip()
1918c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik            ? mPrimitiveFields.mOutline.getPath() : NULL;
1928c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik    const SkPath* revealClipPath = mPrimitiveFields.mRevealClip.getPath();
1938c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik
1948c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik    if (!outlineClipPath && !revealClipPath) {
1958c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik        // mComputedFields.mClipPath doesn't need to be updated, since it won't be used
1968c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik        return;
1978c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik    }
1988c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik
1998c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik    if (mComputedFields.mClipPath == NULL) {
2008c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik        mComputedFields.mClipPath = new SkPath();
2018c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik    }
2028c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik    SkPath* clipPath = mComputedFields.mClipPath;
2038c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik    mComputedFields.mClipPathOp = SkRegion::kIntersect_Op;
2048c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik
2058c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik    if (outlineClipPath && revealClipPath) {
2068c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik        SkPathOp op = kIntersect_PathOp;
2078c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik        if (mPrimitiveFields.mRevealClip.isInverseClip()) {
2088c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik            op = kDifference_PathOp; // apply difference step in the Op below, instead of draw time
2098c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik        }
2108c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik
2118c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik        Op(*outlineClipPath, *revealClipPath, op, clipPath);
2128c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik    } else if (outlineClipPath) {
2138c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik        *clipPath = *outlineClipPath;
2148c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik    } else {
2158c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik        *clipPath = *revealClipPath;
2168c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik        if (mPrimitiveFields.mRevealClip.isInverseClip()) {
2178c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik            // apply difference step at draw time
2188c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik            mComputedFields.mClipPathOp = SkRegion::kDifference_Op;
2198c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik        }
2208c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik    }
2218c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik}
2228c271ca63b62061fd22cfee78fd6a574b44476fdChris Craik
223acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck} /* namespace uirenderer */
224acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck} /* namespace android */
225