Snapshot.h revision fca52b7583d1e5f5ff8ed06554875d2a30ef56fa
15cbbce535744b89df5ecea95de21ee3733298260Romain Guy/* 25cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Copyright (C) 2010 The Android Open Source Project 35cbbce535744b89df5ecea95de21ee3733298260Romain Guy * 45cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Licensed under the Apache License, Version 2.0 (the "License"); 55cbbce535744b89df5ecea95de21ee3733298260Romain Guy * you may not use this file except in compliance with the License. 65cbbce535744b89df5ecea95de21ee3733298260Romain Guy * You may obtain a copy of the License at 75cbbce535744b89df5ecea95de21ee3733298260Romain Guy * 85cbbce535744b89df5ecea95de21ee3733298260Romain Guy * http://www.apache.org/licenses/LICENSE-2.0 95cbbce535744b89df5ecea95de21ee3733298260Romain Guy * 105cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Unless required by applicable law or agreed to in writing, software 115cbbce535744b89df5ecea95de21ee3733298260Romain Guy * distributed under the License is distributed on an "AS IS" BASIS, 125cbbce535744b89df5ecea95de21ee3733298260Romain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135cbbce535744b89df5ecea95de21ee3733298260Romain Guy * See the License for the specific language governing permissions and 145cbbce535744b89df5ecea95de21ee3733298260Romain Guy * limitations under the License. 155cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 165cbbce535744b89df5ecea95de21ee3733298260Romain Guy 175b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#ifndef ANDROID_HWUI_SNAPSHOT_H 185b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#define ANDROID_HWUI_SNAPSHOT_H 195cbbce535744b89df5ecea95de21ee3733298260Romain Guy 205cbbce535744b89df5ecea95de21ee3733298260Romain Guy#include <GLES2/gl2.h> 215cbbce535744b89df5ecea95de21ee3733298260Romain Guy#include <GLES2/gl2ext.h> 225cbbce535744b89df5ecea95de21ee3733298260Romain Guy 23deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik#include <utils/LinearAllocator.h> 245cbbce535744b89df5ecea95de21ee3733298260Romain Guy#include <utils/RefBase.h> 255b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#include <ui/Region.h> 265cbbce535744b89df5ecea95de21ee3733298260Romain Guy 27ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy#include <SkRegion.h> 28079ba2c85b15e882629b8d188f5fbdb42f7f8eeaRomain Guy 29487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk#include "ClipArea.h" 30dda570201ac851dd85af3861f7e575721d3345daRomain Guy#include "Layer.h" 315cbbce535744b89df5ecea95de21ee3733298260Romain Guy#include "Matrix.h" 32deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik#include "Outline.h" 335cbbce535744b89df5ecea95de21ee3733298260Romain Guy#include "Rect.h" 34deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik#include "utils/Macros.h" 355cbbce535744b89df5ecea95de21ee3733298260Romain Guy 365cbbce535744b89df5ecea95de21ee3733298260Romain Guynamespace android { 375cbbce535744b89df5ecea95de21ee3733298260Romain Guynamespace uirenderer { 385cbbce535744b89df5ecea95de21ee3733298260Romain Guy 395cbbce535744b89df5ecea95de21ee3733298260Romain Guy/** 40deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik * Temporary structure holding information for a single outline clip. 41deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik * 42deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik * These structures are treated as immutable once created, and only exist for a single frame, which 43deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik * is why they may only be allocated with a LinearAllocator. 44deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik */ 45deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craikclass RoundRectClipState { 46deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craikpublic: 47deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik /** static void* operator new(size_t size); PURPOSELY OMITTED, allocator only **/ 48deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik static void* operator new(size_t size, LinearAllocator& allocator) { 49deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik return allocator.alloc(size); 50deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik } 51deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik 52deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik bool areaRequiresRoundRectClip(const Rect& rect) const { 53deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik return rect.intersects(dangerRects[0]) 54deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik || rect.intersects(dangerRects[1]) 55deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik || rect.intersects(dangerRects[2]) 56deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik || rect.intersects(dangerRects[3]); 57deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik } 58deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik 59e83cbd451868a734bfac07ccd680d5617080b579Chris Craik bool highPriority; 60deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik Matrix4 matrix; 61deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik Rect dangerRects[4]; 62af4d04cab6d48ae0d6a5e79bd30f679af87abaadChris Craik Rect innerRect; 63af4d04cab6d48ae0d6a5e79bd30f679af87abaadChris Craik float radius; 64deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik}; 65deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik 66fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craikclass ProjectionPathMask { 67fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craikpublic: 68fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik /** static void* operator new(size_t size); PURPOSELY OMITTED, allocator only **/ 69fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik static void* operator new(size_t size, LinearAllocator& allocator) { 70fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik return allocator.alloc(size); 71fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik } 72fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik 73fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik const SkPath* projectionMask; 74fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik Matrix4 projectionMaskTransform; 75fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik}; 76fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik 77deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik/** 785cbbce535744b89df5ecea95de21ee3733298260Romain Guy * A snapshot holds information about the current state of the rendering 795cbbce535744b89df5ecea95de21ee3733298260Romain Guy * surface. A snapshot is usually created whenever the user calls save() 805cbbce535744b89df5ecea95de21ee3733298260Romain Guy * and discarded when the user calls restore(). Once a snapshot is created, 815cbbce535744b89df5ecea95de21ee3733298260Romain Guy * it can hold information for deferred rendering. 825cbbce535744b89df5ecea95de21ee3733298260Romain Guy * 835cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Each snapshot has a link to a previous snapshot, indicating the previous 845cbbce535744b89df5ecea95de21ee3733298260Romain Guy * state of the renderer. 855cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 865cbbce535744b89df5ecea95de21ee3733298260Romain Guyclass Snapshot: public LightRefBase<Snapshot> { 875cbbce535744b89df5ecea95de21ee3733298260Romain Guypublic: 885cbbce535744b89df5ecea95de21ee3733298260Romain Guy 89ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy Snapshot(); 90ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy Snapshot(const sp<Snapshot>& s, int saveFlags); 915cbbce535744b89df5ecea95de21ee3733298260Romain Guy 925cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 93ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy * Various flags set on ::flags. 945cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 955cbbce535744b89df5ecea95de21ee3733298260Romain Guy enum Flags { 965cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 975cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Indicates that the clip region was modified. When this 985cbbce535744b89df5ecea95de21ee3733298260Romain Guy * snapshot is restored so must the clip. 995cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 1005cbbce535744b89df5ecea95de21ee3733298260Romain Guy kFlagClipSet = 0x1, 1015cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 1025cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Indicates that this snapshot was created when saving 1035cbbce535744b89df5ecea95de21ee3733298260Romain Guy * a new layer. 1045cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 105079ba2c85b15e882629b8d188f5fbdb42f7f8eeaRomain Guy kFlagIsLayer = 0x2, 106f86ef57f8bcd8ba43ce222ec6a8b4f67d3600640Romain Guy /** 107eb99356a0548684a501766e6a524529ab93304c8Romain Guy * Indicates that this snapshot is a special type of layer 108eb99356a0548684a501766e6a524529ab93304c8Romain Guy * backed by an FBO. This flag only makes sense when the 109eb99356a0548684a501766e6a524529ab93304c8Romain Guy * flag kFlagIsLayer is also set. 110a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik * 111a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik * Viewport has been modified to fit the new Fbo, and must be 112a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik * restored when this snapshot is restored. 113eb99356a0548684a501766e6a524529ab93304c8Romain Guy */ 114eb99356a0548684a501766e6a524529ab93304c8Romain Guy kFlagIsFboLayer = 0x4, 115eb99356a0548684a501766e6a524529ab93304c8Romain Guy /** 1165b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * Indicates that this snapshot or an ancestor snapshot is 1175b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * an FBO layer. 1185b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy */ 119a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik kFlagFboTarget = 0x8, 1205cbbce535744b89df5ecea95de21ee3733298260Romain Guy }; 1215cbbce535744b89df5ecea95de21ee3733298260Romain Guy 1225cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 123f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy * Modifies the current clip with the new clip rectangle and 124f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy * the specified operation. The specified rectangle is transformed 125f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy * by this snapshot's trasnformation. 1263d58c03de0d8877b36cdb78b0ca8b5cac7f600e2Romain Guy */ 127f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy bool clip(float left, float top, float right, float bottom, 128ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy SkRegion::Op op = SkRegion::kIntersect_Op); 129f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy 130f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy /** 131f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy * Modifies the current clip with the new clip rectangle and 132f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy * the specified operation. The specified rectangle is considered 133f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy * already transformed. 134f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy */ 135ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy bool clipTransformed(const Rect& r, SkRegion::Op op = SkRegion::kIntersect_Op); 1365cbbce535744b89df5ecea95de21ee3733298260Romain Guy 1375cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 1388ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy * Modifies the current clip with the specified region and operation. 1398ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy * The specified region is considered already transformed. 1408ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy */ 1418ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy bool clipRegionTransformed(const SkRegion& region, SkRegion::Op op); 1428ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy 1438ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy /** 144487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk * Modifies the current clip with the specified path and operation. 145487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk */ 146487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk bool clipPath(const SkPath& path, SkRegion::Op op); 147487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk 148487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk /** 149d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy * Sets the current clip. 150d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy */ 151ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy void setClip(float left, float top, float right, float bottom); 152959c91f7f7b4f921d341264f5b4ef54e702a0df0Romain Guy 153ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy /** 154ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy * Returns the current clip in local coordinates. The clip rect is 155ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy * transformed by the inverse transform matrix. 156ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy */ 1571a49868fd82f8975da5685fdb6ca3cc83a99bdf5Ben Cheng ANDROID_API const Rect& getLocalClip(); 1583f085429fd47ebd32ac2463b3eae2a5a6c17be25Chris Craik 1593f085429fd47ebd32ac2463b3eae2a5a6c17be25Chris Craik /** 1603f085429fd47ebd32ac2463b3eae2a5a6c17be25Chris Craik * Returns the current clip in render target coordinates. 1613f085429fd47ebd32ac2463b3eae2a5a6c17be25Chris Craik */ 162487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk const Rect& getRenderTargetClip() { return mClipArea->getClipRect(); } 163487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk 164487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk /* 165487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk * Accessor functions so that the clip area can stay private 166487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk */ 167487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk bool clipIsEmpty() const { return mClipArea->isEmpty(); } 168487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk const Rect& getClipRect() const { return mClipArea->getClipRect(); } 169487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk const SkRegion& getClipRegion() const { return mClipArea->getClipRegion(); } 170487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk bool clipIsSimple() const { return mClipArea->isSimple(); } 171487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk const ClipArea& getClipArea() const { return *mClipArea; } 172d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy 173ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy /** 174ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy * Resets the clip to the specified rect. 175ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy */ 176ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy void resetClip(float left, float top, float right, float bottom); 177eb99356a0548684a501766e6a524529ab93304c8Romain Guy 178ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy /** 179ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy * Resets the current transform to a pure 3D translation. 180ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy */ 181ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy void resetTransform(float x, float y, float z); 182eb99356a0548684a501766e6a524529ab93304c8Romain Guy 183a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik void initializeViewport(int width, int height) { 184a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik mViewportData.initialize(width, height); 185487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk mClipAreaRoot.setViewportDimensions(width, height); 186a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik } 187a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik 188a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik int getViewportWidth() const { return mViewportData.mWidth; } 189a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik int getViewportHeight() const { return mViewportData.mHeight; } 190a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik const Matrix4& getOrthoMatrix() const { return mViewportData.mOrthoMatrix; } 191a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik 19269e5adffb19135d51bde8e458f4907d7265f3e23Chris Craik const Vector3& getRelativeLightCenter() const { return mRelativeLightCenter; } 19369e5adffb19135d51bde8e458f4907d7265f3e23Chris Craik void setRelativeLightCenter(const Vector3& lightCenter) { mRelativeLightCenter = lightCenter; } 19469e5adffb19135d51bde8e458f4907d7265f3e23Chris Craik 195ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy /** 196deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik * Sets (and replaces) the current clipping outline 197e83cbd451868a734bfac07ccd680d5617080b579Chris Craik * 198e83cbd451868a734bfac07ccd680d5617080b579Chris Craik * If the current round rect clip is high priority, the incoming clip is ignored. 199deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik */ 200e83cbd451868a734bfac07ccd680d5617080b579Chris Craik void setClippingRoundRect(LinearAllocator& allocator, const Rect& bounds, 201e83cbd451868a734bfac07ccd680d5617080b579Chris Craik float radius, bool highPriority); 202deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik 203deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik /** 204fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik * Sets (and replaces) the current projection mask 205fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik */ 206fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik void setProjectionPathMask(LinearAllocator& allocator, const SkPath* path); 207fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik 208fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik /** 209ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy * Indicates whether this snapshot should be ignored. A snapshot 210487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk * is typically ignored if its layer is invisible or empty. 211ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy */ 212ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy bool isIgnored() const; 213af636ebf5feb2837683fbfe965040cb706b32ec1Romain Guy 2148b55f377655d13a445b08a0a8ed09b6e95c752b0Romain Guy /** 215a3dc55f83ab583e0a66b893c71b849afa046770aRomain Guy * Indicates whether the current transform has perspective components. 216a3dc55f83ab583e0a66b893c71b849afa046770aRomain Guy */ 217a3dc55f83ab583e0a66b893c71b849afa046770aRomain Guy bool hasPerspectiveTransform() const; 218a3dc55f83ab583e0a66b893c71b849afa046770aRomain Guy 219a3dc55f83ab583e0a66b893c71b849afa046770aRomain Guy /** 220fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik * Fills outTransform with the current, total transform to screen space, 221fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik * across layer boundaries. 222fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik */ 223fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik void buildScreenSpaceTransform(Matrix4* outTransform) const; 224fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik 225fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik /** 2265cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Dirty flags. 2275cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 2285cbbce535744b89df5ecea95de21ee3733298260Romain Guy int flags; 2295cbbce535744b89df5ecea95de21ee3733298260Romain Guy 2305cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 2315cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Previous snapshot. 2325cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 2335cbbce535744b89df5ecea95de21ee3733298260Romain Guy sp<Snapshot> previous; 2345cbbce535744b89df5ecea95de21ee3733298260Romain Guy 2355cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 2368ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy * A pointer to the currently active layer. 237ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy * 238ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy * This snapshot does not own the layer, this pointer must not be freed. 2395cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 240dda570201ac851dd85af3861f7e575721d3345daRomain Guy Layer* layer; 241f86ef57f8bcd8ba43ce222ec6a8b4f67d3600640Romain Guy 2428aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy /** 243421458aad764cd9d1403d2540ab979b336b02341Romain Guy * Target FBO used for rendering. Set to 0 when rendering directly 244421458aad764cd9d1403d2540ab979b336b02341Romain Guy * into the framebuffer. 245eb99356a0548684a501766e6a524529ab93304c8Romain Guy */ 246eb99356a0548684a501766e6a524529ab93304c8Romain Guy GLuint fbo; 247eb99356a0548684a501766e6a524529ab93304c8Romain Guy 248eb99356a0548684a501766e6a524529ab93304c8Romain Guy /** 249dbc26d2ba13f80a7590c57de2d80530d96832969Romain Guy * Indicates that this snapshot is invisible and nothing should be drawn 250af636ebf5feb2837683fbfe965040cb706b32ec1Romain Guy * inside it. This flag is set only when the layer clips drawing to its 251af636ebf5feb2837683fbfe965040cb706b32ec1Romain Guy * bounds and is passed to subsequent snapshots. 252dbc26d2ba13f80a7590c57de2d80530d96832969Romain Guy */ 253dbc26d2ba13f80a7590c57de2d80530d96832969Romain Guy bool invisible; 254dbc26d2ba13f80a7590c57de2d80530d96832969Romain Guy 255dbc26d2ba13f80a7590c57de2d80530d96832969Romain Guy /** 256af636ebf5feb2837683fbfe965040cb706b32ec1Romain Guy * If set to true, the layer will not be composited. This is similar to 257af636ebf5feb2837683fbfe965040cb706b32ec1Romain Guy * invisible but this flag is not passed to subsequent snapshots. 258af636ebf5feb2837683fbfe965040cb706b32ec1Romain Guy */ 259af636ebf5feb2837683fbfe965040cb706b32ec1Romain Guy bool empty; 260af636ebf5feb2837683fbfe965040cb706b32ec1Romain Guy 261af636ebf5feb2837683fbfe965040cb706b32ec1Romain Guy /** 2628aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy * Local transformation. Holds the current translation, scale and 2638aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy * rotation values. 264ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy * 265ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy * This is a reference to a matrix owned by this snapshot or another 266ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy * snapshot. This pointer must not be freed. See ::mTransformRoot. 2678aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy */ 2688aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy mat4* transform; 2698aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy 2708aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy /** 271f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy * The ancestor layer's dirty region. 272ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy * 273ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy * This is a reference to a region owned by a layer. This pointer must 274ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy * not be freed. 2755b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy */ 2765b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy Region* region; 2775b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy 278db8c9a6a4d9bf8c39f834b25611926caf21380f6Chet Haase /** 279db8c9a6a4d9bf8c39f834b25611926caf21380f6Chet Haase * Current alpha value. This value is 1 by default, but may be set by a DisplayList which 280db8c9a6a4d9bf8c39f834b25611926caf21380f6Chet Haase * has translucent rendering in a non-overlapping View. This value will be used by 281db8c9a6a4d9bf8c39f834b25611926caf21380f6Chet Haase * the renderer to set the alpha in the current color being used for ensuing drawing 282db8c9a6a4d9bf8c39f834b25611926caf21380f6Chet Haase * operations. The value is inherited by child snapshots because the same value should 283487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk * be applied to descendants of the current DisplayList (for example, a TextView contains 284db8c9a6a4d9bf8c39f834b25611926caf21380f6Chet Haase * the base alpha value which should be applied to the child DisplayLists used for drawing 285db8c9a6a4d9bf8c39f834b25611926caf21380f6Chet Haase * the actual text). 286db8c9a6a4d9bf8c39f834b25611926caf21380f6Chet Haase */ 287db8c9a6a4d9bf8c39f834b25611926caf21380f6Chet Haase float alpha; 288db8c9a6a4d9bf8c39f834b25611926caf21380f6Chet Haase 289deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik /** 290deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik * Current clipping round rect. 291deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik * 292deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik * Points to data not owned by the snapshot, and may only be replaced by subsequent RR clips, 293deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik * never modified. 294deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik */ 295deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik const RoundRectClipState* roundRectClipState; 296deeda3d337aed1eee218b89a7aba5992ced371f0Chris Craik 297fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik /** 298fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik * Current projection masking path - used exclusively to mask tessellated circles. 299fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik */ 300fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik const ProjectionPathMask* projectionPathMask; 301fca52b7583d1e5f5ff8ed06554875d2a30ef56faChris Craik 3025f803623559aab395a29d575c37c4e39c23a4b4eChris Craik void dump() const; 3035f803623559aab395a29d575c37c4e39c23a4b4eChris Craik 3045cbbce535744b89df5ecea95de21ee3733298260Romain Guyprivate: 305a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik struct ViewportData { 306924197513aa2df4c1fb2977c1727f5d2c21f2689Chris Craik ViewportData() : mWidth(0), mHeight(0) {} 307a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik void initialize(int width, int height) { 308a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik mWidth = width; 309a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik mHeight = height; 310a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik mOrthoMatrix.loadOrtho(0, width, height, 0, -1, 1); 311a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik } 312a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik 313a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik /* 314a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik * Width and height of current viewport. 315a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik * 316a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik * The viewport is always defined to be (0, 0, width, height). 317a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik */ 318a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik int mWidth; 319a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik int mHeight; 320a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik /** 321a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik * Contains the current orthographic, projection matrix. 322a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik */ 323a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik mat4 mOrthoMatrix; 324a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik }; 325a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik 3268aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy mat4 mTransformRoot; 327079ba2c85b15e882629b8d188f5fbdb42f7f8eeaRomain Guy 328487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk ClipArea mClipAreaRoot; 329487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk ClipArea* mClipArea; 330487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk Rect mLocalClip; 331487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk 332a64a2bef1048db5a742843f1e3bea9e80d0defc5Chris Craik ViewportData mViewportData; 33369e5adffb19135d51bde8e458f4907d7265f3e23Chris Craik Vector3 mRelativeLightCenter; 334967e2bf3ac8943a8e8a374bf86021915445cda67Romain Guy 3355cbbce535744b89df5ecea95de21ee3733298260Romain Guy}; // class Snapshot 3365cbbce535744b89df5ecea95de21ee3733298260Romain Guy 3375cbbce535744b89df5ecea95de21ee3733298260Romain Guy}; // namespace uirenderer 3385cbbce535744b89df5ecea95de21ee3733298260Romain Guy}; // namespace android 3395cbbce535744b89df5ecea95de21ee3733298260Romain Guy 3405b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#endif // ANDROID_HWUI_SNAPSHOT_H 341