| OLD | NEW |
| 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 "GrAARectRenderer.h" | 9 #include "GrAARectRenderer.h" |
| 10 #include "GrAtlasTextContext.h" | 10 #include "GrAtlasTextContext.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 public: | 27 public: |
| 28 AutoCheckFlush(GrContext* context) : fContext(context) { SkASSERT(context);
} | 28 AutoCheckFlush(GrContext* context) : fContext(context) { SkASSERT(context);
} |
| 29 ~AutoCheckFlush() { fContext->flushIfNecessary(); } | 29 ~AutoCheckFlush() { fContext->flushIfNecessary(); } |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 GrContext* fContext; | 32 GrContext* fContext; |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 GrDrawContext::GrDrawContext(GrContext* context, | 35 GrDrawContext::GrDrawContext(GrContext* context, |
| 36 GrDrawTarget* drawTarget, | 36 GrDrawTarget* drawTarget, |
| 37 const SkDeviceProperties& devProps, | 37 const SkDeviceProperties& devProps) |
| 38 bool useDFT) | |
| 39 : fContext(context) | 38 : fContext(context) |
| 40 , fDrawTarget(SkRef(drawTarget)) | 39 , fDrawTarget(SkRef(drawTarget)) |
| 41 , fTextContext(NULL) | 40 , fTextContext(NULL) |
| 42 , fDevProps(SkNEW_ARGS(SkDeviceProperties, (devProps))) | 41 , fDevProps(SkNEW_ARGS(SkDeviceProperties, (devProps))) { |
| 43 , fUseDFT(useDFT) { | |
| 44 } | 42 } |
| 45 | 43 |
| 46 GrDrawContext::~GrDrawContext() { | 44 GrDrawContext::~GrDrawContext() { |
| 47 SkSafeUnref(fDrawTarget); | 45 SkSafeUnref(fDrawTarget); |
| 48 SkDELETE(fTextContext); | 46 SkDELETE(fTextContext); |
| 49 SkDELETE(fDevProps); | 47 SkDELETE(fDevProps); |
| 50 } | 48 } |
| 51 | 49 |
| 52 void GrDrawContext::copySurface(GrRenderTarget* dst, GrSurface* src, | 50 void GrDrawContext::copySurface(GrRenderTarget* dst, GrSurface* src, |
| 53 const SkIRect& srcRect, const SkIPoint& dstPoint
) { | 51 const SkIRect& srcRect, const SkIPoint& dstPoint
) { |
| 54 if (!this->prepareToDraw(dst)) { | 52 if (!this->prepareToDraw(dst)) { |
| 55 return; | 53 return; |
| 56 } | 54 } |
| 57 | 55 |
| 58 fDrawTarget->copySurface(dst, src, srcRect, dstPoint); | 56 fDrawTarget->copySurface(dst, src, srcRect, dstPoint); |
| 59 } | 57 } |
| 60 | 58 |
| 61 GrTextContext* GrDrawContext::createTextContext(GrRenderTarget* renderTarget, | 59 GrTextContext* GrDrawContext::createTextContext(GrRenderTarget* renderTarget, |
| 62 const SkDeviceProperties& leakyP
roperties, | 60 const SkDeviceProperties& leakyP
roperties) { |
| 63 bool enableDistanceFieldFonts) { | |
| 64 if (fContext->caps()->shaderCaps()->pathRenderingSupport() && | 61 if (fContext->caps()->shaderCaps()->pathRenderingSupport() && |
| 65 renderTarget->isStencilBufferMultisampled()) { | 62 renderTarget->isStencilBufferMultisampled()) { |
| 66 GrStencilAttachment* sb = renderTarget->renderTargetPriv().attachStencil
Attachment(); | 63 GrStencilAttachment* sb = renderTarget->renderTargetPriv().attachStencil
Attachment(); |
| 67 if (sb) { | 64 if (sb) { |
| 68 return GrStencilAndCoverTextContext::Create(fContext, this, | 65 return GrStencilAndCoverTextContext::Create(fContext, this, leakyPro
perties); |
| 69 leakyProperties, | |
| 70 enableDistanceFieldFonts
); | |
| 71 } | 66 } |
| 72 } | 67 } |
| 73 | 68 |
| 74 return GrAtlasTextContext::Create(fContext, this, leakyProperties, enableDis
tanceFieldFonts); | 69 return GrAtlasTextContext::Create(fContext, this, leakyProperties); |
| 75 } | 70 } |
| 76 | 71 |
| 77 void GrDrawContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPai
nt& grPaint, | 72 void GrDrawContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPai
nt& grPaint, |
| 78 const SkPaint& skPaint, | 73 const SkPaint& skPaint, |
| 79 const SkMatrix& viewMatrix, | 74 const SkMatrix& viewMatrix, |
| 80 const char text[], size_t byteLength, | 75 const char text[], size_t byteLength, |
| 81 SkScalar x, SkScalar y, const SkIRect& clipBounds)
{ | 76 SkScalar x, SkScalar y, const SkIRect& clipBounds)
{ |
| 82 if (!fTextContext) { | 77 if (!fTextContext) { |
| 83 fTextContext = this->createTextContext(rt, *fDevProps, fUseDFT); | 78 fTextContext = this->createTextContext(rt, *fDevProps); |
| 84 } | 79 } |
| 85 | 80 |
| 86 fTextContext->drawText(rt, clip, grPaint, skPaint, viewMatrix, | 81 fTextContext->drawText(rt, clip, grPaint, skPaint, viewMatrix, |
| 87 text, byteLength, x, y, clipBounds); | 82 text, byteLength, x, y, clipBounds); |
| 88 | 83 |
| 89 } | 84 } |
| 90 void GrDrawContext::drawPosText(GrRenderTarget* rt, const GrClip& clip, const Gr
Paint& grPaint, | 85 void GrDrawContext::drawPosText(GrRenderTarget* rt, const GrClip& clip, const Gr
Paint& grPaint, |
| 91 const SkPaint& skPaint, | 86 const SkPaint& skPaint, |
| 92 const SkMatrix& viewMatrix, | 87 const SkMatrix& viewMatrix, |
| 93 const char text[], size_t byteLength, | 88 const char text[], size_t byteLength, |
| 94 const SkScalar pos[], int scalarsPerPosition, | 89 const SkScalar pos[], int scalarsPerPosition, |
| 95 const SkPoint& offset, const SkIRect& clipBounds
) { | 90 const SkPoint& offset, const SkIRect& clipBounds
) { |
| 96 if (!fTextContext) { | 91 if (!fTextContext) { |
| 97 fTextContext = this->createTextContext(rt, *fDevProps, fUseDFT); | 92 fTextContext = this->createTextContext(rt, *fDevProps); |
| 98 } | 93 } |
| 99 | 94 |
| 100 fTextContext->drawPosText(rt, clip, grPaint, skPaint, viewMatrix, text, byte
Length, | 95 fTextContext->drawPosText(rt, clip, grPaint, skPaint, viewMatrix, text, byte
Length, |
| 101 pos, scalarsPerPosition, offset, clipBounds); | 96 pos, scalarsPerPosition, offset, clipBounds); |
| 102 | 97 |
| 103 } | 98 } |
| 104 void GrDrawContext::drawTextBlob(GrRenderTarget* rt, const GrClip& clip, const S
kPaint& skPaint, | 99 void GrDrawContext::drawTextBlob(GrRenderTarget* rt, const GrClip& clip, const S
kPaint& skPaint, |
| 105 const SkMatrix& viewMatrix, const SkTextBlob* b
lob, | 100 const SkMatrix& viewMatrix, const SkTextBlob* b
lob, |
| 106 SkScalar x, SkScalar y, | 101 SkScalar x, SkScalar y, |
| 107 SkDrawFilter* filter, const SkIRect& clipBounds
) { | 102 SkDrawFilter* filter, const SkIRect& clipBounds
) { |
| 108 if (!fTextContext) { | 103 if (!fTextContext) { |
| 109 fTextContext = this->createTextContext(rt, *fDevProps, fUseDFT); | 104 fTextContext = this->createTextContext(rt, *fDevProps); |
| 110 } | 105 } |
| 111 | 106 |
| 112 fTextContext->drawTextBlob(rt, clip, skPaint, viewMatrix, blob, x, y, filter
, clipBounds); | 107 fTextContext->drawTextBlob(rt, clip, skPaint, viewMatrix, blob, x, y, filter
, clipBounds); |
| 113 } | 108 } |
| 114 | 109 |
| 115 void GrDrawContext::drawPaths(GrPipelineBuilder* pipelineBuilder, | 110 void GrDrawContext::drawPaths(GrPipelineBuilder* pipelineBuilder, |
| 116 const GrPathProcessor* pathProc, | 111 const GrPathProcessor* pathProc, |
| 117 const GrPathRange* pathRange, | 112 const GrPathRange* pathRange, |
| 118 const void* indices, | 113 const void* indices, |
| 119 int /*GrDrawTarget::PathIndexType*/ indexType, | 114 int /*GrDrawTarget::PathIndexType*/ indexType, |
| (...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 return DrawVerticesBatch::Create(geometry, type, viewMatrix, | 1328 return DrawVerticesBatch::Create(geometry, type, viewMatrix, |
| 1334 positions.begin(), vertexCount, | 1329 positions.begin(), vertexCount, |
| 1335 indices.begin(), hasIndices ? vertexCount :
0, | 1330 indices.begin(), hasIndices ? vertexCount :
0, |
| 1336 colors.begin(), | 1331 colors.begin(), |
| 1337 texCoords.begin(), | 1332 texCoords.begin(), |
| 1338 bounds); | 1333 bounds); |
| 1339 } | 1334 } |
| 1340 | 1335 |
| 1341 #endif | 1336 #endif |
| 1342 | 1337 |
| OLD | NEW |