OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkBlitter.h" | 8 #include "SkBlitter.h" |
9 #include "SkAntiRun.h" | 9 #include "SkAntiRun.h" |
10 #include "SkColor.h" | 10 #include "SkColor.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 bool SkBlitter::isNullBlitter() const { return false; } | 26 bool SkBlitter::isNullBlitter() const { return false; } |
27 | 27 |
28 bool SkBlitter::resetShaderContext(const SkShader::ContextRec&) { | 28 bool SkBlitter::resetShaderContext(const SkShader::ContextRec&) { |
29 return true; | 29 return true; |
30 } | 30 } |
31 | 31 |
32 SkShader::Context* SkBlitter::getShaderContext() const { | 32 SkShader::Context* SkBlitter::getShaderContext() const { |
33 return NULL; | 33 return NULL; |
34 } | 34 } |
35 | 35 |
36 const SkBitmap* SkBlitter::justAnOpaqueColor(uint32_t* value) { | 36 const SkPixmap* SkBlitter::justAnOpaqueColor(uint32_t* value) { |
37 return NULL; | 37 return NULL; |
38 } | 38 } |
39 | 39 |
40 void SkBlitter::blitH(int x, int y, int width) { | 40 void SkBlitter::blitH(int x, int y, int width) { |
41 SkDEBUGFAIL("unimplemented"); | 41 SkDEBUGFAIL("unimplemented"); |
42 } | 42 } |
43 | 43 |
44 void SkBlitter::blitAntiH(int x, int y, const SkAlpha antialias[], | 44 void SkBlitter::blitAntiH(int x, int y, const SkAlpha antialias[], |
45 const int16_t runs[]) { | 45 const int16_t runs[]) { |
46 SkDEBUGFAIL("unimplemented"); | 46 SkDEBUGFAIL("unimplemented"); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 void SkNullBlitter::blitAntiH(int x, int y, const SkAlpha antialias[], | 237 void SkNullBlitter::blitAntiH(int x, int y, const SkAlpha antialias[], |
238 const int16_t runs[]) {} | 238 const int16_t runs[]) {} |
239 | 239 |
240 void SkNullBlitter::blitV(int x, int y, int height, SkAlpha alpha) {} | 240 void SkNullBlitter::blitV(int x, int y, int height, SkAlpha alpha) {} |
241 | 241 |
242 void SkNullBlitter::blitRect(int x, int y, int width, int height) {} | 242 void SkNullBlitter::blitRect(int x, int y, int width, int height) {} |
243 | 243 |
244 void SkNullBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {} | 244 void SkNullBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {} |
245 | 245 |
246 const SkBitmap* SkNullBlitter::justAnOpaqueColor(uint32_t* value) { | 246 const SkPixmap* SkNullBlitter::justAnOpaqueColor(uint32_t* value) { |
247 return NULL; | 247 return NULL; |
248 } | 248 } |
249 | 249 |
250 bool SkNullBlitter::isNullBlitter() const { return true; } | 250 bool SkNullBlitter::isNullBlitter() const { return true; } |
251 | 251 |
252 /////////////////////////////////////////////////////////////////////////////// | 252 /////////////////////////////////////////////////////////////////////////////// |
253 | 253 |
254 static int compute_anti_width(const int16_t runs[]) { | 254 static int compute_anti_width(const int16_t runs[]) { |
255 int width = 0; | 255 int width = 0; |
256 | 256 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 void SkRectClipBlitter::blitMask(const SkMask& mask, const SkIRect& clip) { | 397 void SkRectClipBlitter::blitMask(const SkMask& mask, const SkIRect& clip) { |
398 SkASSERT(mask.fBounds.contains(clip)); | 398 SkASSERT(mask.fBounds.contains(clip)); |
399 | 399 |
400 SkIRect r = clip; | 400 SkIRect r = clip; |
401 | 401 |
402 if (r.intersect(fClipRect)) { | 402 if (r.intersect(fClipRect)) { |
403 fBlitter->blitMask(mask, r); | 403 fBlitter->blitMask(mask, r); |
404 } | 404 } |
405 } | 405 } |
406 | 406 |
407 const SkBitmap* SkRectClipBlitter::justAnOpaqueColor(uint32_t* value) { | 407 const SkPixmap* SkRectClipBlitter::justAnOpaqueColor(uint32_t* value) { |
408 return fBlitter->justAnOpaqueColor(value); | 408 return fBlitter->justAnOpaqueColor(value); |
409 } | 409 } |
410 | 410 |
411 /////////////////////////////////////////////////////////////////////////////// | 411 /////////////////////////////////////////////////////////////////////////////// |
412 | 412 |
413 void SkRgnClipBlitter::blitH(int x, int y, int width) { | 413 void SkRgnClipBlitter::blitH(int x, int y, int width) { |
414 SkRegion::Spanerator span(*fRgn, y, x, x + width); | 414 SkRegion::Spanerator span(*fRgn, y, x, x + width); |
415 int left, right; | 415 int left, right; |
416 | 416 |
417 while (span.next(&left, &right)) { | 417 while (span.next(&left, &right)) { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 SkRegion::Cliperator iter(*fRgn, clip); | 533 SkRegion::Cliperator iter(*fRgn, clip); |
534 const SkIRect& r = iter.rect(); | 534 const SkIRect& r = iter.rect(); |
535 SkBlitter* blitter = fBlitter; | 535 SkBlitter* blitter = fBlitter; |
536 | 536 |
537 while (!iter.done()) { | 537 while (!iter.done()) { |
538 blitter->blitMask(mask, r); | 538 blitter->blitMask(mask, r); |
539 iter.next(); | 539 iter.next(); |
540 } | 540 } |
541 } | 541 } |
542 | 542 |
543 const SkBitmap* SkRgnClipBlitter::justAnOpaqueColor(uint32_t* value) { | 543 const SkPixmap* SkRgnClipBlitter::justAnOpaqueColor(uint32_t* value) { |
544 return fBlitter->justAnOpaqueColor(value); | 544 return fBlitter->justAnOpaqueColor(value); |
545 } | 545 } |
546 | 546 |
547 /////////////////////////////////////////////////////////////////////////////// | 547 /////////////////////////////////////////////////////////////////////////////// |
548 | 548 |
549 SkBlitter* SkBlitterClipper::apply(SkBlitter* blitter, const SkRegion* clip, | 549 SkBlitter* SkBlitterClipper::apply(SkBlitter* blitter, const SkRegion* clip, |
550 const SkIRect* ir) { | 550 const SkIRect* ir) { |
551 if (clip) { | 551 if (clip) { |
552 const SkIRect& clipR = clip->getBounds(); | 552 const SkIRect& clipR = clip->getBounds(); |
553 | 553 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 private: | 771 private: |
772 // Both pointers are unowned. They will be deleted by SkSmallAllocator. | 772 // Both pointers are unowned. They will be deleted by SkSmallAllocator. |
773 SkBlitter* fProxy; | 773 SkBlitter* fProxy; |
774 SkShader::Context* fShaderContext; | 774 SkShader::Context* fShaderContext; |
775 }; | 775 }; |
776 | 776 |
777 /////////////////////////////////////////////////////////////////////////////// | 777 /////////////////////////////////////////////////////////////////////////////// |
778 | 778 |
779 #include "SkCoreBlitters.h" | 779 #include "SkCoreBlitters.h" |
780 | 780 |
781 SkBlitter* SkBlitter::Choose(const SkBitmap& device, | 781 SkBlitter* SkBlitter::Choose(const SkPixmap& device, |
782 const SkMatrix& matrix, | 782 const SkMatrix& matrix, |
783 const SkPaint& origPaint, | 783 const SkPaint& origPaint, |
784 SkTBlitterAllocator* allocator, | 784 SkTBlitterAllocator* allocator, |
785 bool drawCoverage) { | 785 bool drawCoverage) { |
786 SkASSERT(allocator != NULL); | 786 SkASSERT(allocator != NULL); |
787 | 787 |
788 // which check, in case we're being called by a client with a dummy device | 788 // which check, in case we're being called by a client with a dummy device |
789 // (e.g. they have a bounder that always aborts the draw) | 789 // (e.g. they have a bounder that always aborts the draw) |
790 if (kUnknown_SkColorType == device.colorType() || | 790 if (kUnknown_SkColorType == device.colorType() || |
791 (drawCoverage && (kAlpha_8_SkColorType != device.colorType()))) { | 791 (drawCoverage && (kAlpha_8_SkColorType != device.colorType()))) { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 : INHERITED(shader, SkShader::ContextRec(*rec.fPaint, SkMatrix::I(), NUL
L)) {} | 937 : INHERITED(shader, SkShader::ContextRec(*rec.fPaint, SkMatrix::I(), NUL
L)) {} |
938 | 938 |
939 void shadeSpan(int x, int y, SkPMColor colors[], int count) override { | 939 void shadeSpan(int x, int y, SkPMColor colors[], int count) override { |
940 sk_bzero(colors, count * sizeof(SkPMColor)); | 940 sk_bzero(colors, count * sizeof(SkPMColor)); |
941 } | 941 } |
942 | 942 |
943 private: | 943 private: |
944 typedef SkShader::Context INHERITED; | 944 typedef SkShader::Context INHERITED; |
945 }; | 945 }; |
946 | 946 |
947 SkShaderBlitter::SkShaderBlitter(const SkBitmap& device, const SkPaint& paint, | 947 SkShaderBlitter::SkShaderBlitter(const SkPixmap& device, const SkPaint& paint, |
948 SkShader::Context* shaderContext) | 948 SkShader::Context* shaderContext) |
949 : INHERITED(device) | 949 : INHERITED(device) |
950 , fShader(paint.getShader()) | 950 , fShader(paint.getShader()) |
951 , fShaderContext(shaderContext) { | 951 , fShaderContext(shaderContext) { |
952 SkASSERT(fShader); | 952 SkASSERT(fShader); |
953 SkASSERT(fShaderContext); | 953 SkASSERT(fShaderContext); |
954 | 954 |
955 fShader->ref(); | 955 fShader->ref(); |
956 fShaderFlags = fShaderContext->getFlags(); | 956 fShaderFlags = fShaderContext->getFlags(); |
957 } | 957 } |
(...skipping 11 matching lines...) Expand all Loading... |
969 fShaderContext->~Context(); | 969 fShaderContext->~Context(); |
970 SkShader::Context* ctx = fShader->createContext(rec, (void*)fShaderContext); | 970 SkShader::Context* ctx = fShader->createContext(rec, (void*)fShaderContext); |
971 if (NULL == ctx) { | 971 if (NULL == ctx) { |
972 // Need a valid context in fShaderContext's storage, so we can later (or
our caller) call | 972 // Need a valid context in fShaderContext's storage, so we can later (or
our caller) call |
973 // the in-place destructor. | 973 // the in-place destructor. |
974 SkNEW_PLACEMENT_ARGS(fShaderContext, SkZeroShaderContext, (*fShader, rec
)); | 974 SkNEW_PLACEMENT_ARGS(fShaderContext, SkZeroShaderContext, (*fShader, rec
)); |
975 return false; | 975 return false; |
976 } | 976 } |
977 return true; | 977 return true; |
978 } | 978 } |
OLD | NEW |