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

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

Issue 1454933002: Initial implementation of GPU no filter NinePatch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 1 month 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
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 "GrDrawingManager.h" 13 #include "GrDrawingManager.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 "GrResourceProvider.h" 18 #include "GrResourceProvider.h"
19 #include "GrStencilAndCoverTextContext.h" 19 #include "GrStencilAndCoverTextContext.h"
20 #include "SkSurfacePriv.h" 20 #include "SkSurfacePriv.h"
21 21
22 #include "batches/GrBatch.h" 22 #include "batches/GrBatch.h"
23 #include "batches/GrDrawAtlasBatch.h" 23 #include "batches/GrDrawAtlasBatch.h"
24 #include "batches/GrDrawVerticesBatch.h" 24 #include "batches/GrDrawVerticesBatch.h"
25 #include "batches/GrRectBatchFactory.h" 25 #include "batches/GrRectBatchFactory.h"
26 #include "batches/GrNinePatch.h" // TODO Factory
26 27
27 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM anager->getContext()) 28 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM anager->getContext())
28 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } 29 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; }
29 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fa lse; } 30 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fa lse; }
30 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nu llptr; } 31 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nu llptr; }
31 32
32 class AutoCheckFlush { 33 class AutoCheckFlush {
33 public: 34 public:
34 AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingMa nager) { 35 AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingMa nager) {
35 SkASSERT(fDrawingManager); 36 SkASSERT(fDrawingManager);
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 oval, 563 oval,
563 strokeInfo)) { 564 strokeInfo)) {
564 SkPath path; 565 SkPath path;
565 path.setIsVolatile(true); 566 path.setIsVolatile(true);
566 path.addOval(oval); 567 path.addOval(oval);
567 this->internalDrawPath(&pipelineBuilder, viewMatrix, color, 568 this->internalDrawPath(&pipelineBuilder, viewMatrix, color,
568 paint.isAntiAlias(), path, strokeInfo); 569 paint.isAntiAlias(), path, strokeInfo);
569 } 570 }
570 } 571 }
571 572
573 void GrDrawContext::drawImageNine(const GrClip& clip,
574 const GrPaint& paint,
575 const SkMatrix& viewMatrix,
576 int imageWidth,
577 int imageHeight,
578 const SkIRect& center,
579 const SkRect& dst) {
580 RETURN_IF_ABANDONED
581 SkDEBUGCODE(this->validate();)
582
583 AutoCheckFlush acf(fDrawingManager);
584
585 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v iewMatrix,
586 imageWidth, imageHe ight,
587 center, dst));
588
589 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
590 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
591 }
592
593
572 // Can 'path' be drawn as a pair of filled nested rectangles? 594 // Can 'path' be drawn as a pair of filled nested rectangles?
573 static bool is_nested_rects(const SkMatrix& viewMatrix, 595 static bool is_nested_rects(const SkMatrix& viewMatrix,
574 const SkPath& path, 596 const SkPath& path,
575 const SkStrokeRec& stroke, 597 const SkStrokeRec& stroke,
576 SkRect rects[2]) { 598 SkRect rects[2]) {
577 SkASSERT(stroke.isFillStyle()); 599 SkASSERT(stroke.isFillStyle());
578 600
579 if (path.isInverseFillType()) { 601 if (path.isInverseFillType()) {
580 return false; 602 return false;
581 } 603 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 args.fAntiAlias = useCoverageAA; 810 args.fAntiAlias = useCoverageAA;
789 pr->drawPath(args); 811 pr->drawPath(args);
790 } 812 }
791 813
792 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) { 814 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) {
793 RETURN_IF_ABANDONED 815 RETURN_IF_ABANDONED
794 SkDEBUGCODE(this->validate();) 816 SkDEBUGCODE(this->validate();)
795 817
796 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); 818 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch);
797 } 819 }
OLDNEW
« no previous file with comments | « include/gpu/GrDrawContext.h ('k') | src/gpu/SkGpuDevice.h » ('j') | src/gpu/SkGpuDevice.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698