OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrBatchTest.h" | 8 #include "GrBatchTest.h" |
9 #include "GrColor.h" | 9 #include "GrColor.h" |
10 #include "GrDrawContext.h" | 10 #include "GrDrawContext.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "effects/GrRRectEffect.h" | 30 #include "effects/GrRRectEffect.h" |
31 | 31 |
32 #include "instanced/InstancedRendering.h" | 32 #include "instanced/InstancedRendering.h" |
33 | 33 |
34 #include "text/GrAtlasTextContext.h" | 34 #include "text/GrAtlasTextContext.h" |
35 #include "text/GrStencilAndCoverTextContext.h" | 35 #include "text/GrStencilAndCoverTextContext.h" |
36 | 36 |
37 #include "../private/GrAuditTrail.h" | 37 #include "../private/GrAuditTrail.h" |
38 | 38 |
39 #include "SkLatticeIter.h" | 39 #include "SkLatticeIter.h" |
| 40 #include "SkMatrixPriv.h" |
40 | 41 |
41 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM
anager->getContext()) | 42 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM
anager->getContext()) |
42 #define ASSERT_SINGLE_OWNER \ | 43 #define ASSERT_SINGLE_OWNER \ |
43 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);) | 44 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);) |
44 #define ASSERT_SINGLE_OWNER_PRIV \ | 45 #define ASSERT_SINGLE_OWNER_PRIV \ |
45 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fDrawContext->fSing
leOwner);) | 46 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fDrawContext->fSing
leOwner);) |
46 #define RETURN_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return
; } | 47 #define RETURN_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return
; } |
47 #define RETURN_IF_ABANDONED_PRIV if (fDrawContext->fDrawingManager->wasAbandon
ed()) { return; } | 48 #define RETURN_IF_ABANDONED_PRIV if (fDrawContext->fDrawingManager->wasAbandon
ed()) { return; } |
48 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return
false; } | 49 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return
false; } |
49 #define RETURN_FALSE_IF_ABANDONED_PRIV if (fDrawContext->fDrawingManager->wasAb
andoned()) { return false; } | 50 #define RETURN_FALSE_IF_ABANDONED_PRIV if (fDrawContext->fDrawingManager->wasAb
andoned()) { return false; } |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 if (paint->isAntiAlias()) { | 254 if (paint->isAntiAlias()) { |
254 paint.writable()->setAntiAlias(false); | 255 paint.writable()->setAntiAlias(false); |
255 } | 256 } |
256 | 257 |
257 bool isPerspective = viewMatrix.hasPerspective(); | 258 bool isPerspective = viewMatrix.hasPerspective(); |
258 | 259 |
259 // We attempt to map r by the inverse matrix and draw that. mapRect will | 260 // We attempt to map r by the inverse matrix and draw that. mapRect will |
260 // map the four corners and bound them with a new rect. This will not | 261 // map the four corners and bound them with a new rect. This will not |
261 // produce a correct result for some perspective matrices. | 262 // produce a correct result for some perspective matrices. |
262 if (!isPerspective) { | 263 if (!isPerspective) { |
263 SkMatrix inverse; | 264 if (!SkMatrixPriv::InverseMapRect(viewMatrix, &r, r)) { |
264 if (!viewMatrix.invert(&inverse)) { | |
265 SkDebugf("Could not invert matrix\n"); | 265 SkDebugf("Could not invert matrix\n"); |
266 return; | 266 return; |
267 } | 267 } |
268 inverse.mapRect(&r); | |
269 this->drawRect(clip, *paint, viewMatrix, r); | 268 this->drawRect(clip, *paint, viewMatrix, r); |
270 } else { | 269 } else { |
271 SkMatrix localMatrix; | 270 SkMatrix localMatrix; |
272 if (!viewMatrix.invert(&localMatrix)) { | 271 if (!viewMatrix.invert(&localMatrix)) { |
273 SkDebugf("Could not invert matrix\n"); | 272 SkDebugf("Could not invert matrix\n"); |
274 return; | 273 return; |
275 } | 274 } |
276 | 275 |
277 AutoCheckFlush acf(fDrawingManager); | 276 AutoCheckFlush acf(fDrawingManager); |
278 | 277 |
(...skipping 28 matching lines...) Expand all Loading... |
307 | 306 |
308 // Attempts to crop a rect and optional local rect to the clip boundaries. | 307 // Attempts to crop a rect and optional local rect to the clip boundaries. |
309 // Returns false if the draw can be skipped entirely. | 308 // Returns false if the draw can be skipped entirely. |
310 static bool crop_filled_rect(const GrRenderTarget* rt, const GrClip& clip, | 309 static bool crop_filled_rect(const GrRenderTarget* rt, const GrClip& clip, |
311 const SkMatrix& viewMatrix, SkRect* rect, | 310 const SkMatrix& viewMatrix, SkRect* rect, |
312 SkRect* localRect = nullptr) { | 311 SkRect* localRect = nullptr) { |
313 if (!viewMatrix.rectStaysRect()) { | 312 if (!viewMatrix.rectStaysRect()) { |
314 return true; | 313 return true; |
315 } | 314 } |
316 | 315 |
317 SkMatrix inverseViewMatrix; | |
318 if (!viewMatrix.invert(&inverseViewMatrix)) { | |
319 return false; | |
320 } | |
321 | |
322 SkIRect clipDevBounds; | 316 SkIRect clipDevBounds; |
323 SkRect clipBounds; | 317 SkRect clipBounds; |
324 SkASSERT(inverseViewMatrix.rectStaysRect()); | |
325 | 318 |
326 clip.getConservativeBounds(rt->width(), rt->height(), &clipDevBounds); | 319 clip.getConservativeBounds(rt->width(), rt->height(), &clipDevBounds); |
327 inverseViewMatrix.mapRect(&clipBounds, SkRect::Make(clipDevBounds)); | 320 if (!SkMatrixPriv::InverseMapRect(viewMatrix, &clipBounds, SkRect::Make(clip
DevBounds))) { |
| 321 return false; |
| 322 } |
328 | 323 |
329 if (localRect) { | 324 if (localRect) { |
330 if (!rect->intersects(clipBounds)) { | 325 if (!rect->intersects(clipBounds)) { |
331 return false; | 326 return false; |
332 } | 327 } |
333 const SkScalar dx = localRect->width() / rect->width(); | 328 const SkScalar dx = localRect->width() / rect->width(); |
334 const SkScalar dy = localRect->height() / rect->height(); | 329 const SkScalar dy = localRect->height() / rect->height(); |
335 if (clipBounds.fLeft > rect->fLeft) { | 330 if (clipBounds.fLeft > rect->fLeft) { |
336 localRect->fLeft += (clipBounds.fLeft - rect->fLeft) * dx; | 331 localRect->fLeft += (clipBounds.fLeft - rect->fLeft) * dx; |
337 rect->fLeft = clipBounds.fLeft; | 332 rect->fLeft = clipBounds.fLeft; |
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1312 | 1307 |
1313 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr
Clip& clip, | 1308 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr
Clip& clip, |
1314 GrDrawBatch* batch) { | 1309 GrDrawBatch* batch) { |
1315 ASSERT_SINGLE_OWNER | 1310 ASSERT_SINGLE_OWNER |
1316 RETURN_IF_ABANDONED | 1311 RETURN_IF_ABANDONED |
1317 SkDEBUGCODE(this->validate();) | 1312 SkDEBUGCODE(this->validate();) |
1318 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 1313 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
1319 | 1314 |
1320 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 1315 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
1321 } | 1316 } |
OLD | NEW |