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

Unified Diff: src/core/SkBitmapProcShader.cpp

Issue 1998793002: Make an embeddable container to hold linear pipelines. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove unused defs Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkLinearBitmapPipeline.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapProcShader.cpp
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index ae973a2a5902c31d7aa06158be1edb7652e8cc3c..a372b5199041d9c608d608ecac302ae8f24aced6 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -129,12 +129,11 @@ public:
fFilterQuality = info->fFilterQuality;
fMatrixTypeMask = info->fRealInvMatrix.getType();
- // Need to ensure that our pipeline is created at a 16byte aligned address
- fShaderPipeline = (SkLinearBitmapPipeline*)SkAlign16((intptr_t)fShaderStorage);
- new (fShaderPipeline) SkLinearBitmapPipeline(info->fRealInvMatrix, info->fFilterQuality,
- info->fTileModeX, info->fTileModeY,
- info->fPaintColor,
- info->fPixmap);
+ fShaderPipeline.init(
+ info->fRealInvMatrix, info->fFilterQuality,
+ info->fTileModeX, info->fTileModeY,
+ info->fPaintColor,
+ info->fPixmap);
// To implement the old shadeSpan entry-point, we need to efficiently convert our native
// floats into SkPMColor. The SkXfermode::D32Procs do exactly that.
@@ -143,14 +142,6 @@ public:
fXferProc = SkXfermode::GetD32Proc(xfer.get(), 0);
}
- ~LinearPipelineContext() override {
- // since we did a manual new, we need to manually destroy as well.
- fShaderPipeline->~SkLinearBitmapPipeline();
- if (fBlitterPipeline != nullptr) {
- fBlitterPipeline->~SkLinearBitmapPipeline();
- }
- }
-
void shadeSpan4f(int x, int y, SkPM4f dstC[], int count) override {
fShaderPipeline->shadeSpan4f(x, y, dstC, count);
}
@@ -173,23 +164,19 @@ public:
SkXfermode::Mode mode;
if (!SkXfermode::AsMode(state->fXfer, &mode)) { return false; }
- // Need to ensure that our pipeline is created at a 16byte aligned address
- fBlitterPipeline = (SkLinearBitmapPipeline*)SkAlign16((intptr_t)fBlitterStorage);
if (SkLinearBitmapPipeline::ClonePipelineForBlitting(
- fBlitterPipeline, *fShaderPipeline,
+ &fBlitterPipeline, *fShaderPipeline,
fMatrixTypeMask,
fXMode, fYMode,
fFilterQuality, fSrcPixmap,
fAlpha, mode, dstInfo))
{
- state->fStorage[0] = fBlitterPipeline;
+ state->fStorage[0] = fBlitterPipeline.get();
state->fBlitBW = &LinearPipelineContext::ForwardToPipeline;
return true;
}
- // Did not successfully create a pipeline so don't destruct it.
- fBlitterPipeline = nullptr;
return false;
}
@@ -199,23 +186,16 @@ public:
pipeline->blitSpan(x, y, addr, count);
}
-
private:
- enum {
- kActualSize = sizeof(SkLinearBitmapPipeline),
- kPaddedSize = SkAlignPtr(kActualSize + 12),
- };
- void* fShaderStorage[kPaddedSize / sizeof(void*)];
- SkLinearBitmapPipeline* fShaderPipeline;
- void* fBlitterStorage[kPaddedSize / sizeof(void*)];
- SkLinearBitmapPipeline* fBlitterPipeline{nullptr};
- SkXfermode::D32Proc fXferProc;
- SkPixmap fSrcPixmap;
- float fAlpha;
- SkShader::TileMode fXMode;
- SkShader::TileMode fYMode;
- SkMatrix::TypeMask fMatrixTypeMask;
- SkFilterQuality fFilterQuality;
+ SkEmbeddableLinearPipeline fShaderPipeline;
+ SkEmbeddableLinearPipeline fBlitterPipeline;
+ SkXfermode::D32Proc fXferProc;
+ SkPixmap fSrcPixmap;
+ float fAlpha;
+ SkShader::TileMode fXMode;
+ SkShader::TileMode fYMode;
+ SkMatrix::TypeMask fMatrixTypeMask;
+ SkFilterQuality fFilterQuality;
typedef BitmapProcInfoContext INHERITED;
};
« no previous file with comments | « no previous file | src/core/SkLinearBitmapPipeline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698