OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrAARectRenderer.h" | 8 #include "GrAARectRenderer.h" |
9 #include "GrRefCnt.h" | 9 #include "GrRefCnt.h" |
10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 * Half width + 0.5 | 23 * Half width + 0.5 |
24 * Half height + 0.5 | 24 * Half height + 0.5 |
25 * The center and vector are stored in a vec4 varying ("RectEdge") with the | 25 * The center and vector are stored in a vec4 varying ("RectEdge") with the |
26 * center in the xy components and the vector in the zw components. | 26 * center in the xy components and the vector in the zw components. |
27 * The munged width and height are stored in a vec2 varying ("WidthHeight") | 27 * The munged width and height are stored in a vec2 varying ("WidthHeight") |
28 * with the width in x and the height in y. | 28 * with the width in x and the height in y. |
29 */ | 29 */ |
30 class GrRectEffect : public GrEffect { | 30 class GrRectEffect : public GrEffect { |
31 public: | 31 public: |
32 static GrEffectRef* Create() { | 32 static GrEffectRef* Create() { |
33 static SkAutoTUnref<GrEffectRef> gRectEffectRef( | 33 GR_CREATE_STATIC_EFFECT(gRectEffect, GrRectEffect, ()); |
34 CreateEffectRef(AutoEffectUnref(SkNEW(GrRectEffect)))); | 34 gRectEffect->ref(); |
35 gRectEffectRef.get()->ref(); | 35 return gRectEffect; |
36 return gRectEffectRef; | |
37 } | 36 } |
38 | 37 |
39 virtual ~GrRectEffect() {} | 38 virtual ~GrRectEffect() {} |
40 | 39 |
41 static const char* Name() { return "RectEdge"; } | 40 static const char* Name() { return "RectEdge"; } |
42 | 41 |
43 virtual void getConstantColorComponents(GrColor* color, | 42 virtual void getConstantColorComponents(GrColor* color, |
44 uint32_t* validFlags) const SK_OVERR
IDE { | 43 uint32_t* validFlags) const SK_OVERR
IDE { |
45 *validFlags = 0; | 44 *validFlags = 0; |
46 } | 45 } |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 // The innermost rect has full coverage | 482 // The innermost rect has full coverage |
484 verts += 8 * vsize; | 483 verts += 8 * vsize; |
485 for (int i = 0; i < 4; ++i) { | 484 for (int i = 0; i < 4; ++i) { |
486 *reinterpret_cast<GrColor*>(verts + i * vsize) = 0; | 485 *reinterpret_cast<GrColor*>(verts + i * vsize) = 0; |
487 } | 486 } |
488 | 487 |
489 target->setIndexSourceToBuffer(indexBuffer); | 488 target->setIndexSourceToBuffer(indexBuffer); |
490 target->drawIndexed(kTriangles_GrPrimitiveType, | 489 target->drawIndexed(kTriangles_GrPrimitiveType, |
491 0, 0, 16, aaStrokeRectIndexCount()); | 490 0, 0, 16, aaStrokeRectIndexCount()); |
492 } | 491 } |
OLD | NEW |