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

Side by Side Diff: src/core/SkBitmapProcShader.h

Issue 1343123005: use SkBitmapProvider for shader-context (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: restore privacy Created 5 years, 3 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/SkBitmapController.h ('k') | src/core/SkBitmapProcShader.cpp » ('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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkBitmapProcShader_DEFINED 10 #ifndef SkBitmapProcShader_DEFINED
11 #define SkBitmapProcShader_DEFINED 11 #define SkBitmapProcShader_DEFINED
12 12
13 #include "SkShader.h" 13 #include "SkShader.h"
14 #include "SkSmallAllocator.h" 14 #include "SkSmallAllocator.h"
15 15
16 struct SkBitmapProcState; 16 struct SkBitmapProcState;
17 17
18 class SkBitmapProcShader : public SkShader { 18 class SkBitmapProcShader : public SkShader {
19 public: 19 public:
20 SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty, 20 SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty,
21 const SkMatrix* localMatrix = nullptr); 21 const SkMatrix* localMatrix = nullptr);
22 22
23 bool isOpaque() const override; 23 bool isOpaque() const override;
24 24
25 size_t contextSize() const override; 25 size_t contextSize() const override { return ContextSize(); }
26 26
27 SK_TO_STRING_OVERRIDE() 27 SK_TO_STRING_OVERRIDE()
28 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) 28 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader)
29 29
30 #if SK_SUPPORT_GPU 30 #if SK_SUPPORT_GPU
31 const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& v iewM, 31 const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& v iewM,
32 const SkMatrix*, SkFilterQual ity, 32 const SkMatrix*, SkFilterQual ity,
33 GrProcessorDataManager*) cons t override; 33 GrProcessorDataManager*) cons t override;
34 #endif 34 #endif
35 35
36 protected:
36 class BitmapProcShaderContext : public SkShader::Context { 37 class BitmapProcShaderContext : public SkShader::Context {
37 public: 38 public:
38 // The context takes ownership of the state. It will call its destructor 39 // The context takes ownership of the state. It will call its destructor
39 // but will NOT free the memory. 40 // but will NOT free the memory.
40 BitmapProcShaderContext(const SkBitmapProcShader&, const ContextRec&, Sk BitmapProcState*); 41 BitmapProcShaderContext(const SkShader&, const ContextRec&, SkBitmapProc State*);
41 ~BitmapProcShaderContext() override; 42 ~BitmapProcShaderContext() override;
42 43
43 void shadeSpan(int x, int y, SkPMColor dstC[], int count) override; 44 void shadeSpan(int x, int y, SkPMColor dstC[], int count) override;
44 ShadeProc asAShadeProc(void** ctx) override; 45 ShadeProc asAShadeProc(void** ctx) override;
45 void shadeSpan16(int x, int y, uint16_t dstC[], int count) override; 46 void shadeSpan16(int x, int y, uint16_t dstC[], int count) override;
46 47
47 uint32_t getFlags() const override { return fFlags; } 48 uint32_t getFlags() const override { return fFlags; }
48 49
49 private: 50 private:
50 SkBitmapProcState* fState; 51 SkBitmapProcState* fState;
51 uint32_t fFlags; 52 uint32_t fFlags;
52 53
53 typedef SkShader::Context INHERITED; 54 typedef SkShader::Context INHERITED;
54 }; 55 };
55 56
56 protected:
57 void flatten(SkWriteBuffer&) const override; 57 void flatten(SkWriteBuffer&) const override;
58 Context* onCreateContext(const ContextRec&, void* storage) const override; 58 Context* onCreateContext(const ContextRec&, void* storage) const override;
59 bool onIsABitmap(SkBitmap*, SkMatrix*, TileMode*) const override; 59 bool onIsABitmap(SkBitmap*, SkMatrix*, TileMode*) const override;
60 60
61 SkBitmap fRawBitmap; // experimental for RLE encoding 61 SkBitmap fRawBitmap; // experimental for RLE encoding
62 uint8_t fTileModeX, fTileModeY; 62 uint8_t fTileModeX, fTileModeY;
63 63
64 private: 64 private:
65 friend class SkImageShader;
66
67 static size_t ContextSize();
68 static Context* MakeContext(const SkShader&, TileMode tmx, TileMode tmy, con st SkBitmap&,
69 const ContextRec&, void* storage);
70
65 typedef SkShader INHERITED; 71 typedef SkShader INHERITED;
66 }; 72 };
67 73
68 // Commonly used allocator. It currently is only used to allocate up to 3 object s. The total 74 // Commonly used allocator. It currently is only used to allocate up to 3 object s. The total
69 // bytes requested is calculated using one of our large shaders, its context siz e plus the size of 75 // bytes requested is calculated using one of our large shaders, its context siz e plus the size of
70 // an Sk3DBlitter in SkDraw.cpp 76 // an Sk3DBlitter in SkDraw.cpp
71 // Note that some contexts may contain other contexts (e.g. for compose shaders) , but we've not 77 // Note that some contexts may contain other contexts (e.g. for compose shaders) , but we've not
72 // yet found a situation where the size below isn't big enough. 78 // yet found a situation where the size below isn't big enough.
73 typedef SkSmallAllocator<3, 1152> SkTBlitterAllocator; 79 typedef SkSmallAllocator<3, 1160> SkTBlitterAllocator;
74 80
75 // If alloc is non-nullptr, it will be used to allocate the returned SkShader, a nd MUST outlive 81 // If alloc is non-nullptr, it will be used to allocate the returned SkShader, a nd MUST outlive
76 // the SkShader. 82 // the SkShader.
77 SkShader* SkCreateBitmapShader(const SkBitmap& src, SkShader::TileMode, SkShader ::TileMode, 83 SkShader* SkCreateBitmapShader(const SkBitmap& src, SkShader::TileMode, SkShader ::TileMode,
78 const SkMatrix* localMatrix, SkTBlitterAllocator* alloc); 84 const SkMatrix* localMatrix, SkTBlitterAllocator* alloc);
79 85
80 #endif 86 #endif
OLDNEW
« no previous file with comments | « src/core/SkBitmapController.h ('k') | src/core/SkBitmapProcShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698