OpenGLRenderer.h revision 4063a0e03ba2e354cc6d19c0ffc073fd5b8aa2ca
1e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy/* 2e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * Copyright (C) 2010 The Android Open Source Project 3e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * 4e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * Licensed under the Apache License, Version 2.0 (the "License"); 5e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * you may not use this file except in compliance with the License. 6e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * You may obtain a copy of the License at 7e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * 8e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * http://www.apache.org/licenses/LICENSE-2.0 9e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * 10e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * Unless required by applicable law or agreed to in writing, software 11e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * distributed under the License is distributed on an "AS IS" BASIS, 12e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * See the License for the specific language governing permissions and 14e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * limitations under the License. 15e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy */ 16e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 175b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#ifndef ANDROID_HWUI_OPENGL_RENDERER_H 185b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#define ANDROID_HWUI_OPENGL_RENDERER_H 199d5316e3f56d138504565ff311145ac01621dff4Romain Guy 209d5316e3f56d138504565ff311145ac01621dff4Romain Guy#include <GLES2/gl2.h> 219d5316e3f56d138504565ff311145ac01621dff4Romain Guy#include <GLES2/gl2ext.h> 2285bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy 23ce0537b80087a6225273040a987414b1dd081aa0Romain Guy#include <SkBitmap.h> 24f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy#include <SkMatrix.h> 25ce0537b80087a6225273040a987414b1dd081aa0Romain Guy#include <SkPaint.h> 26079ba2c85b15e882629b8d188f5fbdb42f7f8eeaRomain Guy#include <SkRegion.h> 27d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy#include <SkShader.h> 2885bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy#include <SkXfermode.h> 29e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 30daf98e941e140e8739458126640183b9f296a2abChet Haase#include <utils/Functor.h> 31bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy#include <utils/RefBase.h> 32ba6be8a62dcdb3ffd210cd36b9af4e3a658eac47Romain Guy#include <utils/SortedVector.h> 338694230ff25fa0a60e480d424843e56b718f0516Romain Guy#include <utils/Vector.h> 34bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 357953745dd565167113f8cbfc461bc0521d32d870Romain Guy#include <cutils/compiler.h> 367953745dd565167113f8cbfc461bc0521d32d870Romain Guy 373b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy#include <androidfw/ResourceTypes.h> 383b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy 39c15008e72ec00ca20a271c3006dac649fd07533bRomain Guy#include "Debug.h" 4051769a68a5cb34e9564740c6a854fcb93018789dRomain Guy#include "Extensions.h" 41f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy#include "Matrix.h" 425cbbce535744b89df5ecea95de21ee3733298260Romain Guy#include "Program.h" 43bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy#include "Rect.h" 445cbbce535744b89df5ecea95de21ee3733298260Romain Guy#include "Snapshot.h" 45f7f93556c8fcc640ab5adef79d021a80a72a645aRomain Guy#include "Vertex.h" 4606f96e2652e4855b6520ad9dd70583677605b79aRomain Guy#include "SkiaShader.h" 47db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy#include "SkiaColorFilter.h" 483b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy#include "UvMapper.h" 49fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy#include "Caches.h" 50bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 51e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guynamespace android { 529d5316e3f56d138504565ff311145ac01621dff4Romain Guynamespace uirenderer { 53e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 54c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craikstruct DrawModifiers { 559b5a1a28c327e6113d68302b1f0eed1d1c6f6183Romain Guy DrawModifiers() { 569b5a1a28c327e6113d68302b1f0eed1d1c6f6183Romain Guy reset(); 579b5a1a28c327e6113d68302b1f0eed1d1c6f6183Romain Guy } 589b5a1a28c327e6113d68302b1f0eed1d1c6f6183Romain Guy 599b5a1a28c327e6113d68302b1f0eed1d1c6f6183Romain Guy void reset() { 609b5a1a28c327e6113d68302b1f0eed1d1c6f6183Romain Guy memset(this, 0, sizeof(DrawModifiers)); 619b5a1a28c327e6113d68302b1f0eed1d1c6f6183Romain Guy } 629b5a1a28c327e6113d68302b1f0eed1d1c6f6183Romain Guy 63c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik SkiaShader* mShader; 64c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik SkiaColorFilter* mColorFilter; 6516ecda5317c40fc3da284952d9b3add34d6763aeChris Craik float mOverrideLayerAlpha; 66c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik 67c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik // Drop shadow 68c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik bool mHasShadow; 69c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik float mShadowRadius; 70c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik float mShadowDx; 71c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik float mShadowDy; 72c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik int mShadowColor; 73c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik 74c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik // Draw filters 75c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik bool mHasDrawFilter; 76c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik int mPaintFilterClearBits; 77c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik int mPaintFilterSetBits; 78c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik}; 79c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik 80ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craikenum StateDeferFlags { 81ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik kStateDeferFlag_Draw = 0x1, 82ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik kStateDeferFlag_Clip = 0x2 83ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik}; 84ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik 85527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craikenum DrawOpMode { 86527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik kDrawOpMode_Immediate, 87527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik kDrawOpMode_Defer, 88527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik kDrawOpMode_Flush 89527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik}; 90527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik 9128ce94a4ffc7576f40776d212f1ada79fafaa061Chris Craikenum ClipSideFlags { 92a02c4ed885d97e516f844ddb0a96083f1b45b4cbChris Craik kClipSide_None = 0x0, 9328ce94a4ffc7576f40776d212f1ada79fafaa061Chris Craik kClipSide_Left = 0x1, 9428ce94a4ffc7576f40776d212f1ada79fafaa061Chris Craik kClipSide_Top = 0x2, 9528ce94a4ffc7576f40776d212f1ada79fafaa061Chris Craik kClipSide_Right = 0x4, 9628ce94a4ffc7576f40776d212f1ada79fafaa061Chris Craik kClipSide_Bottom = 0x8, 97d72b73cea49f29c41661e55eb6bfdbc04f09d809Chris Craik kClipSide_Full = 0xF, 98d72b73cea49f29c41661e55eb6bfdbc04f09d809Chris Craik kClipSide_ConservativeFull = 0x1F 9928ce94a4ffc7576f40776d212f1ada79fafaa061Chris Craik}; 10028ce94a4ffc7576f40776d212f1ada79fafaa061Chris Craik 1014063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik/** 1024063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * Defines additional transformation that should be applied by the model view matrix, beyond that of 1034063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * the currentTransform() 1044063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik */ 1054063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craikenum ModelViewMode { 1064063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik /** 1074063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * Used when the model view should simply translate geometry passed to the shader. The resulting 1084063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * matrix will be a simple translation. 1094063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik */ 1104063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik kModelViewMode_Translate = 0, 1114063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik 1124063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik /** 1134063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * Used when the model view should translate and scale geometry. The resulting matrix will be a 1144063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * translation + scale. This is frequently used together with VBO 0, the (0,0,1,1) rect. 1154063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik */ 1164063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik kModelViewMode_TranslateAndScale = 1, 1174063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik}; 1184063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik 119f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy/////////////////////////////////////////////////////////////////////////////// 120f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy// Renderer 121f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy/////////////////////////////////////////////////////////////////////////////// 122f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 123c1c5f0870282b56dafe5a4d756e4b9e6884655a7Chris Craikclass DeferredDisplayState; 1240fe478ea04720a57ef3919dbc23711bc7eba517fRomain Guyclass DisplayList; 125257ae3502cfad43df681b1783528d645bdabc63fRomain Guyclass TextSetupFunctor; 12665cd612face362d054a85d0f7e5881c59cd523beChris Craikclass VertexBuffer; 127b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy 1285cbbce535744b89df5ecea95de21ee3733298260Romain Guy/** 1295cbbce535744b89df5ecea95de21ee3733298260Romain Guy * OpenGL renderer used to draw accelerated 2D graphics. The API is a 1305cbbce535744b89df5ecea95de21ee3733298260Romain Guy * simplified version of Skia's Canvas API. 1315cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 13285bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guyclass OpenGLRenderer { 133e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guypublic: 1347953745dd565167113f8cbfc461bc0521d32d870Romain Guy ANDROID_API OpenGLRenderer(); 135e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy virtual ~OpenGLRenderer(); 136e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 13717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy /** 138ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy * Sets the name of this renderer. The name is optional and 139ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy * empty by default. If the pointer is null the name is set 140ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy * to the empty string. 141ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy */ 142ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy ANDROID_API void setName(const char* name); 143ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy 144ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy /** 145ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy * Returns the name of this renderer as UTF8 string. 146ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy * The returned pointer is never null. 147ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy */ 148ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy ANDROID_API const char* getName() const; 149ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy 150ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy /** 15187e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy * Read externally defined properties to control the behavior 15287e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy * of the renderer. 15387e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy */ 15487e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy ANDROID_API void initProperties(); 15587e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy 15687e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy /** 15717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * Indicates whether this renderer executes drawing commands immediately. 15817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * If this method returns true, the drawing commands will be executed 15917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * later. 16017112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy */ 16149c5fc0b9e850497233e189ff9dcc71a78ebe6e7Romain Guy virtual bool isDeferred(); 16249c5fc0b9e850497233e189ff9dcc71a78ebe6e7Romain Guy 16317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy /** 16417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * Sets the dimension of the underlying drawing surface. This method must 16517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * be called at least once every time the drawing surface changes size. 16617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * 16717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * @param width The width in pixels of the underlysing surface 16817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * @param height The height in pixels of the underlysing surface 16917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy */ 170b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy virtual void setViewport(int width, int height); 171e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy 17217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy /** 17317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * Prepares the renderer to draw a frame. This method must be invoked 17417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * at the beginning of each frame. When this method is invoked, the 17517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * entire drawing surface is assumed to be redrawn. 17617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * 17717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * @param opaque If true, the target surface is considered opaque 17817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * and will not be cleared. If false, the target surface 17917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * will be cleared 18017112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy */ 1817c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy ANDROID_API status_t prepare(bool opaque); 18217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy 18317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy /** 18417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * Prepares the renderer to draw a frame. This method must be invoked 18517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * at the beginning of each frame. Only the specified rectangle of the 18617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * frame is assumed to be dirty. A clip will automatically be set to 18717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * the specified rectangle. 18817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * 18917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * @param left The left coordinate of the dirty rectangle 19017112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * @param top The top coordinate of the dirty rectangle 19117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * @param right The right coordinate of the dirty rectangle 19217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * @param bottom The bottom coordinate of the dirty rectangle 19317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * @param opaque If true, the target surface is considered opaque 19417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * and will not be cleared. If false, the target surface 19517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * will be cleared in the specified dirty rectangle 19617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy */ 1977c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy virtual status_t prepareDirty(float left, float top, float right, float bottom, bool opaque); 198e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy 19917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy /** 20017112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * Indicates the end of a frame. This method must be invoked whenever 20117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * the caller is done rendering a frame. 20217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy */ 20317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy virtual void finish(); 2046c319ca1275c8db892c39b48fc54864c949f9171Romain Guy 205c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy /** 206c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy * This method must be invoked before handing control over to a draw functor. 207c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy * See callDrawGLFunction() for instance. 208c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy * 209c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy * This command must not be recorded inside display lists. 210c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy */ 211c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy virtual void interrupt(); 212c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy 213c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy /** 214c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy * This method must be invoked after getting control back from a draw functor. 215c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy * 216c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy * This command must not be recorded inside display lists. 217c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy */ 218c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy virtual void resume(); 219c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy 22078dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy ANDROID_API void setCountOverdrawEnabled(bool enabled) { 22178dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy mCountOverdraw = enabled; 22278dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy } 22378dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy 22478dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy ANDROID_API float getOverdraw() { 22578dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy return mCountOverdraw ? mOverdraw : 0.0f; 22678dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy } 22778dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy 2288f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy ANDROID_API status_t invokeFunctors(Rect& dirty); 229ba6be8a62dcdb3ffd210cd36b9af4e3a658eac47Romain Guy ANDROID_API void detachFunctor(Functor* functor); 230ba6be8a62dcdb3ffd210cd36b9af4e3a658eac47Romain Guy ANDROID_API void attachFunctor(Functor* functor); 2318f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy virtual status_t callDrawGLFunction(Functor* functor, Rect& dirty); 23208ae317c21ec3086b5017672bba87420cc38a407Romain Guy 23311cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy ANDROID_API void pushLayerUpdate(Layer* layer); 234e93482f5eac3df581d57e64c2a771a96aa868585Romain Guy ANDROID_API void cancelLayerUpdate(Layer* layer); 23511cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy ANDROID_API void clearLayerUpdates(); 236405436021da156fbe3c5d4de48bdefa564cf7fc0Romain Guy ANDROID_API void flushLayerUpdates(); 23711cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy 2387953745dd565167113f8cbfc461bc0521d32d870Romain Guy ANDROID_API int getSaveCount() const; 2394aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy virtual int save(int flags); 2404aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy virtual void restore(); 2414aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy virtual void restoreToCount(int saveCount); 242bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 243ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik ANDROID_API int saveLayer(float left, float top, float right, float bottom, 244ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik SkPaint* paint, int flags) { 245ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode; 246ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik if (paint) mode = getXfermode(paint->getXfermode()); 247ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik return saveLayer(left, top, right, bottom, paint ? paint->getAlpha() : 255, mode, flags); 248ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik } 249ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik ANDROID_API int saveLayerAlpha(float left, float top, float right, float bottom, 250ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik int alpha, int flags) { 251ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik return saveLayer(left, top, right, bottom, alpha, SkXfermode::kSrcOver_Mode, flags); 252ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik } 253e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy virtual int saveLayer(float left, float top, float right, float bottom, 254ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik int alpha, SkXfermode::Mode mode, int flags); 255bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy 256d90144db52c7297879b950cbbc85137ed123ab5bChris Craik int saveLayerDeferred(float left, float top, float right, float bottom, 257d90144db52c7297879b950cbbc85137ed123ab5bChris Craik int alpha, SkXfermode::Mode mode, int flags); 258d90144db52c7297879b950cbbc85137ed123ab5bChris Craik 2594aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy virtual void translate(float dx, float dy); 2604aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy virtual void rotate(float degrees); 2614aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy virtual void scale(float sx, float sy); 262807daf7df615b60ce6fc41355aabe3aa353cebabRomain Guy virtual void skew(float sx, float sy); 263f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 264b98a016c6769b9e80d392df22fe77a2fca048d9fChris Craik bool hasRectToRectTransform(); 2657953745dd565167113f8cbfc461bc0521d32d870Romain Guy ANDROID_API void getMatrix(SkMatrix* matrix); 2664aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy virtual void setMatrix(SkMatrix* matrix); 2674aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy virtual void concatMatrix(SkMatrix* matrix); 268f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 2697953745dd565167113f8cbfc461bc0521d32d870Romain Guy ANDROID_API const Rect& getClipBounds(); 27039a908c1df89e1073627b0dcbce922d826b67055Chris Craik 27139a908c1df89e1073627b0dcbce922d826b67055Chris Craik /** 2725e49b307eb99269db2db257760508b8efd7bb97dChris Craik * Performs a quick reject but adjust the bounds to account for stroke width if necessary, 2735e49b307eb99269db2db257760508b8efd7bb97dChris Craik * and handling snapOut for AA geometry. 27439a908c1df89e1073627b0dcbce922d826b67055Chris Craik */ 27539a908c1df89e1073627b0dcbce922d826b67055Chris Craik bool quickRejectPreStroke(float left, float top, float right, float bottom, SkPaint* paint); 27639a908c1df89e1073627b0dcbce922d826b67055Chris Craik 27739a908c1df89e1073627b0dcbce922d826b67055Chris Craik /** 27839a908c1df89e1073627b0dcbce922d826b67055Chris Craik * Returns false and sets scissor based upon bounds if drawing won't be clipped out 27939a908c1df89e1073627b0dcbce922d826b67055Chris Craik */ 2805e49b307eb99269db2db257760508b8efd7bb97dChris Craik bool quickReject(float left, float top, float right, float bottom, bool snapOut = false); 28141541825bc90dac740e424cdd41a8c997e15cdb7Chris Craik bool quickReject(const Rect& bounds) { 28241541825bc90dac740e424cdd41a8c997e15cdb7Chris Craik return quickReject(bounds.left, bounds.top, bounds.right, bounds.bottom); 28341541825bc90dac740e424cdd41a8c997e15cdb7Chris Craik } 28439a908c1df89e1073627b0dcbce922d826b67055Chris Craik 28539a908c1df89e1073627b0dcbce922d826b67055Chris Craik /** 28639a908c1df89e1073627b0dcbce922d826b67055Chris Craik * Same as quickReject, without the scissor, instead returning clipRequired through pointer. 28739a908c1df89e1073627b0dcbce922d826b67055Chris Craik * clipRequired will be only set if not rejected 28839a908c1df89e1073627b0dcbce922d826b67055Chris Craik */ 28939a908c1df89e1073627b0dcbce922d826b67055Chris Craik ANDROID_API bool quickRejectNoScissor(float left, float top, float right, float bottom, 2905e49b307eb99269db2db257760508b8efd7bb97dChris Craik bool snapOut = false, bool* clipRequired = NULL); 29139a908c1df89e1073627b0dcbce922d826b67055Chris Craik bool quickRejectNoScissor(const Rect& bounds, bool* clipRequired = NULL) { 29239a908c1df89e1073627b0dcbce922d826b67055Chris Craik return quickRejectNoScissor(bounds.left, bounds.top, bounds.right, bounds.bottom, 29339a908c1df89e1073627b0dcbce922d826b67055Chris Craik clipRequired); 29439a908c1df89e1073627b0dcbce922d826b67055Chris Craik } 29539a908c1df89e1073627b0dcbce922d826b67055Chris Craik 2964aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op); 297735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy virtual bool clipPath(SkPath* path, SkRegion::Op op); 298735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy virtual bool clipRegion(SkRegion* region, SkRegion::Op op); 299a23eed808a1ae4ec0d818c0a9238385e797fd056Chet Haase virtual Rect* getClipRect(); 300bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 301ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik virtual status_t drawDisplayList(DisplayList* displayList, Rect& dirty, int32_t replayFlags); 302c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik virtual void outputDisplayList(DisplayList* displayList); 303a08f95cfeca7217f9c533b03663bf0dceedd259aChris Craik virtual status_t drawLayer(Layer* layer, float x, float y); 304486590963e2207d68eebd6944fec70d50d41116aChet Haase virtual status_t drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint); 30555b6f95ee4ace96c97508bcd14483fb4e9dbeaa0Romain Guy status_t drawBitmaps(SkBitmap* bitmap, AssetAtlas::Entry* entry, int bitmapCount, 306996fe656340ede058a6f0e6b18f9ec525ddb4e27Chris Craik TextureVertex* vertices, bool pureTranslate, const Rect& bounds, SkPaint* paint); 307486590963e2207d68eebd6944fec70d50d41116aChet Haase virtual status_t drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint); 308486590963e2207d68eebd6944fec70d50d41116aChet Haase virtual status_t drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop, 309e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy float srcRight, float srcBottom, float dstLeft, float dstTop, 3105c13d89c1332fcc499379b9064b891187b75ca32Chet Haase float dstRight, float dstBottom, SkPaint* paint); 311486590963e2207d68eebd6944fec70d50d41116aChet Haase virtual status_t drawBitmapData(SkBitmap* bitmap, float left, float top, SkPaint* paint); 312486590963e2207d68eebd6944fec70d50d41116aChet Haase virtual status_t drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight, 3135a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy float* vertices, int* colors, SkPaint* paint); 31403c00b5a135e68d22ca5bb829b899ebda6ed7e9dRomain Guy status_t drawPatches(SkBitmap* bitmap, AssetAtlas::Entry* entry, 31503c00b5a135e68d22ca5bb829b899ebda6ed7e9dRomain Guy TextureVertex* vertices, uint32_t indexCount, SkPaint* paint); 3163b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy virtual status_t drawPatch(SkBitmap* bitmap, Res_png_9patch* patch, 3175c13d89c1332fcc499379b9064b891187b75ca32Chet Haase float left, float top, float right, float bottom, SkPaint* paint); 3184c2547fa9244e78115cde0a259291053108c3dc7Romain Guy status_t drawPatch(SkBitmap* bitmap, const Patch* mesh, AssetAtlas::Entry* entry, 31903c00b5a135e68d22ca5bb829b899ebda6ed7e9dRomain Guy float left, float top, float right, float bottom, SkPaint* paint); 320486590963e2207d68eebd6944fec70d50d41116aChet Haase virtual status_t drawColor(int color, SkXfermode::Mode mode); 321486590963e2207d68eebd6944fec70d50d41116aChet Haase virtual status_t drawRect(float left, float top, float right, float bottom, SkPaint* paint); 322486590963e2207d68eebd6944fec70d50d41116aChet Haase virtual status_t drawRoundRect(float left, float top, float right, float bottom, 32301d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy float rx, float ry, SkPaint* paint); 324486590963e2207d68eebd6944fec70d50d41116aChet Haase virtual status_t drawCircle(float x, float y, float radius, SkPaint* paint); 325486590963e2207d68eebd6944fec70d50d41116aChet Haase virtual status_t drawOval(float left, float top, float right, float bottom, SkPaint* paint); 326486590963e2207d68eebd6944fec70d50d41116aChet Haase virtual status_t drawArc(float left, float top, float right, float bottom, 3278b2f5267f16c295f12faab810527cd6311997e34Romain Guy float startAngle, float sweepAngle, bool useCenter, SkPaint* paint); 328486590963e2207d68eebd6944fec70d50d41116aChet Haase virtual status_t drawPath(SkPath* path, SkPaint* paint); 329486590963e2207d68eebd6944fec70d50d41116aChet Haase virtual status_t drawLines(float* points, int count, SkPaint* paint); 330486590963e2207d68eebd6944fec70d50d41116aChet Haase virtual status_t drawPoints(float* points, int count, SkPaint* paint); 331486590963e2207d68eebd6944fec70d50d41116aChet Haase virtual status_t drawTextOnPath(const char* text, int bytesCount, int count, SkPath* path, 332325740fb444af8fc7fb0119b2e30ce322c2ae134Romain Guy float hOffset, float vOffset, SkPaint* paint); 333486590963e2207d68eebd6944fec70d50d41116aChet Haase virtual status_t drawPosText(const char* text, int bytesCount, int count, 334325740fb444af8fc7fb0119b2e30ce322c2ae134Romain Guy const float* positions, SkPaint* paint); 335c25259519f1b74bb62a2b051b74537f073436b5cRomain Guy virtual status_t drawText(const char* text, int bytesCount, int count, float x, float y, 33641541825bc90dac740e424cdd41a8c997e15cdb7Chris Craik const float* positions, SkPaint* paint, float totalAdvance, const Rect& bounds, 337527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik DrawOpMode drawOpMode = kDrawOpMode_Immediate); 338672433d90fab7383cd28beac9d4485b566a90940Romain Guy virtual status_t drawRects(const float* rects, int count, SkPaint* paint); 33985bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy 3404aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy virtual void resetShader(); 3414aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy virtual void setupShader(SkiaShader* shader); 342d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy 3434aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy virtual void resetColorFilter(); 3444aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy virtual void setupColorFilter(SkiaColorFilter* filter); 345db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy 3464aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy virtual void resetShadow(); 3474aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy virtual void setupShadow(float radius, float dx, float dy, int color); 3481e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy 3495ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy virtual void resetPaintFilter(); 3505ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy virtual void setupPaintFilter(int clearBits, int setBits); 3515ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy 35216ecda5317c40fc3da284952d9b3add34d6763aeChris Craik // If this value is set to < 1.0, it overrides alpha set on layer (see drawBitmap, drawLayer) 35316ecda5317c40fc3da284952d9b3add34d6763aeChris Craik void setOverrideLayerAlpha(float alpha) { mDrawModifiers.mOverrideLayerAlpha = alpha; } 35416ecda5317c40fc3da284952d9b3add34d6763aeChris Craik 355a08f95cfeca7217f9c533b03663bf0dceedd259aChris Craik SkPaint* filterPaint(SkPaint* paint); 3565ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy 3575e49b307eb99269db2db257760508b8efd7bb97dChris Craik /** 3585e49b307eb99269db2db257760508b8efd7bb97dChris Craik * Store the current display state (most importantly, the current clip and transform), and 3595e49b307eb99269db2db257760508b8efd7bb97dChris Craik * additionally map the state's bounds from local to window coordinates. 3605e49b307eb99269db2db257760508b8efd7bb97dChris Craik * 3615e49b307eb99269db2db257760508b8efd7bb97dChris Craik * Returns true if quick-rejected 3625e49b307eb99269db2db257760508b8efd7bb97dChris Craik */ 363ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik bool storeDisplayState(DeferredDisplayState& state, int stateDeferFlags); 364527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik void restoreDisplayState(const DeferredDisplayState& state, bool skipClipRestore = false); 36528ce94a4ffc7576f40776d212f1ada79fafaa061Chris Craik void setupMergedMultiDraw(const Rect* clipRect); 366c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik 367d90144db52c7297879b950cbbc85137ed123ab5bChris Craik const DrawModifiers& getDrawModifiers() { return mDrawModifiers; } 368d90144db52c7297879b950cbbc85137ed123ab5bChris Craik void setDrawModifiers(const DrawModifiers& drawModifiers) { mDrawModifiers = drawModifiers; } 369d90144db52c7297879b950cbbc85137ed123ab5bChris Craik 370672433d90fab7383cd28beac9d4485b566a90940Romain Guy ANDROID_API bool isCurrentTransformSimple() { 371672433d90fab7383cd28beac9d4485b566a90940Romain Guy return mSnapshot->transform->isSimple(); 372672433d90fab7383cd28beac9d4485b566a90940Romain Guy } 373672433d90fab7383cd28beac9d4485b566a90940Romain Guy 3740f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy Caches& getCaches() { 3750f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy return mCaches; 3760f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy } 3770f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy 378ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik // simple rect clip 379ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik bool isCurrentClipSimple() { 380ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik return mSnapshot->clipRegion->isEmpty(); 381ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik } 382ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik 3830e87f00f8cb79635aa70b9a2dfa02bf19dc7473dChris Craik int getViewportWidth() { return getSnapshot()->viewport.getWidth(); } 3840e87f00f8cb79635aa70b9a2dfa02bf19dc7473dChris Craik int getViewportHeight() { return getSnapshot()->viewport.getHeight(); } 3850e87f00f8cb79635aa70b9a2dfa02bf19dc7473dChris Craik 38617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy /** 387a08f95cfeca7217f9c533b03663bf0dceedd259aChris Craik * Scales the alpha on the current snapshot. This alpha value will be modulated 38817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * with other alpha values when drawing primitives. 38917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy */ 390a08f95cfeca7217f9c533b03663bf0dceedd259aChris Craik void scaleAlpha(float alpha) { 391a08f95cfeca7217f9c533b03663bf0dceedd259aChris Craik mSnapshot->alpha *= alpha; 39217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy } 39317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy 39417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy /** 3950f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy * Inserts a named event marker in the stream of GL commands. 3960f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy */ 3970f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy void eventMark(const char* name) const; 3980f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy 3990f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy /** 40017112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * Inserts a named group marker in the stream of GL commands. This marker 40117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * can be used by tools to group commands into logical groups. A call to 40217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * this method must always be followed later on by a call to endMark(). 40317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy */ 40413631f3da855f200a151e7837ed9f6b079622b58Romain Guy void startMark(const char* name) const; 40517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy 40617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy /** 40717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * Closes the last group marker opened by startMark(). 40817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy */ 40913631f3da855f200a151e7837ed9f6b079622b58Romain Guy void endMark() const; 41013631f3da855f200a151e7837ed9f6b079622b58Romain Guy 411d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase /** 412d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase * Gets the alpha and xfermode out of a paint object. If the paint is null 413d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase * alpha will be 255 and the xfermode will be SRC_OVER. This method does 41416ecda5317c40fc3da284952d9b3add34d6763aeChris Craik * not multiply the paint's alpha by the current snapshot's alpha, and does 41516ecda5317c40fc3da284952d9b3add34d6763aeChris Craik * not replace the alpha with the overrideLayerAlpha 416d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase * 417d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase * @param paint The paint to extract values from 418d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase * @param alpha Where to store the resulting alpha 419d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase * @param mode Where to store the resulting xfermode 420d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase */ 421d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase static inline void getAlphaAndModeDirect(SkPaint* paint, int* alpha, SkXfermode::Mode* mode) { 422527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik *mode = getXfermodeDirect(paint); 423527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik *alpha = getAlphaDirect(paint); 424527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik } 425527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik 426527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik static inline SkXfermode::Mode getXfermodeDirect(SkPaint* paint) { 427527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik if (!paint) return SkXfermode::kSrcOver_Mode; 428527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik return getXfermode(paint->getXfermode()); 429527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik } 430527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik 431c1c5f0870282b56dafe5a4d756e4b9e6884655a7Chris Craik static inline int getAlphaDirect(const SkPaint* paint) { 432527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik if (!paint) return 255; 433527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik return paint->getAlpha(); 434d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase } 435d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase 436624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy /** 437624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy * Return the best transform to use to rasterize text given a full 438624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy * transform matrix. 439624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy */ 440624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy mat4 findBestFontTransform(const mat4& transform) const; 441624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy 442527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik#if DEBUG_MERGE_BEHAVIOR 443527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik void drawScreenSpaceColorRect(float left, float top, float right, float bottom, int color) { 444527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik mCaches.setScissorEnabled(false); 445527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik 446527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik // should only be called outside of other draw ops, so stencil can only be in test state 447527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik bool stencilWasEnabled = mCaches.stencil.isTestEnabled(); 448527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik mCaches.stencil.disable(); 449527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik 450527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik drawColorRect(left, top, right, bottom, color, SkXfermode::kSrcOver_Mode, true); 451527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik 452527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik if (stencilWasEnabled) mCaches.stencil.enableTest(); 453527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik } 454527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik#endif 455527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik 456e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guyprotected: 457e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy /** 45835643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy * Computes the projection matrix, initialize the first snapshot 45935643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy * and stores the dimensions of the render target. 46035643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy */ 46135643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy void initViewport(int width, int height); 46235643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy 46335643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy /** 46496885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy * Perform the setup specific to a frame. This method does not 46596885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy * issue any OpenGL commands. 46696885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy */ 46796885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy void setupFrameState(float left, float top, float right, float bottom, bool opaque); 46896885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy 46996885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy /** 47096885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy * Indicates the start of rendering. This method will setup the 47196885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy * initial OpenGL state (viewport, clearing the buffer, etc.) 47296885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy */ 47396885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy status_t startFrame(); 47496885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy 47596885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy /** 4767c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy * Clears the underlying surface if needed. 4777c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy */ 4787c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy virtual status_t clear(float left, float top, float right, float bottom, bool opaque); 4797c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy 4807c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy /** 48135643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy * Call this method after updating a layer during a drawing pass. 48235643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy */ 48335643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy void resumeAfterLayer(); 48435643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy 48535643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy /** 4868ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy * This method is called whenever a stencil buffer is required. Subclasses 4878ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy * should override this method and call attachStencilBufferToLayer() on the 4888ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy * appropriate layer(s). 4898ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy */ 4908ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy virtual void ensureStencilBuffer(); 4918ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy 4928ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy /** 4938ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy * Obtains a stencil render buffer (allocating it if necessary) and 4948ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy * attaches it to the specified layer. 4958ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy */ 4968ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy void attachStencilBufferToLayer(Layer* layer); 4978ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy 4988ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy /** 499e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy * Compose the layer defined in the current snapshot with the layer 500e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy * defined by the previous snapshot. 501e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy * 502e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy * The current snapshot *must* be a layer (flag kFlagIsLayer set.) 503e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy * 504e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy * @param curent The current snapshot containing the layer to compose 505e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy * @param previous The previous snapshot to compose the current layer with 506e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy */ 507e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy virtual void composeLayer(sp<Snapshot> current, sp<Snapshot> previous); 508694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 509ada830f639591b99c3e40de22b07296c7932a33fRomain Guy /** 510f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy * Marks the specified region as dirty at the specified bounds. 511ada830f639591b99c3e40de22b07296c7932a33fRomain Guy */ 512f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy void dirtyLayerUnchecked(Rect& bounds, Region* region); 513ada830f639591b99c3e40de22b07296c7932a33fRomain Guy 514ada830f639591b99c3e40de22b07296c7932a33fRomain Guy /** 515f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy * Returns the current snapshot. 516ada830f639591b99c3e40de22b07296c7932a33fRomain Guy */ 517624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy sp<Snapshot> getSnapshot() const { 518f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy return mSnapshot; 519f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy } 520ada830f639591b99c3e40de22b07296c7932a33fRomain Guy 52142f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy /** 52242f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy * Returns the region of the current layer. 52342f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy */ 524624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy virtual Region* getRegion() const { 525f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy return mSnapshot->region; 526f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy } 527f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy 52842f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy /** 52942f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy * Indicates whether rendering is currently targeted at a layer. 53042f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy */ 531624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy virtual bool hasLayer() const { 532f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy return (mSnapshot->flags & Snapshot::kFlagFboTarget) && mSnapshot->region; 533f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy } 5341bd1bad0b4a75e633c5edbe802bf6fb4dd765161Romain Guy 53542f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy /** 53642f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy * Returns the name of the FBO this renderer is rendering into. 53742f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy */ 538624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy virtual GLint getTargetFbo() const { 53942f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy return 0; 54042f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy } 54142f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy 54277a811610f99e21da7f88dafef60d09f345d0506Romain Guy /** 54377a811610f99e21da7f88dafef60d09f345d0506Romain Guy * Renders the specified layer as a textured quad. 54477a811610f99e21da7f88dafef60d09f345d0506Romain Guy * 54577a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @param layer The layer to render 54677a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @param rect The bounds of the layer 54777a811610f99e21da7f88dafef60d09f345d0506Romain Guy */ 54877a811610f99e21da7f88dafef60d09f345d0506Romain Guy void drawTextureLayer(Layer* layer, const Rect& rect); 54977a811610f99e21da7f88dafef60d09f345d0506Romain Guy 550be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy /** 551be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy * Gets the alpha and xfermode out of a paint object. If the paint is null 55216ecda5317c40fc3da284952d9b3add34d6763aeChris Craik * alpha will be 255 and the xfermode will be SRC_OVER. Accounts for both 55316ecda5317c40fc3da284952d9b3add34d6763aeChris Craik * snapshot alpha, and overrideLayerAlpha 554be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy * 555be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy * @param paint The paint to extract values from 556be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy * @param alpha Where to store the resulting alpha 557be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy * @param mode Where to store the resulting xfermode 558be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy */ 55916ecda5317c40fc3da284952d9b3add34d6763aeChris Craik inline void getAlphaAndMode(SkPaint* paint, int* alpha, SkXfermode::Mode* mode) const; 56016ecda5317c40fc3da284952d9b3add34d6763aeChris Craik 56116ecda5317c40fc3da284952d9b3add34d6763aeChris Craik /** 56216ecda5317c40fc3da284952d9b3add34d6763aeChris Craik * Gets the alpha from a layer, accounting for snapshot alpha and overrideLayerAlpha 56316ecda5317c40fc3da284952d9b3add34d6763aeChris Craik * 56416ecda5317c40fc3da284952d9b3add34d6763aeChris Craik * @param layer The layer from which the alpha is extracted 56516ecda5317c40fc3da284952d9b3add34d6763aeChris Craik */ 56616ecda5317c40fc3da284952d9b3add34d6763aeChris Craik inline float getLayerAlpha(Layer* layer) const; 567be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy 568be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy /** 569be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy * Safely retrieves the mode from the specified xfermode. If the specified 570be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy * xfermode is null, the mode is assumed to be SkXfermode::kSrcOver_Mode. 571be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy */ 572be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy static inline SkXfermode::Mode getXfermode(SkXfermode* mode) { 573be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy SkXfermode::Mode resultMode; 574be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy if (!SkXfermode::AsMode(mode, &resultMode)) { 575be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy resultMode = SkXfermode::kSrcOver_Mode; 576be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy } 577be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy return resultMode; 578be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy } 579be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy 58011cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy /** 58111cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy * Set to true to suppress error checks at the end of a frame. 58211cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy */ 583624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy virtual bool suppressErrorChecks() const { 58411cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy return false; 58511cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy } 58611cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy 58708ae317c21ec3086b5017672bba87420cc38a407Romain Guyprivate: 5885cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 589dcfc836b457a87881da409e1acf251515f121446Romain Guy * Discards the content of the framebuffer if supported by the driver. 590dcfc836b457a87881da409e1acf251515f121446Romain Guy * This method should be called at the beginning of a frame to optimize 591dcfc836b457a87881da409e1acf251515f121446Romain Guy * rendering on some tiler architectures. 592dcfc836b457a87881da409e1acf251515f121446Romain Guy */ 593dcfc836b457a87881da409e1acf251515f121446Romain Guy void discardFramebuffer(float left, float top, float right, float bottom); 594dcfc836b457a87881da409e1acf251515f121446Romain Guy 595dcfc836b457a87881da409e1acf251515f121446Romain Guy /** 596ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy * Ensures the state of the renderer is the same as the state of 597ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy * the GL context. 598ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy */ 599ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy void syncState(); 600ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy 601ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy /** 6022b7028eabac80cec170572bc0e945a1d4224e595Romain Guy * Tells the GPU what part of the screen is about to be redrawn. 603c3fedafc5f50100219449125a000e3138f6fb987Romain Guy * This method will use the clip rect that we started drawing the 604c3fedafc5f50100219449125a000e3138f6fb987Romain Guy * frame with. 6052b7028eabac80cec170572bc0e945a1d4224e595Romain Guy * This method needs to be invoked every time getTargetFbo() is 6062b7028eabac80cec170572bc0e945a1d4224e595Romain Guy * bound again. 6072b7028eabac80cec170572bc0e945a1d4224e595Romain Guy */ 60857b5268708c3b974296c7d4e58a02a957979224aRomain Guy void startTiling(const sp<Snapshot>& snapshot, bool opaque = false); 6092b7028eabac80cec170572bc0e945a1d4224e595Romain Guy 6102b7028eabac80cec170572bc0e945a1d4224e595Romain Guy /** 611c3fedafc5f50100219449125a000e3138f6fb987Romain Guy * Tells the GPU what part of the screen is about to be redrawn. 612c3fedafc5f50100219449125a000e3138f6fb987Romain Guy * This method needs to be invoked every time getTargetFbo() is 613c3fedafc5f50100219449125a000e3138f6fb987Romain Guy * bound again. 614c3fedafc5f50100219449125a000e3138f6fb987Romain Guy */ 615c3fedafc5f50100219449125a000e3138f6fb987Romain Guy void startTiling(const Rect& clip, int windowHeight, bool opaque = false); 616c3fedafc5f50100219449125a000e3138f6fb987Romain Guy 617c3fedafc5f50100219449125a000e3138f6fb987Romain Guy /** 6182b7028eabac80cec170572bc0e945a1d4224e595Romain Guy * Tells the GPU that we are done drawing the frame or that we 6192b7028eabac80cec170572bc0e945a1d4224e595Romain Guy * are switching to another render target. 6202b7028eabac80cec170572bc0e945a1d4224e595Romain Guy */ 6212b7028eabac80cec170572bc0e945a1d4224e595Romain Guy void endTiling(); 6222b7028eabac80cec170572bc0e945a1d4224e595Romain Guy 6232b7028eabac80cec170572bc0e945a1d4224e595Romain Guy /** 6245cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Saves the current state of the renderer as a new snapshot. 6255cbbce535744b89df5ecea95de21ee3733298260Romain Guy * The new snapshot is saved in mSnapshot and the previous snapshot 6265cbbce535744b89df5ecea95de21ee3733298260Romain Guy * is linked from mSnapshot->previous. 6275cbbce535744b89df5ecea95de21ee3733298260Romain Guy * 6288aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy * @param flags The save flags; see SkCanvas for more information 6298aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy * 6305cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @return The new save count. This value can be passed to #restoreToCount() 6315cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 6328aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy int saveSnapshot(int flags); 6335cbbce535744b89df5ecea95de21ee3733298260Romain Guy 6345cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 6355cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Restores the current snapshot; mSnapshot becomes mSnapshot->previous. 6365cbbce535744b89df5ecea95de21ee3733298260Romain Guy * 6372542d199745cdf3ec910b8e3e4cff5851ed24e9bRomain Guy * @return True if the clip was modified. 6385cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 639bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy bool restoreSnapshot(); 640bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 6415cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 6425cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Sets the clipping rectangle using glScissor. The clip is defined by 6435cbbce535744b89df5ecea95de21ee3733298260Romain Guy * the current snapshot's clipRect member. 6445cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 645bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy void setScissorFromClip(); 646bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 6475cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 6488ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy * Sets the clipping region using the stencil buffer. The clip region 6498ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy * is defined by the current snapshot's clipRegion member. 6508ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy */ 6518ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy void setStencilFromClip(); 6528ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy 6538ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy /** 654408eb12631376cbdc96803e918decf6ea804d346Chris Craik * Given the local bounds of the layer, calculates ... 655d90144db52c7297879b950cbbc85137ed123ab5bChris Craik */ 656d90144db52c7297879b950cbbc85137ed123ab5bChris Craik void calculateLayerBoundsAndClip(Rect& bounds, Rect& clip, bool fboLayer); 657d90144db52c7297879b950cbbc85137ed123ab5bChris Craik 658d90144db52c7297879b950cbbc85137ed123ab5bChris Craik /** 659408eb12631376cbdc96803e918decf6ea804d346Chris Craik * Given the local bounds + clip of the layer, updates current snapshot's empty/invisible 660408eb12631376cbdc96803e918decf6ea804d346Chris Craik */ 661408eb12631376cbdc96803e918decf6ea804d346Chris Craik void updateSnapshotIgnoreForLayer(const Rect& bounds, const Rect& clip, 662408eb12631376cbdc96803e918decf6ea804d346Chris Craik bool fboLayer, int alpha); 663408eb12631376cbdc96803e918decf6ea804d346Chris Craik 664408eb12631376cbdc96803e918decf6ea804d346Chris Craik /** 665d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * Creates a new layer stored in the specified snapshot. 666d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * 667d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param snapshot The snapshot associated with the new layer 668d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param left The left coordinate of the layer 669d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param top The top coordinate of the layer 670d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param right The right coordinate of the layer 671d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param bottom The bottom coordinate of the layer 672d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param alpha The translucency of the layer 673d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param mode The blending mode of the layer 674d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param flags The layer save flags 675d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * 676d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @return True if the layer was successfully created, false otherwise 677d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy */ 678d48885a6c8cd27a8a62552c33b5282e9882e19f6Chet Haase bool createLayer(float left, float top, float right, float bottom, 679e63f7c622a2086aefa80983c6f41b74fb166bb42Chris Craik int alpha, SkXfermode::Mode mode, int flags); 680d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy 681d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy /** 6825b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * Creates a new layer stored in the specified snapshot as an FBO. 6835b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * 6845b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * @param layer The layer to store as an FBO 6855b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * @param snapshot The snapshot associated with the new layer 6865b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * @param bounds The bounds of the layer 6875b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy */ 688e63f7c622a2086aefa80983c6f41b74fb166bb42Chris Craik bool createFboLayer(Layer* layer, Rect& bounds, Rect& clip); 6895b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy 6905b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy /** 6915b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * Compose the specified layer as a region. 6925b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * 6935b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * @param layer The layer to compose 6945b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * @param rect The layer's bounds 6955b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy */ 6965b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy void composeLayerRegion(Layer* layer, const Rect& rect); 6975b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy 6985b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy /** 6995b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * Compose the specified layer as a simple rectangle. 7005b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * 7015b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * @param layer The layer to compose 7025b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * @param rect The layer's bounds 7035b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * @param swap If true, the source and destination are swapped 7045b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy */ 7055b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy void composeLayerRect(Layer* layer, const Rect& rect, bool swap = false); 7065b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy 70754be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy /** 70854be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * Clears all the regions corresponding to the current list of layers. 70954be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * This method MUST be invoked before any drawing operation. 71054be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy */ 71154be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy void clearLayerRegions(); 71254be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy 71354be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy /** 714f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy * Mark the layer as dirty at the specified coordinates. The coordinates 715f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy * are transformed with the supplied matrix. 716f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy */ 717f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy void dirtyLayer(const float left, const float top, 718f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy const float right, const float bottom, const mat4 transform); 719f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy 720f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy /** 721f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy * Mark the layer as dirty at the specified coordinates. 722f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy */ 723f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy void dirtyLayer(const float left, const float top, 724f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy const float right, const float bottom); 725f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy 726f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy /** 7275cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Draws a colored rectangle with the specified color. The specified coordinates 728735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy * are transformed by the current snapshot's transform matrix unless specified 729735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy * otherwise. 7305cbbce535744b89df5ecea95de21ee3733298260Romain Guy * 7315cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param left The left coordinate of the rectangle 7325cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param top The top coordinate of the rectangle 7335cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param right The right coordinate of the rectangle 7345cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param bottom The bottom coordinate of the rectangle 7355cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param color The rectangle's ARGB color, defined as a packed 32 bits word 736026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * @param mode The Skia xfermode to use 7373d58c03de0d8877b36cdb78b0ca8b5cac7f600e2Romain Guy * @param ignoreTransform True if the current transform should be ignored 7385cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 739026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy void drawColorRect(float left, float top, float right, float bottom, 7401c740bce8a762f02b5283045a0e2de7c8fb41277Romain Guy int color, SkXfermode::Mode mode, bool ignoreTransform = false); 7415cbbce535744b89df5ecea95de21ee3733298260Romain Guy 74254be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy /** 743735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy * Draws a series of colored rectangles with the specified color. The specified 744735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy * coordinates are transformed by the current snapshot's transform matrix unless 745735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy * specified otherwise. 746735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy * 747735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy * @param rects A list of rectangles, 4 floats (left, top, right, bottom) 748735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy * per rectangle 749735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy * @param color The rectangles' ARGB color, defined as a packed 32 bits word 750735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy * @param mode The Skia xfermode to use 751735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy * @param ignoreTransform True if the current transform should be ignored 7528ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy * @param dirty True if calling this method should dirty the current layer 7533bbacf27c0be1bae4e4483577fc89ae3113abe5dRomain Guy * @param clip True if the rects should be clipped, false otherwise 754735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy */ 755735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy status_t drawColorRects(const float* rects, int count, int color, 7563bbacf27c0be1bae4e4483577fc89ae3113abe5dRomain Guy SkXfermode::Mode mode, bool ignoreTransform = false, 7573bbacf27c0be1bae4e4483577fc89ae3113abe5dRomain Guy bool dirty = true, bool clip = true); 758735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy 759735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy /** 76054be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * Draws the shape represented by the specified path texture. 76154be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * This method invokes drawPathTexture() but takes into account 76254be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * the extra left/top offset and the texture offset to correctly 76354be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * position the final shape. 76454be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * 76554be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * @param left The left coordinate of the shape to render 76654be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * @param top The top coordinate of the shape to render 76754be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * @param texture The texture reprsenting the shape 76854be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * @param paint The paint to draw the shape with 76954be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy */ 770486590963e2207d68eebd6944fec70d50d41116aChet Haase status_t drawShape(float left, float top, const PathTexture* texture, SkPaint* paint); 77154be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy 77254be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy /** 77354be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * Draws the specified texture as an alpha bitmap. Alpha bitmaps obey 77454be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * different compositing rules. 77554be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * 77654be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * @param texture The texture to draw with 77754be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * @param left The x coordinate of the bitmap 77854be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * @param top The y coordinate of the bitmap 77954be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * @param paint The paint to render with 78054be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy */ 781a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy void drawAlphaBitmap(Texture* texture, float left, float top, SkPaint* paint); 782a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy 78354be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy /** 78465cd612face362d054a85d0f7e5881c59cd523beChris Craik * Renders a strip of polygons with the specified paint, used for tessellated geometry. 78565cd612face362d054a85d0f7e5881c59cd523beChris Craik * 78665cd612face362d054a85d0f7e5881c59cd523beChris Craik * @param vertexBuffer The VertexBuffer to be drawn 78765cd612face362d054a85d0f7e5881c59cd523beChris Craik * @param paint The paint to render with 78865cd612face362d054a85d0f7e5881c59cd523beChris Craik * @param useOffset Offset the vertexBuffer (used in drawing non-AA lines) 78965cd612face362d054a85d0f7e5881c59cd523beChris Craik */ 79065cd612face362d054a85d0f7e5881c59cd523beChris Craik status_t drawVertexBuffer(const VertexBuffer& vertexBuffer, SkPaint* paint, 79165cd612face362d054a85d0f7e5881c59cd523beChris Craik bool useOffset = false); 79265cd612face362d054a85d0f7e5881c59cd523beChris Craik 79365cd612face362d054a85d0f7e5881c59cd523beChris Craik /** 794710f46d9d6a5bf9ea1c1833384caf61e1934124fChris Craik * Renders the convex hull defined by the specified path as a strip of polygons. 79554be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * 796710f46d9d6a5bf9ea1c1833384caf61e1934124fChris Craik * @param path The hull of the path to draw 797cb4d6009576cf08195dc23f341a3f4939c0878bbChris Craik * @param paint The paint to render with 79854be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy */ 79965cd612face362d054a85d0f7e5881c59cd523beChris Craik status_t drawConvexPath(const SkPath& path, SkPaint* paint); 800858aa93ddb6e69e0503382af63bb681b6728aef1Chet Haase 8015cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 8025cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Draws a textured rectangle with the specified texture. The specified coordinates 8035cbbce535744b89df5ecea95de21ee3733298260Romain Guy * are transformed by the current snapshot's transform matrix. 8045cbbce535744b89df5ecea95de21ee3733298260Romain Guy * 8055cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param left The left coordinate of the rectangle 8065cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param top The top coordinate of the rectangle 8075cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param right The right coordinate of the rectangle 8085cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param bottom The bottom coordinate of the rectangle 8095cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param texture The texture name to map onto the rectangle 8105cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param alpha An additional translucency parameter, between 0.0f and 1.0f 811d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param mode The blending mode 812c1396e93b6a5286a5183c00c781b62e940a12c1fRomain Guy * @param blend True if the texture contains an alpha channel 8135cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 814bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy void drawTextureRect(float left, float top, float right, float bottom, GLuint texture, 815a979474f15b454c8e2963f239a3770e200bb227cRomain Guy float alpha, SkXfermode::Mode mode, bool blend); 816c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy 817026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy /** 81882ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * Draws a textured rectangle with the specified texture. The specified coordinates 81982ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * are transformed by the current snapshot's transform matrix. 82082ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * 82182ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param left The left coordinate of the rectangle 82282ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param top The top coordinate of the rectangle 82382ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param right The right coordinate of the rectangle 82482ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param bottom The bottom coordinate of the rectangle 82582ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param texture The texture to use 82682ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param paint The paint containing the alpha, blending mode, etc. 82782ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy */ 828a979474f15b454c8e2963f239a3770e200bb227cRomain Guy void drawTextureRect(float left, float top, float right, float bottom, 8298164c2d338781c3a3c4a443941070dca5d88f2a7Romain Guy Texture* texture, SkPaint* paint); 83082ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy 83182ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy /** 83203750a067e818ca7fbd0f590e2ff6a8fded21e6cRomain Guy * Draws a textured mesh with the specified texture. If the indices are omitted, 83303750a067e818ca7fbd0f590e2ff6a8fded21e6cRomain Guy * the mesh is drawn as a simple quad. The mesh pointers become offsets when a 83403750a067e818ca7fbd0f590e2ff6a8fded21e6cRomain Guy * VBO is bound. 83582ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * 83682ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param left The left coordinate of the rectangle 83782ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param top The top coordinate of the rectangle 83882ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param right The right coordinate of the rectangle 83982ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param bottom The bottom coordinate of the rectangle 84082ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param texture The texture name to map onto the rectangle 84182ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param alpha An additional translucency parameter, between 0.0f and 1.0f 84282ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param mode The blending mode 84382ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param blend True if the texture contains an alpha channel 84482ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param vertices The vertices that define the mesh 84582ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param texCoords The texture coordinates of each vertex 84682ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * @param elementsCount The number of elements in the mesh, required by indices 847f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy * @param swapSrcDst Whether or not the src and dst blending operations should be swapped 848f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy * @param ignoreTransform True if the current transform should be ignored 84903750a067e818ca7fbd0f590e2ff6a8fded21e6cRomain Guy * @param vbo The VBO used to draw the mesh 8504063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * @param modelViewMode Defines whether the model view matrix should be scaled 8515b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy * @param dirty True if calling this method should dirty the current layer 852f7f93556c8fcc640ab5adef79d021a80a72a645aRomain Guy */ 853f7f93556c8fcc640ab5adef79d021a80a72a645aRomain Guy void drawTextureMesh(float left, float top, float right, float bottom, GLuint texture, 854a979474f15b454c8e2963f239a3770e200bb227cRomain Guy float alpha, SkXfermode::Mode mode, bool blend, 8556820ac8b14b4558f5d8b833dde80895306a3e137Romain Guy GLvoid* vertices, GLvoid* texCoords, GLenum drawMode, GLsizei elementsCount, 8565b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy bool swapSrcDst = false, bool ignoreTransform = false, GLuint vbo = 0, 8574063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik ModelViewMode modelViewMode = kModelViewMode_TranslateAndScale, bool dirty = true); 858f7f93556c8fcc640ab5adef79d021a80a72a645aRomain Guy 8593b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy void drawIndexedTextureMesh(float left, float top, float right, float bottom, GLuint texture, 8603b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy float alpha, SkXfermode::Mode mode, bool blend, 8613b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy GLvoid* vertices, GLvoid* texCoords, GLenum drawMode, GLsizei elementsCount, 8623b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy bool swapSrcDst = false, bool ignoreTransform = false, GLuint vbo = 0, 8634063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik ModelViewMode modelViewMode = kModelViewMode_TranslateAndScale, bool dirty = true); 8643b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy 865886b275e529e44a59c54b933453d9bc902973178Romain Guy void drawAlpha8TextureMesh(float left, float top, float right, float bottom, 866886b275e529e44a59c54b933453d9bc902973178Romain Guy GLuint texture, bool hasColor, int color, int alpha, SkXfermode::Mode mode, 867886b275e529e44a59c54b933453d9bc902973178Romain Guy GLvoid* vertices, GLvoid* texCoords, GLenum drawMode, GLsizei elementsCount, 8684063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik bool ignoreTransform, ModelViewMode modelViewMode = kModelViewMode_TranslateAndScale, 8694063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik bool dirty = true); 870886b275e529e44a59c54b933453d9bc902973178Romain Guy 871f7f93556c8fcc640ab5adef79d021a80a72a645aRomain Guy /** 872448455fe783b0a711340322dca272b8cc0ebe473Romain Guy * Draws the specified list of vertices as quads using indexed GL_TRIANGLES. 873448455fe783b0a711340322dca272b8cc0ebe473Romain Guy * If the number of vertices to draw exceeds the number of indices we have 874448455fe783b0a711340322dca272b8cc0ebe473Romain Guy * pre-allocated, this method will generate several glDrawElements() calls. 875448455fe783b0a711340322dca272b8cc0ebe473Romain Guy */ 8764063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik void issueIndexedQuadDraw(Vertex* mesh, GLsizei quadsCount); 877448455fe783b0a711340322dca272b8cc0ebe473Romain Guy 878448455fe783b0a711340322dca272b8cc0ebe473Romain Guy /** 8790a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * Draws text underline and strike-through if needed. 8800a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * 8810a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * @param text The text to decor 8820a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * @param bytesCount The number of bytes in the text 88341541825bc90dac740e424cdd41a8c997e15cdb7Chris Craik * @param totalAdvance The total advance in pixels, defines underline/strikethrough length 8840a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * @param x The x coordinate where the text will be drawn 8850a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * @param y The y coordinate where the text will be drawn 8860a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * @param paint The paint to draw the text with 8870a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy */ 888e63f7c622a2086aefa80983c6f41b74fb166bb42Chris Craik void drawTextDecorations(float totalAdvance, float x, float y, SkPaint* paint); 8891e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy 890416a847633680d94efb926837efdc18726d54918Raph Levien /** 891416a847633680d94efb926837efdc18726d54918Raph Levien * Draws shadow layer on text (with optional positions). 892416a847633680d94efb926837efdc18726d54918Raph Levien * 893416a847633680d94efb926837efdc18726d54918Raph Levien * @param paint The paint to draw the shadow with 894416a847633680d94efb926837efdc18726d54918Raph Levien * @param text The text to draw 895416a847633680d94efb926837efdc18726d54918Raph Levien * @param bytesCount The number of bytes in the text 896416a847633680d94efb926837efdc18726d54918Raph Levien * @param count The number of glyphs in the text 897416a847633680d94efb926837efdc18726d54918Raph Levien * @param positions The x, y positions of individual glyphs (or NULL) 898416a847633680d94efb926837efdc18726d54918Raph Levien * @param fontRenderer The font renderer object 899416a847633680d94efb926837efdc18726d54918Raph Levien * @param alpha The alpha value for drawing the shadow 900416a847633680d94efb926837efdc18726d54918Raph Levien * @param mode The xfermode for drawing the shadow 901416a847633680d94efb926837efdc18726d54918Raph Levien * @param x The x coordinate where the shadow will be drawn 902416a847633680d94efb926837efdc18726d54918Raph Levien * @param y The y coordinate where the shadow will be drawn 903416a847633680d94efb926837efdc18726d54918Raph Levien */ 904416a847633680d94efb926837efdc18726d54918Raph Levien void drawTextShadow(SkPaint* paint, const char* text, int bytesCount, int count, 905416a847633680d94efb926837efdc18726d54918Raph Levien const float* positions, FontRenderer& fontRenderer, int alpha, SkXfermode::Mode mode, 906416a847633680d94efb926837efdc18726d54918Raph Levien float x, float y); 907416a847633680d94efb926837efdc18726d54918Raph Levien 90854be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy /** 90954be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * Draws a path texture. Path textures are alpha8 bitmaps that need special 91054be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * compositing to apply colors/filters/etc. 91154be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * 91254be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * @param texture The texture to render 91354be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * @param x The x coordinate where the texture will be drawn 91454be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * @param y The y coordinate where the texture will be drawn 91554be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy * @param paint The paint to draw the texture with 91654be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy */ 917416a847633680d94efb926837efdc18726d54918Raph Levien void drawPathTexture(const PathTexture* texture, float x, float y, SkPaint* paint); 91801d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy 9191e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy /** 920ac670c0433d19397d4e36ced2110475b6f54fe26Romain Guy * Resets the texture coordinates stored in mMeshVertices. Setting the values 921026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * back to default is achieved by calling: 922026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * 9238ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy * resetDrawTextureTexCoords(0.0f, 0.0f, 1.0f, 1.0f); 924026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * 925026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * @param u1 The left coordinate of the texture 926026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * @param v1 The bottom coordinate of the texture 927026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * @param u2 The right coordinate of the texture 928026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * @param v2 The top coordinate of the texture 929026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy */ 930026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy void resetDrawTextureTexCoords(float u1, float v1, float u2, float v2); 931026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy 9328ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy /** 933768bffc9b814f6a1f7d9ff59d91285895c23bbe9Romain Guy * Returns true if the specified paint will draw invisible text. 934768bffc9b814f6a1f7d9ff59d91285895c23bbe9Romain Guy */ 935768bffc9b814f6a1f7d9ff59d91285895c23bbe9Romain Guy bool canSkipText(const SkPaint* paint) const; 936768bffc9b814f6a1f7d9ff59d91285895c23bbe9Romain Guy 937768bffc9b814f6a1f7d9ff59d91285895c23bbe9Romain Guy /** 938746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy * Binds the specified texture. The texture unit must have been selected 939746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy * prior to calling this method. 940a1db574036c9bc2d397b69f8200594027e1fff16Romain Guy */ 941746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy inline void bindTexture(GLuint texture) { 9428aa195d7081b889f3a7b1f426cbd8556377aae5eRomain Guy mCaches.bindTexture(texture); 943746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy } 944746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy 945746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy /** 946aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * Binds the specified EGLImage texture. The texture unit must have been selected 947aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * prior to calling this method. 948aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy */ 949aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy inline void bindExternalTexture(GLuint texture) { 9508aa195d7081b889f3a7b1f426cbd8556377aae5eRomain Guy mCaches.bindTexture(GL_TEXTURE_EXTERNAL_OES, texture); 951aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 952aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 953aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy /** 95482ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * Enable or disable blending as necessary. This function sets the appropriate 95582ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy * blend function based on the specified xfermode. 95682ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy */ 957f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy inline void chooseBlending(bool blend, SkXfermode::Mode mode, ProgramDescription& description, 958f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy bool swapSrcDst = false); 959a5aed0d58962a24c44728ffc46dc9e1ba2f9fda5Romain Guy 960f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy /** 961d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy * Use the specified program with the current GL context. If the program is already 962d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy * in use, it will not be bound again. If it is not in use, the current program is 963d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy * marked unused and the specified program becomes used and becomes the new 964d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy * current program. 9656926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy * 966d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy * @param program The program to use 967d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy * 968d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy * @return true If the specified program was already in use, false otherwise. 969260e102162322958cf17dbd895cd6bd30dc87e32Romain Guy */ 970889f8d1403761d5668115ced6cbb3f767cfe966dRomain Guy inline bool useProgram(Program* program); 971260e102162322958cf17dbd895cd6bd30dc87e32Romain Guy 972746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy /** 973746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy * Invoked before any drawing operation. This sets required state. 974746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy */ 97554be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy void setupDraw(bool clear = true); 97617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy 97770ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy /** 97870ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy * Various methods to setup OpenGL rendering. 97970ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy */ 98070ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy void setupDrawWithTexture(bool isAlpha8 = false); 981ff316ec7a76e52572a2e89b691e6b3bba0cafba3Romain Guy void setupDrawWithTextureAndColor(bool isAlpha8 = false); 982aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy void setupDrawWithExternalTexture(); 98315bc6437f8b4cf10dba55c7638d349e7b9563f4fRomain Guy void setupDrawNoTexture(); 984710f46d9d6a5bf9ea1c1833384caf61e1934124fChris Craik void setupDrawAA(); 9858d0d4783a0206c5884bf0b958d181f450ba5207dRomain Guy void setupDrawColor(int color, int alpha); 98670ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy void setupDrawColor(float r, float g, float b, float a); 98786568198f2c83d4ce5c4cd692eda074ba9de9ed2Romain Guy void setupDrawAlpha8Color(int color, int alpha); 9884121063313ac0d6f69f6253cac821d0c1c122086Romain Guy void setupDrawTextGamma(const SkPaint* paint); 98970ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy void setupDrawShader(); 99070ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy void setupDrawColorFilter(); 99170ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy void setupDrawBlending(SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode, 99270ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy bool swapSrcDst = false); 99370ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy void setupDrawBlending(bool blend = true, SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode, 99470ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy bool swapSrcDst = false); 99570ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy void setupDrawProgram(); 99670ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy void setupDrawDirtyRegionsDisabled(); 9974063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik 9984063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik /** 9994063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * Setup the current program matrices based upon the nature of the geometry. 10004063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * 10014063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * @param mode If kModelViewMode_Translate, the geometry must be translated by the left and top 10024063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * parameters. If kModelViewMode_TranslateAndScale, the geometry that exists in the (0,0, 1,1) 10034063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * space must be scaled up and translated to fill the quad provided in (l,t,r,b). These 10044063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * transformations are stored in the modelView matrix and uploaded to the shader. 10054063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * 10064063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * @param offset Set to true if the the matrix should be fudged (translated) slightly to disambiguate 10074063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * geometry pixel positioning. See Vertex::gGeometryFudgeFactor. 10084063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * 10094063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * @param ignoreTransform Set to true if l,t,r,b coordinates already in layer space, 10104063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * currentTransform() will be ignored. (e.g. when drawing clip in layer coordinates to stencil, 10114063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * or when simple translation has been extracted) 10124063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik */ 10134063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik void setupDrawModelView(ModelViewMode mode, bool offset, 10144063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik float left, float top, float right, float bottom, bool ignoreTransform = false); 101570ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy void setupDrawColorUniforms(); 101686568198f2c83d4ce5c4cd692eda074ba9de9ed2Romain Guy void setupDrawPureColorUniforms(); 101770ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy void setupDrawShaderUniforms(bool ignoreTransform = false); 101870ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy void setupDrawColorFilterUniforms(); 101970ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy void setupDrawSimpleMesh(); 102070ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy void setupDrawTexture(GLuint texture); 1021aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy void setupDrawExternalTexture(GLuint texture); 10228f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy void setupDrawTextureTransform(); 10238f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy void setupDrawTextureTransformUniforms(mat4& transform); 10244121063313ac0d6f69f6253cac821d0c1c122086Romain Guy void setupDrawTextGammaUniforms(); 10258d0d4783a0206c5884bf0b958d181f450ba5207dRomain Guy void setupDrawMesh(GLvoid* vertices, GLvoid* texCoords = NULL, GLuint vbo = 0); 1026ff316ec7a76e52572a2e89b691e6b3bba0cafba3Romain Guy void setupDrawMesh(GLvoid* vertices, GLvoid* texCoords, GLvoid* colors); 10273b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy void setupDrawMeshIndices(GLvoid* vertices, GLvoid* texCoords, GLuint vbo = 0); 1028448455fe783b0a711340322dca272b8cc0ebe473Romain Guy void setupDrawIndexedVertices(GLvoid* vertices); 1029f09ef51889f75289b041f9e9f949b7b82ed5b686Romain Guy void accountForClear(SkXfermode::Mode mode); 1030746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy 103111cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy bool updateLayer(Layer* layer, bool inFrame); 103211cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy void updateLayers(); 103396885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy void flushLayers(); 103411cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy 1035e63f7c622a2086aefa80983c6f41b74fb166bb42Chris Craik#if DEBUG_LAYERS_AS_REGIONS 103617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy /** 103717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * Renders the specified region as a series of rectangles. This method 103817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy * is used for debugging only. 103917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy */ 1040e63f7c622a2086aefa80983c6f41b74fb166bb42Chris Craik void drawRegionRectsDebug(const Region& region); 1041e63f7c622a2086aefa80983c6f41b74fb166bb42Chris Craik#endif 10423a3133d876caf60ebff2176ad75c3dcf0259148dRomain Guy 10438ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy /** 10448ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy * Renders the specified region as a series of rectangles. The region 10458ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy * must be in screen-space coordinates. 10468ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy */ 10478ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy void drawRegionRects(const SkRegion& region, int color, SkXfermode::Mode mode, 10488ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy bool dirty = false); 10498ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy 10508ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy /** 10518ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy * Draws the current clip region if any. Only when DEBUG_CLIP_REGIONS 10528ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy * is turned on. 10538ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy */ 10548ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy void debugClip(); 10558ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy 10567c450aaa3caac2a05fcb20a177483d0e92378426Romain Guy void debugOverdraw(bool enable, bool clear); 10577c450aaa3caac2a05fcb20a177483d0e92378426Romain Guy void renderOverdraw(); 105878dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy void countOverdraw(); 10597c450aaa3caac2a05fcb20a177483d0e92378426Romain Guy 1060746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy /** 1061746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy * Should be invoked every time the glScissor is modified. 1062746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy */ 1063746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy inline void dirtyClip() { 1064746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy mDirtyClip = true; 1065746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy } 1066746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy 10673b753829ae858d424fe109f714745379a6daf455Romain Guy inline mat4& currentTransform() const { 10683b753829ae858d424fe109f714745379a6daf455Romain Guy return *mSnapshot->transform; 10693b753829ae858d424fe109f714745379a6daf455Romain Guy } 10703b753829ae858d424fe109f714745379a6daf455Romain Guy 10713b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy inline const UvMapper& getMapper(const Texture* texture) { 10723b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy return texture && texture->uvMapper ? *texture->uvMapper : mUvMapper; 10733b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy } 10743b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy 10753b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy /** 10763b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy * Returns a texture object for the specified bitmap. The texture can 10773b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy * come from the texture cache or an atlas. If this method returns 10783b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy * NULL, the texture could not be found and/or allocated. 10793b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy */ 10803b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy Texture* getTexture(SkBitmap* bitmap); 10813b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy 1082bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy // Dimensions of the drawing surface 1083bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy int mWidth, mHeight; 1084bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 108585bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy // Matrix used for ortho projection in shaders 1086260e102162322958cf17dbd895cd6bd30dc87e32Romain Guy mat4 mOrthoMatrix; 1087bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 10884063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik /** 10894063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * Model-view matrix used to position/size objects 10904063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * 10914063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * Stores operation-local modifications to the draw matrix that aren't incorporated into the 10924063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * currentTransform(). 10934063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * 10944063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * If generated with kModelViewMode_Translate, the mModelView will reflect an x/y offset, 10954063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * e.g. the offset in drawLayer(). If generated with kModelViewMode_TranslateAndScale, 10964063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * mModelView will reflect a translation and scale, e.g. the translation and scale required to 10974063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * make VBO 0 (a rect of (0,0,1,1)) scaled to match the x,y offset, and width/height of a 10984063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * bitmap. 10994063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * 11004063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik * Used as input to SkiaShader transformation. 11014063a0e03ba2e354cc6d19c0ffc073fd5b8aa2caChris Craik */ 1102c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy mat4 mModelView; 1103c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy 1104bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy // Number of saved states 1105bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy int mSaveCount; 1106f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy // Base state 1107ae5575b3421c8fbe590ab046d7d5f2b36ecfd821Romain Guy sp<Snapshot> mFirstSnapshot; 1108bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy // Current state 1109bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy sp<Snapshot> mSnapshot; 11102b7028eabac80cec170572bc0e945a1d4224e595Romain Guy // State used to define the clipping region 11115f803623559aab395a29d575c37c4e39c23a4b4eChris Craik Rect mTilingClip; 111296885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy // Is the target render surface opaque 111396885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy bool mOpaque; 111496885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy // Is a frame currently being rendered 111596885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy bool mFrameStarted; 11169d5316e3f56d138504565ff311145ac01621dff4Romain Guy 1117026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy // Used to draw textured quads 1118ac670c0433d19397d4e36ced2110475b6f54fe26Romain Guy TextureVertex mMeshVertices[4]; 1119ce0537b80087a6225273040a987414b1dd081aa0Romain Guy 11203b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy // Default UV mapper 11213b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy const UvMapper mUvMapper; 11223b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy 1123c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik // shader, filters, and shadow 1124c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik DrawModifiers mDrawModifiers; 11255ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy SkPaint mFilteredPaint; 11265ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy 112782ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy // Various caches 1128fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy Caches& mCaches; 11293bbacf27c0be1bae4e4483577fc89ae3113abe5dRomain Guy Extensions& mExtensions; 11308694230ff25fa0a60e480d424843e56b718f0516Romain Guy 11318f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy // List of rectangles to clear after saveLayer() is invoked 113254be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy Vector<Rect*> mLayers; 11338f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy // List of functors to invoke after a frame is drawn 1134ba6be8a62dcdb3ffd210cd36b9af4e3a658eac47Romain Guy SortedVector<Functor*> mFunctors; 113511cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy // List of layers to update at the beginning of a frame 113611cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy Vector<Layer*> mLayerUpdates; 113754be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy 1138746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy // Indicates whether the clip must be restored 1139746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy bool mDirtyClip; 1140746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy 114170ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy // The following fields are used to setup drawing 114270ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy // Used to describe the shaders to generate 114370ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy ProgramDescription mDescription; 114470ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy // Color description 114570ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy bool mColorSet; 114670ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy float mColorA, mColorR, mColorG, mColorB; 114770ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy // Indicates that the shader should get a color 114870ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy bool mSetShaderColor; 114970ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy // Current texture unit 115070ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy GLuint mTextureUnit; 115170ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy // Track dirty regions, true by default 115270ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy bool mTrackDirtyRegions; 11532b7028eabac80cec170572bc0e945a1d4224e595Romain Guy // Indicate whether we are drawing an opaque frame 11542b7028eabac80cec170572bc0e945a1d4224e595Romain Guy bool mOpaqueFrame; 115570ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy 115687e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy // See PROPERTY_DISABLE_SCISSOR_OPTIMIZATION in 115787e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy // Properties.h 115887e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy bool mScissorOptimizationDisabled; 115987e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy 116054c1a64d5441a964890b44280e4457e11f4f924aRomain Guy // No-ops start/endTiling when set 116154c1a64d5441a964890b44280e4457e11f4f924aRomain Guy bool mSuppressTiling; 116254c1a64d5441a964890b44280e4457e11f4f924aRomain Guy 116378dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy // If true, this renderer will setup drawing to emulate 116478dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy // an increment stencil buffer in the color buffer 116578dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy bool mCountOverdraw; 116678dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy float mOverdraw; 116778dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy 1168ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy // Optional name of the renderer 1169ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy String8 mName; 1170ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy 1171b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy friend class DisplayListRenderer; 117296885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy friend class Layer; 1173257ae3502cfad43df681b1783528d645bdabc63fRomain Guy friend class TextSetupFunctor; 117403c00b5a135e68d22ca5bb829b899ebda6ed7e9dRomain Guy friend class DrawBitmapOp; 117503c00b5a135e68d22ca5bb829b899ebda6ed7e9dRomain Guy friend class DrawPatchOp; 1176b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy 1177bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy}; // class OpenGLRenderer 1178e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 11799d5316e3f56d138504565ff311145ac01621dff4Romain Guy}; // namespace uirenderer 1180e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy}; // namespace android 1181e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 11825b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#endif // ANDROID_HWUI_OPENGL_RENDERER_H 1183