diff options
author | 2014-01-02 22:20:49 +0000 | |
---|---|---|
committer | 2014-01-02 22:20:49 +0000 | |
commit | 07adb6359fd137ccb633b2c64ee2287c8edfd701 (patch) | |
tree | 8fcd5e82f36ef31f5c2366f9214f9fb840150fa1 /src/pipe/SkGPipeWrite.cpp | |
parent | 78e7b4e1b928fa69f672be3c743df6d6c3ecbced (diff) |
Function pointers -> templates in SkPictureFlat.
These flatten/unflatten function pointers were driving me nuts when reading the
generated assembly for this code. We don't need the flexibility of function
pointers here, so let's use templates to make it more manageable. You'll
notice we get much better typing now on flatten/unflatten.
BUG=
R=reed@google.com
Author: mtklein@google.com
Review URL: https://codereview.chromium.org/123213004
git-svn-id: http://skia.googlecode.com/svn/trunk@12873 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/pipe/SkGPipeWrite.cpp')
-rw-r--r-- | src/pipe/SkGPipeWrite.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp index 0131ebb876..68acc179e7 100644 --- a/src/pipe/SkGPipeWrite.cpp +++ b/src/pipe/SkGPipeWrite.cpp @@ -150,20 +150,13 @@ const SkFlatData* FlattenableHeap::flatToReplace() const { /////////////////////////////////////////////////////////////////////////////// -class FlatDictionary : public SkFlatDictionary<SkFlattenable> { -public: - FlatDictionary(FlattenableHeap* heap) - : SkFlatDictionary<SkFlattenable>(heap) { - fFlattenProc = &flattenFlattenableProc; - // No need to define fUnflattenProc since the writer will never - // unflatten the data. - } - static void flattenFlattenableProc(SkOrderedWriteBuffer& buffer, - const void* obj) { - buffer.writeFlattenable((SkFlattenable*)obj); +struct SkFlattenableTraits { + static void flatten(SkOrderedWriteBuffer& buffer, const SkFlattenable& flattenable) { + buffer.writeFlattenable(&flattenable); } - + // No need to define unflatten if we never call it. }; +typedef SkFlatDictionary<SkFlattenable, SkFlattenableTraits> FlatDictionary; /////////////////////////////////////////////////////////////////////////////// |