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

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

Issue 2224163005: Made shadows blurry (thru implementing variance mapping) (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: removed extra comments Created 4 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkImageFilter.h" 10 #include "SkImageFilter.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 SkMatrix matrix = SkMatrix::I(); 215 SkMatrix matrix = SkMatrix::I();
216 SkPaint paint; 216 SkPaint paint;
217 bool has_paint = false; // TODO: why is a default pai nt not the same? 217 bool has_paint = false; // TODO: why is a default pai nt not the same?
218 void draw(SkCanvas* c) override { 218 void draw(SkCanvas* c) override {
219 c->drawPicture(picture.get(), &matrix, has_paint ? &paint : nullptr) ; 219 c->drawPicture(picture.get(), &matrix, has_paint ? &paint : nullptr) ;
220 } 220 }
221 void optimizeFor(GrContext* ctx) override { optimize_for(ctx, &paint); } 221 void optimizeFor(GrContext* ctx) override { optimize_for(ctx, &paint); }
222 void makeThreadsafe() override { make_threadsafe(nullptr, &matrix); } 222 void makeThreadsafe() override { make_threadsafe(nullptr, &matrix); }
223 }; 223 };
224 struct DrawShadowedPicture final : Op { 224 struct DrawShadowedPicture final : Op {
225 DrawShadowedPicture(const SkPicture* picture, const SkMatrix* matrix, co nst SkPaint* paint) 225 DrawShadowedPicture(const SkPicture* picture, const SkMatrix* matrix,
226 const SkPaint* paint, SkShadowType sType)
jvanverth1 2016/08/15 16:37:16 const &
vjiaoblack 2016/08/15 17:43:30 Done.
226 : picture(sk_ref_sp(picture)) { 227 : picture(sk_ref_sp(picture)) {
227 if (matrix) { this->matrix = *matrix; } 228 if (matrix) { this->matrix = *matrix; }
228 if (paint) { this->paint = *paint; } 229 if (paint) { this->paint = *paint; }
230 this->sType = sType;
229 } 231 }
230 sk_sp<const SkPicture> picture; 232 sk_sp<const SkPicture> picture;
231 SkMatrix matrix = SkMatrix::I(); 233 SkMatrix matrix = SkMatrix::I();
232 SkPaint paint; 234 SkPaint paint;
235 SkShadowType sType;
233 void draw(SkCanvas* c) override { 236 void draw(SkCanvas* c) override {
234 #ifdef SK_EXPERIMENTAL_SHADOWING 237 #ifdef SK_EXPERIMENTAL_SHADOWING
235 c->drawShadowedPicture(picture.get(), &matrix, &paint); 238 c->drawShadowedPicture(picture.get(), &matrix, &paint, sType);
236 #endif 239 #endif
237 } 240 }
238 void optimizeFor(GrContext* ctx) override { optimize_for(ctx, &paint); } 241 void optimizeFor(GrContext* ctx) override { optimize_for(ctx, &paint); }
239 void makeThreadsafe() override { make_threadsafe(nullptr, &matrix); } 242 void makeThreadsafe() override { make_threadsafe(nullptr, &matrix); }
240 }; 243 };
241 244
242 struct DrawImage final : Op { 245 struct DrawImage final : Op {
243 DrawImage(sk_sp<const SkImage>&& image, SkScalar x, SkScalar y, const Sk Paint* paint) 246 DrawImage(sk_sp<const SkImage>&& image, SkScalar x, SkScalar y, const Sk Paint* paint)
244 : image(image), x(x), y(y) { 247 : image(image), x(x), y(y) {
245 if (paint) { this->paint = *paint; } 248 if (paint) { this->paint = *paint; }
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 void* pod = push<DrawAnnotation>(&fBytes, bytes, rect, value); 537 void* pod = push<DrawAnnotation>(&fBytes, bytes, rect, value);
535 copy_v(pod, key,bytes); 538 copy_v(pod, key,bytes);
536 } 539 }
537 void SkLiteDL::drawDrawable(SkDrawable* drawable, const SkMatrix* matrix) { 540 void SkLiteDL::drawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
538 push<DrawDrawable>(&fBytes, 0, drawable, matrix); 541 push<DrawDrawable>(&fBytes, 0, drawable, matrix);
539 } 542 }
540 void SkLiteDL::drawPicture(const SkPicture* picture, 543 void SkLiteDL::drawPicture(const SkPicture* picture,
541 const SkMatrix* matrix, const SkPaint* paint) { 544 const SkMatrix* matrix, const SkPaint* paint) {
542 push<DrawPicture>(&fBytes, 0, picture, matrix, paint); 545 push<DrawPicture>(&fBytes, 0, picture, matrix, paint);
543 } 546 }
544 void SkLiteDL::drawShadowedPicture(const SkPicture* picture, 547 void SkLiteDL::drawShadowedPicture(const SkPicture* picture, const SkMatrix* mat rix,
545 const SkMatrix* matrix, const SkPaint* paint) { 548 const SkPaint* paint, SkShadowType sType) {
jvanverth1 2016/08/15 16:37:16 const &
vjiaoblack 2016/08/15 17:43:30 Done.
546 push<DrawShadowedPicture>(&fBytes, 0, picture, matrix, paint); 549 push<DrawShadowedPicture>(&fBytes, 0, picture, matrix, paint, sType);
547 } 550 }
548 551
549 void SkLiteDL::drawBitmap(const SkBitmap& bm, SkScalar x, SkScalar y, const SkPa int* paint) { 552 void SkLiteDL::drawBitmap(const SkBitmap& bm, SkScalar x, SkScalar y, const SkPa int* paint) {
550 push<DrawImage>(&fBytes, 0, SkImage::MakeFromBitmap(bm), x,y, paint); 553 push<DrawImage>(&fBytes, 0, SkImage::MakeFromBitmap(bm), x,y, paint);
551 } 554 }
552 void SkLiteDL::drawBitmapNine(const SkBitmap& bm, const SkIRect& center, 555 void SkLiteDL::drawBitmapNine(const SkBitmap& bm, const SkIRect& center,
553 const SkRect& dst, const SkPaint* paint) { 556 const SkRect& dst, const SkPaint* paint) {
554 push<DrawImageNine>(&fBytes, 0, SkImage::MakeFromBitmap(bm), center, dst, pa int); 557 push<DrawImageNine>(&fBytes, 0, SkImage::MakeFromBitmap(bm), center, dst, pa int);
555 } 558 }
556 void SkLiteDL::drawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRec t& dst, 559 void SkLiteDL::drawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRec t& dst,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 } 717 }
715 718
716 void SkLiteDL::PurgeFreelist() { 719 void SkLiteDL::PurgeFreelist() {
717 SkAutoMutexAcquire lock(gFreeStackLock); 720 SkAutoMutexAcquire lock(gFreeStackLock);
718 while (gFreeStack) { 721 while (gFreeStack) {
719 SkLiteDL* top = gFreeStack; 722 SkLiteDL* top = gFreeStack;
720 gFreeStack = gFreeStack->fNext; 723 gFreeStack = gFreeStack->fNext;
721 delete top; // Calling unref() here would just put it back on the list ! 724 delete top; // Calling unref() here would just put it back on the list !
722 } 725 }
723 } 726 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698