OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrStencilAndCoverTextContext.h" | 8 #include "GrStencilAndCoverTextContext.h" |
9 #include "GrBitmapTextContext.h" | 9 #include "GrBitmapTextContext.h" |
10 #include "GrDrawTarget.h" | 10 #include "GrDrawTarget.h" |
11 #include "GrGpu.h" | 11 #include "GrGpu.h" |
12 #include "GrPath.h" | 12 #include "GrPath.h" |
13 #include "GrPathRange.h" | 13 #include "GrPathRange.h" |
14 #include "SkAutoKern.h" | 14 #include "SkAutoKern.h" |
15 #include "SkDraw.h" | 15 #include "SkDraw.h" |
16 #include "SkDrawProcs.h" | 16 #include "SkDrawProcs.h" |
17 #include "SkGlyphCache.h" | 17 #include "SkGlyphCache.h" |
18 #include "SkGpuDevice.h" | 18 #include "SkGpuDevice.h" |
19 #include "SkPath.h" | 19 #include "SkPath.h" |
20 #include "SkTextMapStateProc.h" | 20 #include "SkTextMapStateProc.h" |
21 #include "SkTextFormatParams.h" | 21 #include "SkTextFormatParams.h" |
22 | 22 |
23 GrStencilAndCoverTextContext::GrStencilAndCoverTextContext( | 23 GrStencilAndCoverTextContext::GrStencilAndCoverTextContext(GrContext* context, |
24 GrContext* context, const SkDeviceProperties& properties) | 24 SkGpuDevice* gpuDevic
e, |
25 : GrTextContext(context, properties) | 25 const SkDevicePropert
ies& properties) |
| 26 : GrTextContext(context, gpuDevice, properties) |
26 , fStroke(SkStrokeRec::kFill_InitStyle) | 27 , fStroke(SkStrokeRec::kFill_InitStyle) |
27 , fQueuedGlyphCount(0) | 28 , fQueuedGlyphCount(0) |
28 , fFallbackGlyphsIdx(kGlyphBufferSize) { | 29 , fFallbackGlyphsIdx(kGlyphBufferSize) { |
29 } | 30 } |
30 | 31 |
31 GrStencilAndCoverTextContext* GrStencilAndCoverTextContext::Create(GrContext* co
ntext, | 32 GrStencilAndCoverTextContext* |
32 const SkDeviceP
roperties& props) { | 33 GrStencilAndCoverTextContext::Create(GrContext* context, SkGpuDevice* gpuDevice, |
| 34 const SkDeviceProperties& props) { |
33 GrStencilAndCoverTextContext* textContext = SkNEW_ARGS(GrStencilAndCoverText
Context, | 35 GrStencilAndCoverTextContext* textContext = SkNEW_ARGS(GrStencilAndCoverText
Context, |
34 (context, props)); | 36 (context, gpuDevice,
props)); |
35 textContext->fFallbackTextContext = GrBitmapTextContext::Create(context, pro
ps); | 37 textContext->fFallbackTextContext = GrBitmapTextContext::Create(context, gpu
Device, props); |
36 | 38 |
37 return textContext; | 39 return textContext; |
38 } | 40 } |
39 | 41 |
40 GrStencilAndCoverTextContext::~GrStencilAndCoverTextContext() { | 42 GrStencilAndCoverTextContext::~GrStencilAndCoverTextContext() { |
41 } | 43 } |
42 | 44 |
43 bool GrStencilAndCoverTextContext::canDraw(const SkPaint& paint, const SkMatrix&
viewMatrix) { | 45 bool GrStencilAndCoverTextContext::canDraw(const SkPaint& paint, const SkMatrix&
viewMatrix) { |
44 if (paint.getRasterizer()) { | 46 if (paint.getRasterizer()) { |
45 return false; | 47 return false; |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 fStroke.applyToPaint(&skPaintFallback); | 440 fStroke.applyToPaint(&skPaintFallback); |
439 } | 441 } |
440 skPaintFallback.setTextAlign(SkPaint::kLeft_Align); // Align has already
been accounted for. | 442 skPaintFallback.setTextAlign(SkPaint::kLeft_Align); // Align has already
been accounted for. |
441 skPaintFallback.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 443 skPaintFallback.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
442 | 444 |
443 SkMatrix inverse; | 445 SkMatrix inverse; |
444 if (this->mapToFallbackContext(&inverse)) { | 446 if (this->mapToFallbackContext(&inverse)) { |
445 inverse.mapPoints(&fGlyphPositions[fFallbackGlyphsIdx], fallbackGlyp
hCount); | 447 inverse.mapPoints(&fGlyphPositions[fFallbackGlyphsIdx], fallbackGlyp
hCount); |
446 } | 448 } |
447 | 449 |
448 fFallbackTextContext->drawPosText(fRenderTarget, fClip, paintFallback, s
kPaintFallback, | 450 fFallbackTextContext->onDrawPosText( |
449 fViewMatrix, (char*)&fGlyphIndices[fFa
llbackGlyphsIdx], | 451 fRenderTarget, fClip, paintFallback, skPaintFallback, |
450 2 * fallbackGlyphCount, | 452 fViewMatrix, (char*)&fGlyphIndices[fFallbackGlyphsIdx], |
451 get_xy_scalar_array(&fGlyphPositions[f
FallbackGlyphsIdx]), | 453 2 * fallbackGlyphCount, |
452 2, SkPoint::Make(0, 0)); | 454 get_xy_scalar_array(&fGlyphPositions[fFallbackGlyphsIdx]), |
| 455 2, SkPoint::Make(0, 0)); |
453 | 456 |
454 fFallbackGlyphsIdx = kGlyphBufferSize; | 457 fFallbackGlyphsIdx = kGlyphBufferSize; |
455 } | 458 } |
456 } | 459 } |
457 | 460 |
458 void GrStencilAndCoverTextContext::finish() { | 461 void GrStencilAndCoverTextContext::finish() { |
459 this->flush(); | 462 this->flush(); |
460 | 463 |
461 fGlyphs->unref(); | 464 fGlyphs->unref(); |
462 fGlyphs = NULL; | 465 fGlyphs = NULL; |
463 | 466 |
464 SkGlyphCache::AttachCache(fGlyphCache); | 467 SkGlyphCache::AttachCache(fGlyphCache); |
465 fGlyphCache = NULL; | 468 fGlyphCache = NULL; |
466 | 469 |
467 fPipelineBuilder.stencil()->setDisabled(); | 470 fPipelineBuilder.stencil()->setDisabled(); |
468 fStateRestore.set(NULL); | 471 fStateRestore.set(NULL); |
469 fViewMatrix = fContextInitialMatrix; | 472 fViewMatrix = fContextInitialMatrix; |
470 GrTextContext::finish(); | 473 GrTextContext::finish(); |
471 } | 474 } |
472 | 475 |
OLD | NEW |