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

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

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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 | « src/gpu/GrDefaultPathRenderer.cpp ('k') | src/gpu/GrDrawTarget.h » ('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 "GrAtlasTextContext.h" 9 #include "GrAtlasTextContext.h"
10 #include "GrBatchTest.h" 10 #include "GrBatchTest.h"
11 #include "GrColor.h" 11 #include "GrColor.h"
12 #include "GrDrawContext.h" 12 #include "GrDrawContext.h"
13 #include "GrOvalRenderer.h" 13 #include "GrOvalRenderer.h"
14 #include "GrPathRenderer.h" 14 #include "GrPathRenderer.h"
15 #include "GrRenderTarget.h" 15 #include "GrRenderTarget.h"
16 #include "GrRenderTargetPriv.h" 16 #include "GrRenderTargetPriv.h"
17 #include "GrStencilAndCoverTextContext.h" 17 #include "GrStencilAndCoverTextContext.h"
18 18
19 #include "batches/GrBatch.h" 19 #include "batches/GrBatch.h"
20 #include "batches/GrDrawAtlasBatch.h" 20 #include "batches/GrDrawAtlasBatch.h"
21 #include "batches/GrDrawVerticesBatch.h" 21 #include "batches/GrDrawVerticesBatch.h"
22 #include "batches/GrRectBatchFactory.h" 22 #include "batches/GrRectBatchFactory.h"
23 23
24 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fContext) 24 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fContext)
25 #define RETURN_IF_ABANDONED if (!fDrawTarget) { return; } 25 #define RETURN_IF_ABANDONED if (!fDrawTarget) { return; }
26 #define RETURN_FALSE_IF_ABANDONED if (!fDrawTarget) { return false; } 26 #define RETURN_FALSE_IF_ABANDONED if (!fDrawTarget) { return false; }
27 #define RETURN_NULL_IF_ABANDONED if (!fDrawTarget) { return NULL; } 27 #define RETURN_NULL_IF_ABANDONED if (!fDrawTarget) { return nullptr; }
28 28
29 class AutoCheckFlush { 29 class AutoCheckFlush {
30 public: 30 public:
31 AutoCheckFlush(GrContext* context) : fContext(context) { SkASSERT(context); } 31 AutoCheckFlush(GrContext* context) : fContext(context) { SkASSERT(context); }
32 ~AutoCheckFlush() { fContext->flushIfNecessary(); } 32 ~AutoCheckFlush() { fContext->flushIfNecessary(); }
33 33
34 private: 34 private:
35 GrContext* fContext; 35 GrContext* fContext;
36 }; 36 };
37 37
38 GrDrawContext::GrDrawContext(GrContext* context, 38 GrDrawContext::GrDrawContext(GrContext* context,
39 GrDrawTarget* drawTarget, 39 GrDrawTarget* drawTarget,
40 const SkSurfaceProps& surfaceProps) 40 const SkSurfaceProps& surfaceProps)
41 : fContext(context) 41 : fContext(context)
42 , fDrawTarget(SkRef(drawTarget)) 42 , fDrawTarget(SkRef(drawTarget))
43 , fTextContext(NULL) 43 , fTextContext(nullptr)
44 , fSurfaceProps(surfaceProps) { 44 , fSurfaceProps(surfaceProps) {
45 } 45 }
46 46
47 GrDrawContext::~GrDrawContext() { 47 GrDrawContext::~GrDrawContext() {
48 SkSafeUnref(fDrawTarget); 48 SkSafeUnref(fDrawTarget);
49 delete fTextContext; 49 delete fTextContext;
50 } 50 }
51 51
52 void GrDrawContext::copySurface(GrRenderTarget* dst, GrSurface* src, 52 void GrDrawContext::copySurface(GrRenderTarget* dst, GrSurface* src,
53 const SkIRect& srcRect, const SkIPoint& dstPoint ) { 53 const SkIRect& srcRect, const SkIPoint& dstPoint ) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 return; 223 return;
224 } 224 }
225 225
226 AutoCheckFlush acf(fContext); 226 AutoCheckFlush acf(fContext);
227 if (!this->prepareToDraw(rt)) { 227 if (!this->prepareToDraw(rt)) {
228 return; 228 return;
229 } 229 }
230 230
231 GrPipelineBuilder pipelineBuilder(paint, rt, clip); 231 GrPipelineBuilder pipelineBuilder(paint, rt, clip);
232 232
233 SkScalar width = NULL == strokeInfo ? -1 : strokeInfo->getWidth(); 233 SkScalar width = nullptr == strokeInfo ? -1 : strokeInfo->getWidth();
234 234
235 // Check if this is a full RT draw and can be replaced with a clear. We don' t bother checking 235 // Check if this is a full RT draw and can be replaced with a clear. We don' t bother checking
236 // cases where the RT is fully inside a stroke. 236 // cases where the RT is fully inside a stroke.
237 if (width < 0) { 237 if (width < 0) {
238 SkRect rtRect; 238 SkRect rtRect;
239 pipelineBuilder.getRenderTarget()->getBoundsRect(&rtRect); 239 pipelineBuilder.getRenderTarget()->getBoundsRect(&rtRect);
240 SkRect clipSpaceRTRect = rtRect; 240 SkRect clipSpaceRTRect = rtRect;
241 bool checkClip = GrClip::kWideOpen_ClipType != clip.clipType(); 241 bool checkClip = GrClip::kWideOpen_ClipType != clip.clipType();
242 if (checkClip) { 242 if (checkClip) {
243 clipSpaceRTRect.offset(SkIntToScalar(clip.origin().fX), 243 clipSpaceRTRect.offset(SkIntToScalar(clip.origin().fX),
244 SkIntToScalar(clip.origin().fY)); 244 SkIntToScalar(clip.origin().fY));
245 } 245 }
246 // Does the clip contain the entire RT? 246 // Does the clip contain the entire RT?
247 if (!checkClip || clip.quickContains(clipSpaceRTRect)) { 247 if (!checkClip || clip.quickContains(clipSpaceRTRect)) {
248 SkMatrix invM; 248 SkMatrix invM;
249 if (!viewMatrix.invert(&invM)) { 249 if (!viewMatrix.invert(&invM)) {
250 return; 250 return;
251 } 251 }
252 // Does the rect bound the RT? 252 // Does the rect bound the RT?
253 SkPoint srcSpaceRTQuad[4]; 253 SkPoint srcSpaceRTQuad[4];
254 invM.mapRectToQuad(srcSpaceRTQuad, rtRect); 254 invM.mapRectToQuad(srcSpaceRTQuad, rtRect);
255 if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) && 255 if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) &&
256 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) && 256 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) &&
257 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) && 257 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) &&
258 rect_contains_inclusive(rect, srcSpaceRTQuad[3])) { 258 rect_contains_inclusive(rect, srcSpaceRTQuad[3])) {
259 // Will it blend? 259 // Will it blend?
260 GrColor clearColor; 260 GrColor clearColor;
261 if (paint.isConstantBlendedColor(&clearColor)) { 261 if (paint.isConstantBlendedColor(&clearColor)) {
262 fDrawTarget->clear(NULL, clearColor, true, rt); 262 fDrawTarget->clear(nullptr, clearColor, true, rt);
263 return; 263 return;
264 } 264 }
265 } 265 }
266 } 266 }
267 } 267 }
268 268
269 GrColor color = paint.getColor(); 269 GrColor color = paint.getColor();
270 bool needAA = paint.isAntiAlias() && 270 bool needAA = paint.isAntiAlias() &&
271 !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled(); 271 !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled();
272 272
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 692
693 const SkPath* pathPtr = &path; 693 const SkPath* pathPtr = &path;
694 SkTLazy<SkPath> tmpPath; 694 SkTLazy<SkPath> tmpPath;
695 const GrStrokeInfo* strokeInfoPtr = &strokeInfo; 695 const GrStrokeInfo* strokeInfoPtr = &strokeInfo;
696 696
697 // Try a 1st time without stroking the path and without allowing the SW rend erer 697 // Try a 1st time without stroking the path and without allowing the SW rend erer
698 GrPathRenderer* pr = fContext->getPathRenderer(target, pipelineBuilder, view Matrix, *pathPtr, 698 GrPathRenderer* pr = fContext->getPathRenderer(target, pipelineBuilder, view Matrix, *pathPtr,
699 *strokeInfoPtr, false, type) ; 699 *strokeInfoPtr, false, type) ;
700 700
701 GrStrokeInfo dashlessStrokeInfo(strokeInfo, false); 701 GrStrokeInfo dashlessStrokeInfo(strokeInfo, false);
702 if (NULL == pr && strokeInfo.isDashed()) { 702 if (nullptr == pr && strokeInfo.isDashed()) {
703 // It didn't work above, so try again with dashed stroke converted to a dashless stroke. 703 // It didn't work above, so try again with dashed stroke converted to a dashless stroke.
704 if (!strokeInfo.applyDashToPath(tmpPath.init(), &dashlessStrokeInfo, *pa thPtr)) { 704 if (!strokeInfo.applyDashToPath(tmpPath.init(), &dashlessStrokeInfo, *pa thPtr)) {
705 return; 705 return;
706 } 706 }
707 pathPtr = tmpPath.get(); 707 pathPtr = tmpPath.get();
708 if (pathPtr->isEmpty()) { 708 if (pathPtr->isEmpty()) {
709 return; 709 return;
710 } 710 }
711 strokeInfoPtr = &dashlessStrokeInfo; 711 strokeInfoPtr = &dashlessStrokeInfo;
712 pr = fContext->getPathRenderer(target, pipelineBuilder, viewMatrix, *pat hPtr, *strokeInfoPtr, 712 pr = fContext->getPathRenderer(target, pipelineBuilder, viewMatrix, *pat hPtr, *strokeInfoPtr,
713 false, type); 713 false, type);
714 } 714 }
715 715
716 if (NULL == pr) { 716 if (nullptr == pr) {
717 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*strokeInfoPtr, viewMa trix, NULL) && 717 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*strokeInfoPtr, viewMa trix, nullptr) &&
718 !strokeInfoPtr->isFillStyle()) { 718 !strokeInfoPtr->isFillStyle()) {
719 // It didn't work above, so try again with stroke converted to a fil l. 719 // It didn't work above, so try again with stroke converted to a fil l.
720 if (!tmpPath.isValid()) { 720 if (!tmpPath.isValid()) {
721 tmpPath.init(); 721 tmpPath.init();
722 } 722 }
723 dashlessStrokeInfo.setResScale(SkScalarAbs(viewMatrix.getMaxScale()) ); 723 dashlessStrokeInfo.setResScale(SkScalarAbs(viewMatrix.getMaxScale()) );
724 if (!dashlessStrokeInfo.applyToPath(tmpPath.get(), *pathPtr)) { 724 if (!dashlessStrokeInfo.applyToPath(tmpPath.get(), *pathPtr)) {
725 return; 725 return;
726 } 726 }
727 pathPtr = tmpPath.get(); 727 pathPtr = tmpPath.get();
728 if (pathPtr->isEmpty()) { 728 if (pathPtr->isEmpty()) {
729 return; 729 return;
730 } 730 }
731 dashlessStrokeInfo.setFillStyle(); 731 dashlessStrokeInfo.setFillStyle();
732 strokeInfoPtr = &dashlessStrokeInfo; 732 strokeInfoPtr = &dashlessStrokeInfo;
733 } 733 }
734 734
735 // This time, allow SW renderer 735 // This time, allow SW renderer
736 pr = fContext->getPathRenderer(target, pipelineBuilder, viewMatrix, *pat hPtr, *strokeInfoPtr, 736 pr = fContext->getPathRenderer(target, pipelineBuilder, viewMatrix, *pat hPtr, *strokeInfoPtr,
737 true, type); 737 true, type);
738 } 738 }
739 739
740 if (NULL == pr) { 740 if (nullptr == pr) {
741 #ifdef SK_DEBUG 741 #ifdef SK_DEBUG
742 SkDebugf("Unable to find path renderer compatible with path.\n"); 742 SkDebugf("Unable to find path renderer compatible with path.\n");
743 #endif 743 #endif
744 return; 744 return;
745 } 745 }
746 746
747 GrPathRenderer::DrawPathArgs args; 747 GrPathRenderer::DrawPathArgs args;
748 args.fTarget = target; 748 args.fTarget = target;
749 args.fResourceProvider = fContext->resourceProvider(); 749 args.fResourceProvider = fContext->resourceProvider();
750 args.fPipelineBuilder = pipelineBuilder; 750 args.fPipelineBuilder = pipelineBuilder;
751 args.fColor = color; 751 args.fColor = color;
752 args.fViewMatrix = &viewMatrix; 752 args.fViewMatrix = &viewMatrix;
753 args.fPath = pathPtr; 753 args.fPath = pathPtr;
754 args.fStroke = strokeInfoPtr; 754 args.fStroke = strokeInfoPtr;
755 args.fAntiAlias = useCoverageAA; 755 args.fAntiAlias = useCoverageAA;
756 pr->drawPath(args); 756 pr->drawPath(args);
757 } 757 }
758 758
759 bool GrDrawContext::prepareToDraw(GrRenderTarget* rt) { 759 bool GrDrawContext::prepareToDraw(GrRenderTarget* rt) {
760 RETURN_FALSE_IF_ABANDONED 760 RETURN_FALSE_IF_ABANDONED
761 761
762 ASSERT_OWNED_RESOURCE(rt); 762 ASSERT_OWNED_RESOURCE(rt);
763 SkASSERT(rt); 763 SkASSERT(rt);
764 return true; 764 return true;
765 } 765 }
766 766
767 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) { 767 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) {
768 fDrawTarget->drawBatch(*pipelineBuilder, batch); 768 fDrawTarget->drawBatch(*pipelineBuilder, batch);
769 } 769 }
OLDNEW
« no previous file with comments | « src/gpu/GrDefaultPathRenderer.cpp ('k') | src/gpu/GrDrawTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698