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

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

Issue 1720933002: Add ContextRec param to SkShader::contextSize() (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: ContextRec plumbing only Created 4 years, 10 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/SkColorFilterShader.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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 class Sk3DShader : public SkShader { 585 class Sk3DShader : public SkShader {
586 public: 586 public:
587 Sk3DShader(SkShader* proxy) : fProxy(proxy) { 587 Sk3DShader(SkShader* proxy) : fProxy(proxy) {
588 SkSafeRef(proxy); 588 SkSafeRef(proxy);
589 } 589 }
590 590
591 virtual ~Sk3DShader() { 591 virtual ~Sk3DShader() {
592 SkSafeUnref(fProxy); 592 SkSafeUnref(fProxy);
593 } 593 }
594 594
595 size_t contextSize() const override { 595 size_t contextSize(const ContextRec& rec) const override {
596 size_t size = sizeof(Sk3DShaderContext); 596 size_t size = sizeof(Sk3DShaderContext);
597 if (fProxy) { 597 if (fProxy) {
598 size += fProxy->contextSize(); 598 size += fProxy->contextSize(rec);
599 } 599 }
600 return size; 600 return size;
601 } 601 }
602 602
603 Context* onCreateContext(const ContextRec& rec, void* storage) const overrid e { 603 Context* onCreateContext(const ContextRec& rec, void* storage) const overrid e {
604 SkShader::Context* proxyContext = nullptr; 604 SkShader::Context* proxyContext = nullptr;
605 if (fProxy) { 605 if (fProxy) {
606 char* proxyContextStorage = (char*) storage + sizeof(Sk3DShaderConte xt); 606 char* proxyContextStorage = (char*) storage + sizeof(Sk3DShaderConte xt);
607 proxyContext = fProxy->createContext(rec, proxyContextStorage); 607 proxyContext = fProxy->createContext(rec, proxyContextStorage);
608 if (!proxyContext) { 608 if (!proxyContext) {
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 // blitters should ignore the presence/absence of a filter, since 869 // blitters should ignore the presence/absence of a filter, since
870 // if there is one, the shader will take care of it. 870 // if there is one, the shader will take care of it.
871 } 871 }
872 872
873 /* 873 /*
874 * We create a SkShader::Context object, and store it on the blitter. 874 * We create a SkShader::Context object, and store it on the blitter.
875 */ 875 */
876 SkShader::Context* shaderContext = nullptr; 876 SkShader::Context* shaderContext = nullptr;
877 if (shader) { 877 if (shader) {
878 SkShader::ContextRec rec(*paint, matrix, nullptr); 878 SkShader::ContextRec rec(*paint, matrix, nullptr);
879 size_t contextSize = shader->contextSize(); 879 size_t contextSize = shader->contextSize(rec);
880 if (contextSize) { 880 if (contextSize) {
881 // Try to create the ShaderContext 881 // Try to create the ShaderContext
882 void* storage = allocator->reserveT<SkShader::Context>(contextSize); 882 void* storage = allocator->reserveT<SkShader::Context>(contextSize);
883 shaderContext = shader->createContext(rec, storage); 883 shaderContext = shader->createContext(rec, storage);
884 if (!shaderContext) { 884 if (!shaderContext) {
885 allocator->freeLast(); 885 allocator->freeLast();
886 return allocator->createT<SkNullBlitter>(); 886 return allocator->createT<SkNullBlitter>();
887 } 887 }
888 SkASSERT(shaderContext); 888 SkASSERT(shaderContext);
889 SkASSERT((void*) shaderContext == storage); 889 SkASSERT((void*) shaderContext == storage);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 fShaderContext->~Context(); 997 fShaderContext->~Context();
998 SkShader::Context* ctx = fShader->createContext(rec, (void*)fShaderContext); 998 SkShader::Context* ctx = fShader->createContext(rec, (void*)fShaderContext);
999 if (nullptr == ctx) { 999 if (nullptr == ctx) {
1000 // Need a valid context in fShaderContext's storage, so we can later (or our caller) call 1000 // Need a valid context in fShaderContext's storage, so we can later (or our caller) call
1001 // the in-place destructor. 1001 // the in-place destructor.
1002 new (fShaderContext) SkZeroShaderContext(*fShader, rec); 1002 new (fShaderContext) SkZeroShaderContext(*fShader, rec);
1003 return false; 1003 return false;
1004 } 1004 }
1005 return true; 1005 return true;
1006 } 1006 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcShader.h ('k') | src/core/SkColorFilterShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698