Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "OpenGLRenderer" |
| 18 | |
Romain Guy | d5a85fb | 2012-03-13 11:18:20 -0700 | [diff] [blame] | 19 | #include <SkCamera.h> |
Romain Guy | c46d07a | 2013-03-15 19:06:39 -0700 | [diff] [blame] | 20 | #include <SkCanvas.h> |
Chet Haase | 9c1e23b | 2011-03-24 10:51:31 -0700 | [diff] [blame] | 21 | |
Romain Guy | 6554943 | 2012-03-26 16:45:05 -0700 | [diff] [blame] | 22 | #include <private/hwui/DrawGlInfo.h> |
| 23 | |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 24 | #include "DisplayList.h" |
Chris Craik | c3566d0 | 2013-02-04 16:16:33 -0800 | [diff] [blame] | 25 | #include "DeferredDisplayList.h" |
Chet Haase | 9c1e23b | 2011-03-24 10:51:31 -0700 | [diff] [blame] | 26 | #include "DisplayListLogBuffer.h" |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 27 | #include "DisplayListOp.h" |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 28 | #include "DisplayListRenderer.h" |
Chet Haase | 9c1e23b | 2011-03-24 10:51:31 -0700 | [diff] [blame] | 29 | #include "Caches.h" |
Romain Guy | 13631f3 | 2012-01-30 17:41:55 -0800 | [diff] [blame] | 30 | |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 31 | namespace android { |
| 32 | namespace uirenderer { |
| 33 | |
Romain Guy | 58ecc20 | 2012-09-07 11:58:36 -0700 | [diff] [blame] | 34 | DisplayListRenderer::DisplayListRenderer(): |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 35 | mCaches(Caches::getInstance()), mDisplayListData(new DisplayListData), |
Romain Guy | 54c1a64 | 2012-09-27 17:55:46 -0700 | [diff] [blame] | 36 | mTranslateX(0.0f), mTranslateY(0.0f), mHasTranslate(false), |
| 37 | mHasDrawOps(false), mFunctorCount(0) { |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | DisplayListRenderer::~DisplayListRenderer() { |
| 41 | reset(); |
| 42 | } |
| 43 | |
| 44 | void DisplayListRenderer::reset() { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 45 | mDisplayListData = new DisplayListData(); |
Romain Guy | 58ecc20 | 2012-09-07 11:58:36 -0700 | [diff] [blame] | 46 | mCaches.resourceCache.lock(); |
| 47 | |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 48 | for (size_t i = 0; i < mBitmapResources.size(); i++) { |
Romain Guy | 58ecc20 | 2012-09-07 11:58:36 -0700 | [diff] [blame] | 49 | mCaches.resourceCache.decrementRefcountLocked(mBitmapResources.itemAt(i)); |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 50 | } |
Chet Haase | d98aa2d | 2010-10-25 15:47:32 -0700 | [diff] [blame] | 51 | |
Romain Guy | 49c5fc0 | 2012-05-15 11:10:01 -0700 | [diff] [blame] | 52 | for (size_t i = 0; i < mOwnedBitmapResources.size(); i++) { |
Romain Guy | 58ecc20 | 2012-09-07 11:58:36 -0700 | [diff] [blame] | 53 | mCaches.resourceCache.decrementRefcountLocked(mOwnedBitmapResources.itemAt(i)); |
Romain Guy | 49c5fc0 | 2012-05-15 11:10:01 -0700 | [diff] [blame] | 54 | } |
Romain Guy | 49c5fc0 | 2012-05-15 11:10:01 -0700 | [diff] [blame] | 55 | |
Romain Guy | d586ad9 | 2011-06-22 16:14:36 -0700 | [diff] [blame] | 56 | for (size_t i = 0; i < mFilterResources.size(); i++) { |
Romain Guy | 58ecc20 | 2012-09-07 11:58:36 -0700 | [diff] [blame] | 57 | mCaches.resourceCache.decrementRefcountLocked(mFilterResources.itemAt(i)); |
Romain Guy | d586ad9 | 2011-06-22 16:14:36 -0700 | [diff] [blame] | 58 | } |
Romain Guy | d586ad9 | 2011-06-22 16:14:36 -0700 | [diff] [blame] | 59 | |
Romain Guy | e3b0a01 | 2013-06-26 15:45:41 -0700 | [diff] [blame] | 60 | for (size_t i = 0; i < mPatchResources.size(); i++) { |
| 61 | mCaches.resourceCache.decrementRefcountLocked(mPatchResources.itemAt(i)); |
| 62 | } |
| 63 | |
Romain Guy | 43ccf46 | 2011-01-14 18:51:01 -0800 | [diff] [blame] | 64 | for (size_t i = 0; i < mShaders.size(); i++) { |
Romain Guy | 58ecc20 | 2012-09-07 11:58:36 -0700 | [diff] [blame] | 65 | mCaches.resourceCache.decrementRefcountLocked(mShaders.itemAt(i)); |
Romain Guy | 43ccf46 | 2011-01-14 18:51:01 -0800 | [diff] [blame] | 66 | } |
Romain Guy | 43ccf46 | 2011-01-14 18:51:01 -0800 | [diff] [blame] | 67 | |
Chet Haase | d34dd71 | 2012-05-02 18:50:34 -0700 | [diff] [blame] | 68 | for (size_t i = 0; i < mSourcePaths.size(); i++) { |
Romain Guy | 58ecc20 | 2012-09-07 11:58:36 -0700 | [diff] [blame] | 69 | mCaches.resourceCache.decrementRefcountLocked(mSourcePaths.itemAt(i)); |
Chet Haase | d34dd71 | 2012-05-02 18:50:34 -0700 | [diff] [blame] | 70 | } |
Romain Guy | 58ecc20 | 2012-09-07 11:58:36 -0700 | [diff] [blame] | 71 | |
Chet Haase | 603f6de | 2012-09-14 15:31:25 -0700 | [diff] [blame] | 72 | for (size_t i = 0; i < mLayers.size(); i++) { |
| 73 | mCaches.resourceCache.decrementRefcountLocked(mLayers.itemAt(i)); |
| 74 | } |
| 75 | |
Romain Guy | 58ecc20 | 2012-09-07 11:58:36 -0700 | [diff] [blame] | 76 | mCaches.resourceCache.unlock(); |
| 77 | |
| 78 | mBitmapResources.clear(); |
| 79 | mOwnedBitmapResources.clear(); |
| 80 | mFilterResources.clear(); |
Romain Guy | e3b0a01 | 2013-06-26 15:45:41 -0700 | [diff] [blame] | 81 | mPatchResources.clear(); |
Chet Haase | d34dd71 | 2012-05-02 18:50:34 -0700 | [diff] [blame] | 82 | mSourcePaths.clear(); |
| 83 | |
Romain Guy | 58ecc20 | 2012-09-07 11:58:36 -0700 | [diff] [blame] | 84 | mShaders.clear(); |
| 85 | mShaderMap.clear(); |
| 86 | |
Romain Guy | 43ccf46 | 2011-01-14 18:51:01 -0800 | [diff] [blame] | 87 | mPaints.clear(); |
| 88 | mPaintMap.clear(); |
Romain Guy | d586ad9 | 2011-06-22 16:14:36 -0700 | [diff] [blame] | 89 | |
Romain Guy | 735738c | 2012-12-03 12:34:51 -0800 | [diff] [blame] | 90 | mRegions.clear(); |
| 91 | mRegionMap.clear(); |
| 92 | |
Romain Guy | 2fc941e | 2011-02-03 15:06:05 -0800 | [diff] [blame] | 93 | mPaths.clear(); |
| 94 | mPathMap.clear(); |
Romain Guy | d586ad9 | 2011-06-22 16:14:36 -0700 | [diff] [blame] | 95 | |
Chet Haase | d98aa2d | 2010-10-25 15:47:32 -0700 | [diff] [blame] | 96 | mMatrices.clear(); |
Romain Guy | 04c9d8c | 2011-08-25 14:01:48 -0700 | [diff] [blame] | 97 | |
Chet Haase | 603f6de | 2012-09-14 15:31:25 -0700 | [diff] [blame] | 98 | mLayers.clear(); |
| 99 | |
Romain Guy | 04c9d8c | 2011-08-25 14:01:48 -0700 | [diff] [blame] | 100 | mHasDrawOps = false; |
Romain Guy | 54c1a64 | 2012-09-27 17:55:46 -0700 | [diff] [blame] | 101 | mFunctorCount = 0; |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | /////////////////////////////////////////////////////////////////////////////// |
| 105 | // Operations |
| 106 | /////////////////////////////////////////////////////////////////////////////// |
| 107 | |
Jeff Brown | 162a021 | 2011-07-21 17:02:54 -0700 | [diff] [blame] | 108 | DisplayList* DisplayListRenderer::getDisplayList(DisplayList* displayList) { |
| 109 | if (!displayList) { |
| 110 | displayList = new DisplayList(*this); |
Chet Haase | 5977baa | 2011-01-05 18:01:22 -0800 | [diff] [blame] | 111 | } else { |
Jeff Brown | 162a021 | 2011-07-21 17:02:54 -0700 | [diff] [blame] | 112 | displayList->initFromDisplayListRenderer(*this, true); |
Chet Haase | 5977baa | 2011-01-05 18:01:22 -0800 | [diff] [blame] | 113 | } |
Romain Guy | 04c9d8c | 2011-08-25 14:01:48 -0700 | [diff] [blame] | 114 | displayList->setRenderable(mHasDrawOps); |
Jeff Brown | 162a021 | 2011-07-21 17:02:54 -0700 | [diff] [blame] | 115 | return displayList; |
Chet Haase | 5977baa | 2011-01-05 18:01:22 -0800 | [diff] [blame] | 116 | } |
| 117 | |
Romain Guy | 49c5fc0 | 2012-05-15 11:10:01 -0700 | [diff] [blame] | 118 | bool DisplayListRenderer::isDeferred() { |
| 119 | return true; |
| 120 | } |
| 121 | |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 122 | void DisplayListRenderer::setViewport(int width, int height) { |
| 123 | mOrthoMatrix.loadOrtho(0, width, height, 0, -1, 1); |
| 124 | |
| 125 | mWidth = width; |
| 126 | mHeight = height; |
| 127 | } |
| 128 | |
Romain Guy | 7c25aab | 2012-10-18 15:05:02 -0700 | [diff] [blame] | 129 | status_t DisplayListRenderer::prepareDirty(float left, float top, |
Romain Guy | 7d7b549 | 2011-01-24 16:33:45 -0800 | [diff] [blame] | 130 | float right, float bottom, bool opaque) { |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 131 | mSnapshot = new Snapshot(mFirstSnapshot, |
| 132 | SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag); |
| 133 | mSaveCount = 1; |
Romain Guy | 45e4c3d | 2012-09-11 17:17:07 -0700 | [diff] [blame] | 134 | |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 135 | mSnapshot->setClip(0.0f, 0.0f, mWidth, mHeight); |
Romain Guy | 45e4c3d | 2012-09-11 17:17:07 -0700 | [diff] [blame] | 136 | mDirtyClip = opaque; |
| 137 | |
Romain Guy | 27454a4 | 2011-01-23 12:01:41 -0800 | [diff] [blame] | 138 | mRestoreSaveCount = -1; |
Romain Guy | 45e4c3d | 2012-09-11 17:17:07 -0700 | [diff] [blame] | 139 | |
Chet Haase | 44b2fe3 | 2012-06-06 19:03:58 -0700 | [diff] [blame] | 140 | return DrawGlInfo::kStatusDone; // No invalidate needed at record-time |
Romain Guy | 27454a4 | 2011-01-23 12:01:41 -0800 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | void DisplayListRenderer::finish() { |
| 144 | insertRestoreToCount(); |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 145 | insertTranslate(); |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 146 | } |
| 147 | |
Chet Haase | daf98e9 | 2011-01-10 14:10:36 -0800 | [diff] [blame] | 148 | void DisplayListRenderer::interrupt() { |
Chet Haase | daf98e9 | 2011-01-10 14:10:36 -0800 | [diff] [blame] | 149 | } |
Romain Guy | 2b1847e | 2011-01-26 13:43:01 -0800 | [diff] [blame] | 150 | |
Chet Haase | daf98e9 | 2011-01-10 14:10:36 -0800 | [diff] [blame] | 151 | void DisplayListRenderer::resume() { |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 152 | } |
| 153 | |
Romain Guy | 6554943 | 2012-03-26 16:45:05 -0700 | [diff] [blame] | 154 | status_t DisplayListRenderer::callDrawGLFunction(Functor *functor, Rect& dirty) { |
Romain Guy | cabfcc1 | 2011-03-07 18:06:46 -0800 | [diff] [blame] | 155 | // Ignore dirty during recording, it matters only when we replay |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 156 | addDrawOp(new (alloc()) DrawFunctorOp(functor)); |
Romain Guy | 54c1a64 | 2012-09-27 17:55:46 -0700 | [diff] [blame] | 157 | mFunctorCount++; |
Romain Guy | 6554943 | 2012-03-26 16:45:05 -0700 | [diff] [blame] | 158 | return DrawGlInfo::kStatusDone; // No invalidate needed at record-time |
Chet Haase | daf98e9 | 2011-01-10 14:10:36 -0800 | [diff] [blame] | 159 | } |
| 160 | |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 161 | int DisplayListRenderer::save(int flags) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 162 | addStateOp(new (alloc()) SaveOp(flags)); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 163 | return OpenGLRenderer::save(flags); |
| 164 | } |
| 165 | |
| 166 | void DisplayListRenderer::restore() { |
Romain Guy | 04c9d8c | 2011-08-25 14:01:48 -0700 | [diff] [blame] | 167 | if (mRestoreSaveCount < 0) { |
Romain Guy | 33f6beb | 2012-02-16 19:24:51 -0800 | [diff] [blame] | 168 | restoreToCount(getSaveCount() - 1); |
| 169 | return; |
Romain Guy | 04c9d8c | 2011-08-25 14:01:48 -0700 | [diff] [blame] | 170 | } |
Romain Guy | 33f6beb | 2012-02-16 19:24:51 -0800 | [diff] [blame] | 171 | |
| 172 | mRestoreSaveCount--; |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 173 | insertTranslate(); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 174 | OpenGLRenderer::restore(); |
| 175 | } |
| 176 | |
| 177 | void DisplayListRenderer::restoreToCount(int saveCount) { |
Romain Guy | 27454a4 | 2011-01-23 12:01:41 -0800 | [diff] [blame] | 178 | mRestoreSaveCount = saveCount; |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 179 | insertTranslate(); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 180 | OpenGLRenderer::restoreToCount(saveCount); |
| 181 | } |
| 182 | |
| 183 | int DisplayListRenderer::saveLayer(float left, float top, float right, float bottom, |
Chris Craik | ff78583 | 2013-03-08 13:12:16 -0800 | [diff] [blame] | 184 | int alpha, SkXfermode::Mode mode, int flags) { |
| 185 | addStateOp(new (alloc()) SaveLayerOp(left, top, right, bottom, alpha, mode, flags)); |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 186 | return OpenGLRenderer::save(flags); |
| 187 | } |
| 188 | |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 189 | void DisplayListRenderer::translate(float dx, float dy) { |
Romain Guy | 33f6beb | 2012-02-16 19:24:51 -0800 | [diff] [blame] | 190 | mHasTranslate = true; |
| 191 | mTranslateX += dx; |
| 192 | mTranslateY += dy; |
| 193 | insertRestoreToCount(); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 194 | OpenGLRenderer::translate(dx, dy); |
| 195 | } |
| 196 | |
| 197 | void DisplayListRenderer::rotate(float degrees) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 198 | addStateOp(new (alloc()) RotateOp(degrees)); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 199 | OpenGLRenderer::rotate(degrees); |
| 200 | } |
| 201 | |
| 202 | void DisplayListRenderer::scale(float sx, float sy) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 203 | addStateOp(new (alloc()) ScaleOp(sx, sy)); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 204 | OpenGLRenderer::scale(sx, sy); |
| 205 | } |
| 206 | |
Romain Guy | 807daf7 | 2011-01-18 11:19:19 -0800 | [diff] [blame] | 207 | void DisplayListRenderer::skew(float sx, float sy) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 208 | addStateOp(new (alloc()) SkewOp(sx, sy)); |
Romain Guy | 807daf7 | 2011-01-18 11:19:19 -0800 | [diff] [blame] | 209 | OpenGLRenderer::skew(sx, sy); |
| 210 | } |
| 211 | |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 212 | void DisplayListRenderer::setMatrix(SkMatrix* matrix) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 213 | matrix = refMatrix(matrix); |
| 214 | addStateOp(new (alloc()) SetMatrixOp(matrix)); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 215 | OpenGLRenderer::setMatrix(matrix); |
| 216 | } |
| 217 | |
| 218 | void DisplayListRenderer::concatMatrix(SkMatrix* matrix) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 219 | matrix = refMatrix(matrix); |
| 220 | addStateOp(new (alloc()) ConcatMatrixOp(matrix)); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 221 | OpenGLRenderer::concatMatrix(matrix); |
| 222 | } |
| 223 | |
| 224 | bool DisplayListRenderer::clipRect(float left, float top, float right, float bottom, |
| 225 | SkRegion::Op op) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 226 | addStateOp(new (alloc()) ClipRectOp(left, top, right, bottom, op)); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 227 | return OpenGLRenderer::clipRect(left, top, right, bottom, op); |
| 228 | } |
| 229 | |
Romain Guy | 735738c | 2012-12-03 12:34:51 -0800 | [diff] [blame] | 230 | bool DisplayListRenderer::clipPath(SkPath* path, SkRegion::Op op) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 231 | path = refPath(path); |
| 232 | addStateOp(new (alloc()) ClipPathOp(path, op)); |
Romain Guy | 735738c | 2012-12-03 12:34:51 -0800 | [diff] [blame] | 233 | return OpenGLRenderer::clipPath(path, op); |
| 234 | } |
| 235 | |
| 236 | bool DisplayListRenderer::clipRegion(SkRegion* region, SkRegion::Op op) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 237 | region = refRegion(region); |
| 238 | addStateOp(new (alloc()) ClipRegionOp(region, op)); |
Romain Guy | 735738c | 2012-12-03 12:34:51 -0800 | [diff] [blame] | 239 | return OpenGLRenderer::clipRegion(region, op); |
| 240 | } |
| 241 | |
Romain Guy | 6554943 | 2012-03-26 16:45:05 -0700 | [diff] [blame] | 242 | status_t DisplayListRenderer::drawDisplayList(DisplayList* displayList, |
Chris Craik | c3566d0 | 2013-02-04 16:16:33 -0800 | [diff] [blame] | 243 | Rect& dirty, int32_t flags) { |
Romain Guy | cabfcc1 | 2011-03-07 18:06:46 -0800 | [diff] [blame] | 244 | // dirty is an out parameter and should not be recorded, |
| 245 | // it matters only when replaying the display list |
Chet Haase | b85967b | 2012-03-26 14:37:51 -0700 | [diff] [blame] | 246 | |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 247 | // TODO: To be safe, the display list should be ref-counted in the |
| 248 | // resources cache, but we rely on the caller (UI toolkit) to |
| 249 | // do the right thing for now |
| 250 | |
| 251 | addDrawOp(new (alloc()) DrawDisplayListOp(displayList, flags)); |
Romain Guy | 6554943 | 2012-03-26 16:45:05 -0700 | [diff] [blame] | 252 | return DrawGlInfo::kStatusDone; |
Romain Guy | 0fe478e | 2010-11-08 12:08:41 -0800 | [diff] [blame] | 253 | } |
| 254 | |
Chris Craik | a08f95c | 2013-03-15 17:24:33 -0700 | [diff] [blame] | 255 | status_t DisplayListRenderer::drawLayer(Layer* layer, float x, float y) { |
Romain Guy | ce4a7df | 2013-03-28 11:32:33 -0700 | [diff] [blame] | 256 | layer = refLayer(layer); |
Chris Craik | a08f95c | 2013-03-15 17:24:33 -0700 | [diff] [blame] | 257 | addDrawOp(new (alloc()) DrawLayerOp(layer, x, y)); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 258 | return DrawGlInfo::kStatusDone; |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 259 | } |
| 260 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 261 | status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 262 | bitmap = refBitmap(bitmap); |
| 263 | paint = refPaint(paint); |
| 264 | |
Romain Guy | 55b6f95 | 2013-06-27 15:27:09 -0700 | [diff] [blame] | 265 | addDrawOp(new (alloc()) DrawBitmapOp(bitmap, left, top, paint)); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 266 | return DrawGlInfo::kStatusDone; |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 267 | } |
| 268 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 269 | status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 270 | bitmap = refBitmap(bitmap); |
| 271 | matrix = refMatrix(matrix); |
| 272 | paint = refPaint(paint); |
Romain Guy | 33f6beb | 2012-02-16 19:24:51 -0800 | [diff] [blame] | 273 | |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 274 | addDrawOp(new (alloc()) DrawBitmapMatrixOp(bitmap, matrix, paint)); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 275 | return DrawGlInfo::kStatusDone; |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 276 | } |
| 277 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 278 | status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop, |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 279 | float srcRight, float srcBottom, float dstLeft, float dstTop, |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 280 | float dstRight, float dstBottom, SkPaint* paint) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 281 | bitmap = refBitmap(bitmap); |
| 282 | paint = refPaint(paint); |
| 283 | |
Chris Craik | 527a3aa | 2013-03-04 10:19:31 -0800 | [diff] [blame] | 284 | if (srcLeft == 0 && srcTop == 0 && |
| 285 | srcRight == bitmap->width() && srcBottom == bitmap->height() && |
| 286 | (srcBottom - srcTop == dstBottom - dstTop) && |
| 287 | (srcRight - srcLeft == dstRight - dstLeft)) { |
| 288 | // transform simple rect to rect drawing case into position bitmap ops, since they merge |
Romain Guy | 55b6f95 | 2013-06-27 15:27:09 -0700 | [diff] [blame] | 289 | addDrawOp(new (alloc()) DrawBitmapOp(bitmap, dstLeft, dstTop, paint)); |
Chris Craik | 527a3aa | 2013-03-04 10:19:31 -0800 | [diff] [blame] | 290 | return DrawGlInfo::kStatusDone; |
| 291 | } |
| 292 | |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 293 | addDrawOp(new (alloc()) DrawBitmapRectOp(bitmap, |
| 294 | srcLeft, srcTop, srcRight, srcBottom, |
| 295 | dstLeft, dstTop, dstRight, dstBottom, paint)); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 296 | return DrawGlInfo::kStatusDone; |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 299 | status_t DisplayListRenderer::drawBitmapData(SkBitmap* bitmap, float left, float top, |
| 300 | SkPaint* paint) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 301 | bitmap = refBitmapData(bitmap); |
| 302 | paint = refPaint(paint); |
| 303 | |
| 304 | addDrawOp(new (alloc()) DrawBitmapDataOp(bitmap, left, top, paint)); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 305 | return DrawGlInfo::kStatusDone; |
Romain Guy | e651cc6 | 2012-05-14 19:44:40 -0700 | [diff] [blame] | 306 | } |
| 307 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 308 | status_t DisplayListRenderer::drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight, |
Romain Guy | 5a7b466 | 2011-01-20 19:09:30 -0800 | [diff] [blame] | 309 | float* vertices, int* colors, SkPaint* paint) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 310 | int count = (meshWidth + 1) * (meshHeight + 1) * 2; |
| 311 | bitmap = refBitmap(bitmap); |
| 312 | vertices = refBuffer<float>(vertices, count); |
| 313 | paint = refPaint(paint); |
| 314 | colors = refBuffer<int>(colors, count); |
| 315 | |
| 316 | addDrawOp(new (alloc()) DrawBitmapMeshOp(bitmap, meshWidth, meshHeight, |
| 317 | vertices, colors, paint)); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 318 | return DrawGlInfo::kStatusDone; |
Romain Guy | 5a7b466 | 2011-01-20 19:09:30 -0800 | [diff] [blame] | 319 | } |
| 320 | |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 321 | status_t DisplayListRenderer::drawPatch(SkBitmap* bitmap, Res_png_9patch* patch, |
| 322 | float left, float top, float right, float bottom, SkPaint* paint) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 323 | bitmap = refBitmap(bitmap); |
Romain Guy | e3b0a01 | 2013-06-26 15:45:41 -0700 | [diff] [blame] | 324 | patch = refPatch(patch); |
Romain Guy | 16ea8d3 | 2013-06-21 11:35:52 -0700 | [diff] [blame] | 325 | paint = refPaint(paint); |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 326 | |
Romain Guy | 03c00b5 | 2013-06-20 18:30:28 -0700 | [diff] [blame] | 327 | addDrawOp(new (alloc()) DrawPatchOp(bitmap, patch, left, top, right, bottom, paint)); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 328 | return DrawGlInfo::kStatusDone; |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 329 | } |
| 330 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 331 | status_t DisplayListRenderer::drawColor(int color, SkXfermode::Mode mode) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 332 | addDrawOp(new (alloc()) DrawColorOp(color, mode)); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 333 | return DrawGlInfo::kStatusDone; |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 334 | } |
| 335 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 336 | status_t DisplayListRenderer::drawRect(float left, float top, float right, float bottom, |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 337 | SkPaint* paint) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 338 | paint = refPaint(paint); |
| 339 | addDrawOp(new (alloc()) DrawRectOp(left, top, right, bottom, paint)); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 340 | return DrawGlInfo::kStatusDone; |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 341 | } |
| 342 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 343 | status_t DisplayListRenderer::drawRoundRect(float left, float top, float right, float bottom, |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 344 | float rx, float ry, SkPaint* paint) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 345 | paint = refPaint(paint); |
| 346 | addDrawOp(new (alloc()) DrawRoundRectOp(left, top, right, bottom, rx, ry, paint)); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 347 | return DrawGlInfo::kStatusDone; |
Romain Guy | 01d58e4 | 2011-01-19 21:54:02 -0800 | [diff] [blame] | 348 | } |
| 349 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 350 | status_t DisplayListRenderer::drawCircle(float x, float y, float radius, SkPaint* paint) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 351 | paint = refPaint(paint); |
| 352 | addDrawOp(new (alloc()) DrawCircleOp(x, y, radius, paint)); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 353 | return DrawGlInfo::kStatusDone; |
Romain Guy | 01d58e4 | 2011-01-19 21:54:02 -0800 | [diff] [blame] | 354 | } |
| 355 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 356 | status_t DisplayListRenderer::drawOval(float left, float top, float right, float bottom, |
Romain Guy | c1cd9ba3 | 2011-01-23 14:18:41 -0800 | [diff] [blame] | 357 | SkPaint* paint) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 358 | paint = refPaint(paint); |
| 359 | addDrawOp(new (alloc()) DrawOvalOp(left, top, right, bottom, paint)); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 360 | return DrawGlInfo::kStatusDone; |
Romain Guy | c1cd9ba3 | 2011-01-23 14:18:41 -0800 | [diff] [blame] | 361 | } |
| 362 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 363 | status_t DisplayListRenderer::drawArc(float left, float top, float right, float bottom, |
Romain Guy | 8b2f526 | 2011-01-23 16:15:02 -0800 | [diff] [blame] | 364 | float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 365 | paint = refPaint(paint); |
| 366 | addDrawOp(new (alloc()) DrawArcOp(left, top, right, bottom, |
| 367 | startAngle, sweepAngle, useCenter, paint)); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 368 | return DrawGlInfo::kStatusDone; |
Romain Guy | 8b2f526 | 2011-01-23 16:15:02 -0800 | [diff] [blame] | 369 | } |
| 370 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 371 | status_t DisplayListRenderer::drawPath(SkPath* path, SkPaint* paint) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 372 | path = refPath(path); |
| 373 | paint = refPaint(paint); |
Romain Guy | 33f6beb | 2012-02-16 19:24:51 -0800 | [diff] [blame] | 374 | |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 375 | addDrawOp(new (alloc()) DrawPathOp(path, paint)); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 376 | return DrawGlInfo::kStatusDone; |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 377 | } |
| 378 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 379 | status_t DisplayListRenderer::drawLines(float* points, int count, SkPaint* paint) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 380 | points = refBuffer<float>(points, count); |
| 381 | paint = refPaint(paint); |
| 382 | |
| 383 | addDrawOp(new (alloc()) DrawLinesOp(points, count, paint)); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 384 | return DrawGlInfo::kStatusDone; |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 385 | } |
| 386 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 387 | status_t DisplayListRenderer::drawPoints(float* points, int count, SkPaint* paint) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 388 | points = refBuffer<float>(points, count); |
| 389 | paint = refPaint(paint); |
| 390 | |
| 391 | addDrawOp(new (alloc()) DrawPointsOp(points, count, paint)); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 392 | return DrawGlInfo::kStatusDone; |
Romain Guy | ed6fcb0 | 2011-03-21 13:11:28 -0700 | [diff] [blame] | 393 | } |
| 394 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 395 | status_t DisplayListRenderer::drawTextOnPath(const char* text, int bytesCount, int count, |
Romain Guy | 325740f | 2012-02-24 16:48:34 -0800 | [diff] [blame] | 396 | SkPath* path, float hOffset, float vOffset, SkPaint* paint) { |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 397 | if (!text || count <= 0) return DrawGlInfo::kStatusDone; |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 398 | |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 399 | text = refText(text, bytesCount); |
| 400 | path = refPath(path); |
| 401 | paint = refPaint(paint); |
| 402 | |
| 403 | DrawOp* op = new (alloc()) DrawTextOnPathOp(text, bytesCount, count, path, |
| 404 | hOffset, vOffset, paint); |
Romain Guy | 0f66753 | 2013-03-01 14:31:04 -0800 | [diff] [blame] | 405 | addDrawOp(op); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 406 | return DrawGlInfo::kStatusDone; |
Romain Guy | 325740f | 2012-02-24 16:48:34 -0800 | [diff] [blame] | 407 | } |
| 408 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 409 | status_t DisplayListRenderer::drawPosText(const char* text, int bytesCount, int count, |
Romain Guy | eb9a536 | 2012-01-17 17:39:26 -0800 | [diff] [blame] | 410 | const float* positions, SkPaint* paint) { |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 411 | if (!text || count <= 0) return DrawGlInfo::kStatusDone; |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 412 | |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 413 | text = refText(text, bytesCount); |
| 414 | positions = refBuffer<float>(positions, count * 2); |
| 415 | paint = refPaint(paint); |
| 416 | |
| 417 | DrawOp* op = new (alloc()) DrawPosTextOp(text, bytesCount, count, positions, paint); |
Romain Guy | 0f66753 | 2013-03-01 14:31:04 -0800 | [diff] [blame] | 418 | addDrawOp(op); |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 419 | return DrawGlInfo::kStatusDone; |
Romain Guy | eb9a536 | 2012-01-17 17:39:26 -0800 | [diff] [blame] | 420 | } |
| 421 | |
Romain Guy | c252595 | 2012-07-27 16:41:22 -0700 | [diff] [blame] | 422 | status_t DisplayListRenderer::drawText(const char* text, int bytesCount, int count, |
Chris Craik | 527a3aa | 2013-03-04 10:19:31 -0800 | [diff] [blame] | 423 | float x, float y, const float* positions, SkPaint* paint, |
Chris Craik | 4154182 | 2013-05-03 16:35:54 -0700 | [diff] [blame] | 424 | float totalAdvance, const Rect& bounds, DrawOpMode drawOpMode) { |
Chris Craik | 527a3aa | 2013-03-04 10:19:31 -0800 | [diff] [blame] | 425 | |
Raph Levien | 996e57c | 2012-07-23 15:22:52 -0700 | [diff] [blame] | 426 | if (!text || count <= 0) return DrawGlInfo::kStatusDone; |
| 427 | |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 428 | text = refText(text, bytesCount); |
| 429 | positions = refBuffer<float>(positions, count * 2); |
| 430 | paint = refPaint(paint); |
Raph Levien | 996e57c | 2012-07-23 15:22:52 -0700 | [diff] [blame] | 431 | |
Chris Craik | 4154182 | 2013-05-03 16:35:54 -0700 | [diff] [blame] | 432 | DrawOp* op = new (alloc()) DrawTextOp(text, bytesCount, count, |
| 433 | x, y, positions, paint, totalAdvance, bounds); |
Romain Guy | 0f66753 | 2013-03-01 14:31:04 -0800 | [diff] [blame] | 434 | addDrawOp(op); |
Raph Levien | 996e57c | 2012-07-23 15:22:52 -0700 | [diff] [blame] | 435 | return DrawGlInfo::kStatusDone; |
| 436 | } |
| 437 | |
Romain Guy | 672433d | 2013-01-04 19:05:13 -0800 | [diff] [blame] | 438 | status_t DisplayListRenderer::drawRects(const float* rects, int count, SkPaint* paint) { |
| 439 | if (count <= 0) return DrawGlInfo::kStatusDone; |
| 440 | |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 441 | rects = refBuffer<float>(rects, count); |
| 442 | paint = refPaint(paint); |
| 443 | addDrawOp(new (alloc()) DrawRectsOp(rects, count, paint)); |
Romain Guy | 672433d | 2013-01-04 19:05:13 -0800 | [diff] [blame] | 444 | return DrawGlInfo::kStatusDone; |
| 445 | } |
| 446 | |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 447 | void DisplayListRenderer::resetShader() { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 448 | addStateOp(new (alloc()) ResetShaderOp()); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | void DisplayListRenderer::setupShader(SkiaShader* shader) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 452 | shader = refShader(shader); |
| 453 | addStateOp(new (alloc()) SetupShaderOp(shader)); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | void DisplayListRenderer::resetColorFilter() { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 457 | addStateOp(new (alloc()) ResetColorFilterOp()); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | void DisplayListRenderer::setupColorFilter(SkiaColorFilter* filter) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 461 | filter = refColorFilter(filter); |
| 462 | addStateOp(new (alloc()) SetupColorFilterOp(filter)); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | void DisplayListRenderer::resetShadow() { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 466 | addStateOp(new (alloc()) ResetShadowOp()); |
Romain Guy | 9b5a1a2 | 2013-08-09 14:06:29 -0700 | [diff] [blame] | 467 | OpenGLRenderer::resetShadow(); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 468 | } |
| 469 | |
| 470 | void DisplayListRenderer::setupShadow(float radius, float dx, float dy, int color) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 471 | addStateOp(new (alloc()) SetupShadowOp(radius, dx, dy, color)); |
Romain Guy | 9b5a1a2 | 2013-08-09 14:06:29 -0700 | [diff] [blame] | 472 | OpenGLRenderer::setupShadow(radius, dx, dy, color); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 473 | } |
| 474 | |
Romain Guy | 5ff9df6 | 2012-01-23 17:09:05 -0800 | [diff] [blame] | 475 | void DisplayListRenderer::resetPaintFilter() { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 476 | addStateOp(new (alloc()) ResetPaintFilterOp()); |
Romain Guy | 5ff9df6 | 2012-01-23 17:09:05 -0800 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | void DisplayListRenderer::setupPaintFilter(int clearBits, int setBits) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 480 | addStateOp(new (alloc()) SetupPaintFilterOp(clearBits, setBits)); |
| 481 | } |
| 482 | |
| 483 | void DisplayListRenderer::insertRestoreToCount() { |
| 484 | if (mRestoreSaveCount >= 0) { |
| 485 | DisplayListOp* op = new (alloc()) RestoreToCountOp(mRestoreSaveCount); |
| 486 | mDisplayListData->displayListOps.add(op); |
| 487 | mRestoreSaveCount = -1; |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | void DisplayListRenderer::insertTranslate() { |
| 492 | if (mHasTranslate) { |
| 493 | if (mTranslateX != 0.0f || mTranslateY != 0.0f) { |
| 494 | DisplayListOp* op = new (alloc()) TranslateOp(mTranslateX, mTranslateY); |
| 495 | mDisplayListData->displayListOps.add(op); |
| 496 | mTranslateX = mTranslateY = 0.0f; |
| 497 | } |
| 498 | mHasTranslate = false; |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | void DisplayListRenderer::addStateOp(StateOp* op) { |
| 503 | addOpInternal(op); |
| 504 | } |
| 505 | |
Romain Guy | 0f66753 | 2013-03-01 14:31:04 -0800 | [diff] [blame] | 506 | void DisplayListRenderer::addDrawOp(DrawOp* op) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 507 | Rect localBounds; |
Chris Craik | c1c5f08 | 2013-09-11 16:23:37 -0700 | [diff] [blame] | 508 | if (op->getLocalBounds(mDrawModifiers, localBounds)) { |
Romain Guy | 0f66753 | 2013-03-01 14:31:04 -0800 | [diff] [blame] | 509 | bool rejected = quickRejectNoScissor(localBounds.left, localBounds.top, |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 510 | localBounds.right, localBounds.bottom); |
| 511 | op->setQuickRejected(rejected); |
| 512 | } |
Chris Craik | c1c5f08 | 2013-09-11 16:23:37 -0700 | [diff] [blame] | 513 | |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 514 | mHasDrawOps = true; |
| 515 | addOpInternal(op); |
Romain Guy | 5ff9df6 | 2012-01-23 17:09:05 -0800 | [diff] [blame] | 516 | } |
| 517 | |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 518 | }; // namespace uirenderer |
| 519 | }; // namespace android |