Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(890)

Side by Side Diff: src/core/SkBlitter.cpp

Issue 563563002: make set3DMask virtual, so we can safely notify the shadercontext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ad gm Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkBitmapProcShader.h ('k') | src/core/SkFilterShader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 fPMColor = SkPreMultiplyColor(rec.fPaint->getColor()); 613 fPMColor = SkPreMultiplyColor(rec.fPaint->getColor());
614 } 614 }
615 } 615 }
616 616
617 virtual ~Sk3DShaderContext() { 617 virtual ~Sk3DShaderContext() {
618 if (fProxyContext) { 618 if (fProxyContext) {
619 fProxyContext->~Context(); 619 fProxyContext->~Context();
620 } 620 }
621 } 621 }
622 622
623 void setMask(const SkMask* mask) { fMask = mask; } 623 virtual void set3DMask(const SkMask* mask) SK_OVERRIDE { fMask = mask; }
624 624
625 virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVE RRIDE { 625 virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVE RRIDE {
626 if (fProxyContext) { 626 if (fProxyContext) {
627 fProxyContext->shadeSpan(x, y, span, count); 627 fProxyContext->shadeSpan(x, y, span, count);
628 } 628 }
629 629
630 if (fMask == NULL) { 630 if (fMask == NULL) {
631 if (fProxyContext == NULL) { 631 if (fProxyContext == NULL) {
632 sk_memset32(span, fPMColor, count); 632 sk_memset32(span, fPMColor, count);
633 } 633 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 typedef SkShader INHERITED; 733 typedef SkShader INHERITED;
734 }; 734 };
735 735
736 SkFlattenable* Sk3DShader::CreateProc(SkReadBuffer& buffer) { 736 SkFlattenable* Sk3DShader::CreateProc(SkReadBuffer& buffer) {
737 SkAutoTUnref<SkShader> shader(buffer.readShader()); 737 SkAutoTUnref<SkShader> shader(buffer.readShader());
738 return SkNEW_ARGS(Sk3DShader, (shader)); 738 return SkNEW_ARGS(Sk3DShader, (shader));
739 } 739 }
740 740
741 class Sk3DBlitter : public SkBlitter { 741 class Sk3DBlitter : public SkBlitter {
742 public: 742 public:
743 Sk3DBlitter(SkBlitter* proxy, Sk3DShader::Sk3DShaderContext* shaderContext) 743 Sk3DBlitter(SkBlitter* proxy, SkShader::Context* shaderContext)
744 : fProxy(proxy) 744 : fProxy(proxy)
745 , f3DShaderContext(shaderContext) 745 , fShaderContext(shaderContext)
746 {} 746 {}
747 747
748 virtual void blitH(int x, int y, int width) { 748 virtual void blitH(int x, int y, int width) {
749 fProxy->blitH(x, y, width); 749 fProxy->blitH(x, y, width);
750 } 750 }
751 751
752 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], 752 virtual void blitAntiH(int x, int y, const SkAlpha antialias[],
753 const int16_t runs[]) { 753 const int16_t runs[]) {
754 fProxy->blitAntiH(x, y, antialias, runs); 754 fProxy->blitAntiH(x, y, antialias, runs);
755 } 755 }
756 756
757 virtual void blitV(int x, int y, int height, SkAlpha alpha) { 757 virtual void blitV(int x, int y, int height, SkAlpha alpha) {
758 fProxy->blitV(x, y, height, alpha); 758 fProxy->blitV(x, y, height, alpha);
759 } 759 }
760 760
761 virtual void blitRect(int x, int y, int width, int height) { 761 virtual void blitRect(int x, int y, int width, int height) {
762 fProxy->blitRect(x, y, width, height); 762 fProxy->blitRect(x, y, width, height);
763 } 763 }
764 764
765 virtual void blitMask(const SkMask& mask, const SkIRect& clip) { 765 virtual void blitMask(const SkMask& mask, const SkIRect& clip) {
766 if (mask.fFormat == SkMask::k3D_Format) { 766 if (mask.fFormat == SkMask::k3D_Format) {
767 f3DShaderContext->setMask(&mask); 767 fShaderContext->set3DMask(&mask);
768 768
769 ((SkMask*)&mask)->fFormat = SkMask::kA8_Format; 769 ((SkMask*)&mask)->fFormat = SkMask::kA8_Format;
770 fProxy->blitMask(mask, clip); 770 fProxy->blitMask(mask, clip);
771 ((SkMask*)&mask)->fFormat = SkMask::k3D_Format; 771 ((SkMask*)&mask)->fFormat = SkMask::k3D_Format;
772 772
773 f3DShaderContext->setMask(NULL); 773 fShaderContext->set3DMask(NULL);
774 } else { 774 } else {
775 fProxy->blitMask(mask, clip); 775 fProxy->blitMask(mask, clip);
776 } 776 }
777 } 777 }
778 778
779 private: 779 private:
780 // Both pointers are unowned. They will be deleted by SkSmallAllocator. 780 // Both pointers are unowned. They will be deleted by SkSmallAllocator.
781 SkBlitter* fProxy; 781 SkBlitter* fProxy;
782 Sk3DShader::Sk3DShaderContext* f3DShaderContext; 782 SkShader::Context* fShaderContext;
783 }; 783 };
784 784
785 /////////////////////////////////////////////////////////////////////////////// 785 ///////////////////////////////////////////////////////////////////////////////
786 786
787 #include "SkCoreBlitters.h" 787 #include "SkCoreBlitters.h"
788 788
789 static bool just_solid_color(const SkPaint& paint) { 789 static bool just_solid_color(const SkPaint& paint) {
790 if (paint.getAlpha() == 0xFF && paint.getColorFilter() == NULL) { 790 if (paint.getAlpha() == 0xFF && paint.getColorFilter() == NULL) {
791 SkShader* shader = paint.getShader(); 791 SkShader* shader = paint.getShader();
792 if (NULL == shader) { 792 if (NULL == shader) {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 980
981 default: 981 default:
982 SkDEBUGFAIL("unsupported device config"); 982 SkDEBUGFAIL("unsupported device config");
983 blitter = allocator->createT<SkNullBlitter>(); 983 blitter = allocator->createT<SkNullBlitter>();
984 break; 984 break;
985 } 985 }
986 986
987 if (shader3D) { 987 if (shader3D) {
988 SkBlitter* innerBlitter = blitter; 988 SkBlitter* innerBlitter = blitter;
989 // innerBlitter was allocated by allocator, which will delete it. 989 // innerBlitter was allocated by allocator, which will delete it.
990 // We know shaderContext is of type Sk3DShaderContext because it belongs to shader3D. 990 // We know shaderContext or its proxies is of type Sk3DShaderContext, so we need to
991 blitter = allocator->createT<Sk3DBlitter>(innerBlitter, 991 // wrapper the blitter to notify it when we see an emboss mask.
992 static_cast<Sk3DShader::Sk3DShaderContext*>(shaderContext)); 992 blitter = allocator->createT<Sk3DBlitter>(innerBlitter, shaderContext);
993 } 993 }
994 return blitter; 994 return blitter;
995 } 995 }
996 996
997 /////////////////////////////////////////////////////////////////////////////// 997 ///////////////////////////////////////////////////////////////////////////////
998 998
999 class SkTransparentShaderContext : public SkShader::Context { 999 class SkTransparentShaderContext : public SkShader::Context {
1000 public: 1000 public:
1001 SkTransparentShaderContext(const SkShader& shader, const SkShader::ContextRe c& rec) 1001 SkTransparentShaderContext(const SkShader& shader, const SkShader::ContextRe c& rec)
1002 // Override rec with the identity matrix, so it is guaranteed to be inve rtible. 1002 // Override rec with the identity matrix, so it is guaranteed to be inve rtible.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 fShaderContext->~Context(); 1035 fShaderContext->~Context();
1036 SkShader::Context* ctx = fShader->createContext(rec, (void*)fShaderContext); 1036 SkShader::Context* ctx = fShader->createContext(rec, (void*)fShaderContext);
1037 if (NULL == ctx) { 1037 if (NULL == ctx) {
1038 // Need a valid context in fShaderContext's storage, so we can later (or our caller) call 1038 // Need a valid context in fShaderContext's storage, so we can later (or our caller) call
1039 // the in-place destructor. 1039 // the in-place destructor.
1040 SkNEW_PLACEMENT_ARGS(fShaderContext, SkTransparentShaderContext, (*fShad er, rec)); 1040 SkNEW_PLACEMENT_ARGS(fShaderContext, SkTransparentShaderContext, (*fShad er, rec));
1041 return false; 1041 return false;
1042 } 1042 }
1043 return true; 1043 return true;
1044 } 1044 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcShader.h ('k') | src/core/SkFilterShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698