Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: src/gpu/GrDrawContext.cpp

Issue 1282283002: Move GrStrokeRectBatch creation to behind factory (Closed) Base URL: https://skia.googlesource.com/skia.git@batchfactory2
Patch Set: feedback inc Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/GrDrawTarget.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrAARectRenderer.h" 9 #include "GrAARectRenderer.h"
10 #include "GrAtlasTextContext.h" 10 #include "GrAtlasTextContext.h"
11 #include "GrBatchTest.h" 11 #include "GrBatchTest.h"
12 #include "GrColor.h" 12 #include "GrColor.h"
13 #include "GrDrawContext.h" 13 #include "GrDrawContext.h"
14 #include "GrOvalRenderer.h" 14 #include "GrOvalRenderer.h"
15 #include "GrPathRenderer.h" 15 #include "GrPathRenderer.h"
16 #include "GrRenderTarget.h" 16 #include "GrRenderTarget.h"
17 #include "GrRenderTargetPriv.h" 17 #include "GrRenderTargetPriv.h"
18 #include "GrStencilAndCoverTextContext.h" 18 #include "GrStencilAndCoverTextContext.h"
19 19
20 #include "batches/GrBatch.h" 20 #include "batches/GrBatch.h"
21 #include "batches/GrDrawAtlasBatch.h" 21 #include "batches/GrDrawAtlasBatch.h"
22 #include "batches/GrDrawVerticesBatch.h" 22 #include "batches/GrDrawVerticesBatch.h"
23 #include "batches/GrStrokeRectBatch.h" 23 #include "batches/GrRectBatchFactory.h"
24 24
25 #include "SkGr.h" 25 #include "SkGr.h"
26 #include "SkRSXform.h" 26 #include "SkRSXform.h"
27 27
28 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fContext) 28 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fContext)
29 #define RETURN_IF_ABANDONED if (!fDrawTarget) { return; } 29 #define RETURN_IF_ABANDONED if (!fDrawTarget) { return; }
30 #define RETURN_FALSE_IF_ABANDONED if (!fDrawTarget) { return false; } 30 #define RETURN_FALSE_IF_ABANDONED if (!fDrawTarget) { return false; }
31 #define RETURN_NULL_IF_ABANDONED if (!fDrawTarget) { return NULL; } 31 #define RETURN_NULL_IF_ABANDONED if (!fDrawTarget) { return NULL; }
32 32
33 class AutoCheckFlush { 33 class AutoCheckFlush {
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 pipelineBuilder, 322 pipelineBuilder,
323 color, 323 color,
324 viewMatrix, 324 viewMatrix,
325 rect, 325 rect,
326 devBoundRect); 326 devBoundRect);
327 } 327 }
328 return; 328 return;
329 } 329 }
330 330
331 if (width >= 0) { 331 if (width >= 0) {
332 GrStrokeRectBatch::Geometry geometry;
333 geometry.fViewMatrix = viewMatrix;
334 geometry.fColor = color;
335 geometry.fRect = rect;
336 geometry.fStrokeWidth = width;
337
338 // Non-AA hairlines are snapped to pixel centers to make which pixels ar e hit deterministic 332 // Non-AA hairlines are snapped to pixel centers to make which pixels ar e hit deterministic
339 bool snapToPixelCenters = (0 == width && !rt->isUnifiedMultisampled()); 333 bool snapToPixelCenters = (0 == width && !rt->isUnifiedMultisampled());
340 SkAutoTUnref<GrBatch> batch(GrStrokeRectBatch::Create(geometry, snapToPi xelCenters)); 334 SkAutoTUnref<GrBatch> batch(GrRectBatchFactory::CreateStrokeBW(color, vi ewMatrix, rect,
335 width, sn apToPixelCenters));
341 336
342 // Depending on sub-pixel coordinates and the particular GPU, we may los e a corner of 337 // Depending on sub-pixel coordinates and the particular GPU, we may los e a corner of
343 // hairline rects. We jam all the vertices to pixel centers to avoid thi s, but not when MSAA 338 // hairline rects. We jam all the vertices to pixel centers to avoid thi s, but not when MSAA
344 // is enabled because it can cause ugly artifacts. 339 // is enabled because it can cause ugly artifacts.
345 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_ Flag, 340 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_ Flag,
346 snapToPixelCenters); 341 snapToPixelCenters);
347 fDrawTarget->drawBatch(pipelineBuilder, batch); 342 fDrawTarget->drawBatch(pipelineBuilder, batch);
348 } else { 343 } else {
349 // filled BW rect 344 // filled BW rect
350 fDrawTarget->drawSimpleRect(pipelineBuilder, color, viewMatrix, rect); 345 fDrawTarget->drawSimpleRect(pipelineBuilder, color, viewMatrix, rect);
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 RETURN_FALSE_IF_ABANDONED 819 RETURN_FALSE_IF_ABANDONED
825 820
826 ASSERT_OWNED_RESOURCE(rt); 821 ASSERT_OWNED_RESOURCE(rt);
827 SkASSERT(rt); 822 SkASSERT(rt);
828 return true; 823 return true;
829 } 824 }
830 825
831 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrBatch* batch ) { 826 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrBatch* batch ) {
832 fDrawTarget->drawBatch(*pipelineBuilder, batch); 827 fDrawTarget->drawBatch(*pipelineBuilder, batch);
833 } 828 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrDrawTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698