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

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

Issue 2488523003: Make SkSmallAllocator obey the RAII invariants and be expandable (Closed)
Patch Set: fix includes Created 4 years, 1 month 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 | « no previous file | src/core/SkCanvas.cpp » ('j') | src/core/SkSmallAllocator.h » ('J')
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 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 /* 889 /*
890 * We create a SkShader::Context object, and store it on the blitter. 890 * We create a SkShader::Context object, and store it on the blitter.
891 */ 891 */
892 SkShader::Context* shaderContext = nullptr; 892 SkShader::Context* shaderContext = nullptr;
893 if (shader) { 893 if (shader) {
894 const SkShader::ContextRec rec(*paint, matrix, nullptr, 894 const SkShader::ContextRec rec(*paint, matrix, nullptr,
895 PreferredShaderDest(device.info())); 895 PreferredShaderDest(device.info()));
896 size_t contextSize = shader->contextSize(rec); 896 size_t contextSize = shader->contextSize(rec);
897 if (contextSize) { 897 if (contextSize) {
898 // Try to create the ShaderContext 898 // Try to create the ShaderContext
899 void* storage = allocator->reserveT<SkShader::Context>(contextSize); 899 shaderContext = allocator->createWithIniterT<SkShader::Context>(
900 shaderContext = shader->createContext(rec, storage); 900 contextSize,
901 [&rec, shader](void* storage) {
902 return shader->createContext(rec, storage);
903 });
901 if (!shaderContext) { 904 if (!shaderContext) {
902 allocator->freeLast();
903 return allocator->createT<SkNullBlitter>(); 905 return allocator->createT<SkNullBlitter>();
904 } 906 }
905 SkASSERT(shaderContext); 907 SkASSERT(shaderContext);
906 SkASSERT((void*) shaderContext == storage);
907 } else { 908 } else {
908 return allocator->createT<SkNullBlitter>(); 909 return allocator->createT<SkNullBlitter>();
909 } 910 }
910 } 911 }
911 912
912 SkBlitter* blitter = nullptr; 913 SkBlitter* blitter = nullptr;
913 switch (device.colorType()) { 914 switch (device.colorType()) {
914 case kAlpha_8_SkColorType: 915 case kAlpha_8_SkColorType:
915 if (drawCoverage) { 916 if (drawCoverage) {
916 SkASSERT(nullptr == shader); 917 SkASSERT(nullptr == shader);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 fShaderContext->~Context(); 1015 fShaderContext->~Context();
1015 SkShader::Context* ctx = fShader->createContext(rec, (void*)fShaderContext); 1016 SkShader::Context* ctx = fShader->createContext(rec, (void*)fShaderContext);
1016 if (nullptr == ctx) { 1017 if (nullptr == ctx) {
1017 // Need a valid context in fShaderContext's storage, so we can later (or our caller) call 1018 // Need a valid context in fShaderContext's storage, so we can later (or our caller) call
1018 // the in-place destructor. 1019 // the in-place destructor.
1019 new (fShaderContext) SkZeroShaderContext(*fShader, rec); 1020 new (fShaderContext) SkZeroShaderContext(*fShader, rec);
1020 return false; 1021 return false;
1021 } 1022 }
1022 return true; 1023 return true;
1023 } 1024 }
OLDNEW
« no previous file with comments | « no previous file | src/core/SkCanvas.cpp » ('j') | src/core/SkSmallAllocator.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698