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

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

Issue 1971343002: Convert GrClip to an abstract base class (Closed) Base URL: https://skia.googlesource.com/skia.git@upload2_clipout
Patch Set: fix crash Created 4 years, 7 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/GrBlurUtils.cpp ('k') | src/gpu/GrClipMaskManager.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 * Copyright 2010 Google Inc. 2 * Copyright 2010 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 "GrClip.h" 8 #include "GrClip.h"
9 9
10 #include "GrSurface.h" 10 #include "GrClipMaskManager.h"
11 #include "SkRect.h"
12 11
13 /////////////////////////////////////////////////////////////////////////////// 12 void GrNoClip::getConservativeBounds(int width, int height, SkIRect* devResult,
14 13 bool* isIntersectionOfRects) const {
15 /** 14 devResult->setXYWH(0, 0, width, height);
16 * getConservativeBounds returns the conservative bounding box of the clip 15 if (isIntersectionOfRects) {
17 * in device (as opposed to canvas) coordinates. If the bounding box is 16 *isIntersectionOfRects = true;
18 * the result of purely intersections of rects (with an initial replace)
19 * isIntersectionOfRects will be set to true.
20 */
21 void GrClip::getConservativeBounds(int width, int height, SkIRect* devResult,
22 bool* isIntersectionOfRects) const {
23 switch (fClipType) {
24 case kWideOpen_ClipType: {
25 devResult->setLTRB(0, 0, width, height);
26 if (isIntersectionOfRects) {
27 *isIntersectionOfRects = true;
28 }
29 } break;
30 case kIRect_ClipType: {
31 *devResult = this->irect();
32 if (isIntersectionOfRects) {
33 *isIntersectionOfRects = true;
34 }
35 } break;
36 case kClipStack_ClipType: {
37 SkRect devBounds;
38 this->clipStack()->getConservativeBounds(-this->origin().fX,
39 -this->origin().fY,
40 width,
41 height,
42 &devBounds,
43 isIntersectionOfRects);
44 devBounds.roundOut(devResult);
45 } break;
46
47 } 17 }
48 } 18 }
49 19
50 const GrClip& GrClip::WideOpen() { 20 bool GrFixedClip::quickContains(const SkRect& rect) const {
51 static const GrClip clip; 21 if (fHasStencilClip) {
52 return clip; 22 return false;
23 }
24 if (!fScissorState.enabled()) {
25 return true;
26 }
27 return fScissorState.rect().contains(rect);
53 } 28 }
29
30 void GrFixedClip::getConservativeBounds(int width, int height, SkIRect* devResul t,
31 bool* isIntersectionOfRects) const {
32 devResult->setXYWH(0, 0, width, height);
33 if (fScissorState.enabled()) {
34 if (!devResult->intersect(fScissorState.rect())) {
35 devResult->setEmpty();
36 }
37 }
38 if (isIntersectionOfRects) {
39 *isIntersectionOfRects = true;
40 }
41 }
42
43 bool GrFixedClip::apply(GrClipMaskManager*, const GrPipelineBuilder& pipelineBui lder,
44 const SkRect* devBounds, GrAppliedClip* out) const {
45 if (fScissorState.enabled()) {
46 const GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
47 SkIRect tightScissor;
48 if (!tightScissor.intersect(fScissorState.rect(),
49 SkIRect::MakeWH(rt->width(), rt->height()))) {
50 return false;
51 }
52 if (devBounds && !devBounds->intersects(SkRect::Make(tightScissor))) {
53 return false;
54 }
55 out->fScissorState.set(tightScissor);
56 }
57 out->fHasStencilClip = fHasStencilClip;
58 return true;
59 }
60
61 bool GrClipStackClip::quickContains(const SkRect& rect) const {
62 if (!fStack) {
63 return true;
64 }
65 return fStack->quickContains(rect.makeOffset(SkIntToScalar(fOrigin.x()),
66 SkIntToScalar(fOrigin.y())));
67 }
68
69 void GrClipStackClip::getConservativeBounds(int width, int height, SkIRect* devR esult,
70 bool* isIntersectionOfRects) const {
71 if (!fStack) {
72 devResult->setXYWH(0, 0, width, height);
73 if (isIntersectionOfRects) {
74 *isIntersectionOfRects = true;
75 }
76 return;
77 }
78 SkRect devBounds;
79 fStack->getConservativeBounds(-fOrigin.x(), -fOrigin.y(), width, height, &de vBounds,
80 isIntersectionOfRects);
81 devBounds.roundOut(devResult);
82 }
83
84 bool GrClipStackClip::apply(GrClipMaskManager* clipMaskManager,
85 const GrPipelineBuilder& pipelineBuilder, const SkRe ct* devBounds,
86 GrAppliedClip* out) const {
87 // TODO: Collapse ClipMaskManager into this class.(?)
88 return clipMaskManager->setupClipping(pipelineBuilder, *this, devBounds, out );
89 }
OLDNEW
« no previous file with comments | « src/gpu/GrBlurUtils.cpp ('k') | src/gpu/GrClipMaskManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698