OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkGpuDevice.h" | 8 #include "SkGpuDevice.h" |
9 | 9 |
10 #include "effects/GrBicubicEffect.h" | 10 #include "effects/GrBicubicEffect.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "SkImageFilter.h" | 27 #include "SkImageFilter.h" |
28 #include "SkMaskFilter.h" | 28 #include "SkMaskFilter.h" |
29 #include "SkPathEffect.h" | 29 #include "SkPathEffect.h" |
30 #include "SkPicture.h" | 30 #include "SkPicture.h" |
31 #include "SkPicturePlayback.h" | 31 #include "SkPicturePlayback.h" |
32 #include "SkRRect.h" | 32 #include "SkRRect.h" |
33 #include "SkStroke.h" | 33 #include "SkStroke.h" |
34 #include "SkSurface.h" | 34 #include "SkSurface.h" |
35 #include "SkTLazy.h" | 35 #include "SkTLazy.h" |
36 #include "SkUtils.h" | 36 #include "SkUtils.h" |
| 37 #include "SkVertState.h" |
37 #include "SkErrorInternals.h" | 38 #include "SkErrorInternals.h" |
38 | 39 |
39 #define CACHE_COMPATIBLE_DEVICE_TEXTURES 1 | 40 #define CACHE_COMPATIBLE_DEVICE_TEXTURES 1 |
40 | 41 |
41 #if 0 | 42 #if 0 |
42 extern bool (*gShouldDrawProc)(); | 43 extern bool (*gShouldDrawProc)(); |
43 #define CHECK_SHOULD_DRAW(draw, forceI) \ | 44 #define CHECK_SHOULD_DRAW(draw, forceI) \ |
44 do { \ | 45 do { \ |
45 if (gShouldDrawProc && !gShouldDrawProc()) return; \ | 46 if (gShouldDrawProc && !gShouldDrawProc()) return; \ |
46 this->prepareDraw(draw, forceI); \ | 47 this->prepareDraw(draw, forceI); \ |
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1621 }; | 1622 }; |
1622 | 1623 |
1623 void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, | 1624 void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, |
1624 int vertexCount, const SkPoint vertices[], | 1625 int vertexCount, const SkPoint vertices[], |
1625 const SkPoint texs[], const SkColor colors[], | 1626 const SkPoint texs[], const SkColor colors[], |
1626 SkXfermode* xmode, | 1627 SkXfermode* xmode, |
1627 const uint16_t indices[], int indexCount, | 1628 const uint16_t indices[], int indexCount, |
1628 const SkPaint& paint) { | 1629 const SkPaint& paint) { |
1629 CHECK_SHOULD_DRAW(draw, false); | 1630 CHECK_SHOULD_DRAW(draw, false); |
1630 | 1631 |
| 1632 // If both textures and vertex-colors are NULL, strokes hairlines with the p
aint's color. |
| 1633 if ((NULL == texs || NULL == paint.getShader()) && NULL == colors) { |
| 1634 texs = NULL; |
| 1635 SkPaint copy(paint); |
| 1636 copy.setStyle(SkPaint::kStroke_Style); |
| 1637 copy.setStrokeWidth(0); |
| 1638 |
| 1639 VertState state(vertexCount, indices, indexCount); |
| 1640 VertState::Proc vertProc = state.chooseProc(vmode); |
| 1641 |
| 1642 SkPoint* pts = new SkPoint[vertexCount * 6]; |
| 1643 int i = 0; |
| 1644 while (vertProc(&state)) { |
| 1645 pts[i] = vertices[state.f0]; |
| 1646 pts[i + 1] = vertices[state.f1]; |
| 1647 pts[i + 2] = vertices[state.f1]; |
| 1648 pts[i + 3] = vertices[state.f2]; |
| 1649 pts[i + 4] = vertices[state.f2]; |
| 1650 pts[i + 5] = vertices[state.f0]; |
| 1651 i += 6; |
| 1652 } |
| 1653 draw.drawPoints(SkCanvas::kLines_PointMode, i, pts, copy, true); |
| 1654 return; |
| 1655 } |
| 1656 |
1631 GrPaint grPaint; | 1657 GrPaint grPaint; |
1632 // we ignore the shader if texs is null. | 1658 // we ignore the shader if texs is null. |
1633 if (NULL == texs) { | 1659 if (NULL == texs) { |
1634 SkPaint2GrPaintNoShader(this->context(), paint, false, NULL == colors, &
grPaint); | 1660 SkPaint2GrPaintNoShader(this->context(), paint, false, NULL == colors, &
grPaint); |
1635 } else { | 1661 } else { |
1636 SkPaint2GrPaintShader(this->context(), paint, NULL == colors, &grPaint); | 1662 SkPaint2GrPaintShader(this->context(), paint, NULL == colors, &grPaint); |
1637 } | 1663 } |
1638 | 1664 |
1639 if (NULL != xmode && NULL != texs && NULL != colors) { | 1665 if (NULL != xmode && NULL != texs && NULL != colors) { |
1640 if (!SkXfermode::IsMode(xmode, SkXfermode::kModulate_Mode)) { | 1666 if (!SkXfermode::IsMode(xmode, SkXfermode::kModulate_Mode)) { |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1991 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict
ure, i); | 2017 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict
ure, i); |
1992 | 2018 |
1993 if (NULL != layer->getTexture()) { | 2019 if (NULL != layer->getTexture()) { |
1994 fContext->unlockScratchTexture(layer->getTexture()); | 2020 fContext->unlockScratchTexture(layer->getTexture()); |
1995 layer->setTexture(NULL); | 2021 layer->setTexture(NULL); |
1996 } | 2022 } |
1997 } | 2023 } |
1998 | 2024 |
1999 return true; | 2025 return true; |
2000 } | 2026 } |
OLD | NEW |