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

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

Issue 2195893002: Always return ImageShader, even from SkShader::MakeBitmapShader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update serialize-8888 ignore list: skbug.com/5595 Created 4 years, 4 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
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
8 #ifndef SkBitmapProcShader_DEFINED 7 #ifndef SkBitmapProcShader_DEFINED
9 #define SkBitmapProcShader_DEFINED 8 #define SkBitmapProcShader_DEFINED
10 9
11 #include "SkShader.h" 10 #include "SkShader.h"
12 #include "SkSmallAllocator.h" 11 #include "SkSmallAllocator.h"
13 12
14 struct SkBitmapProcState; 13 struct SkBitmapProcState;
15 class SkBitmapProvider; 14 class SkBitmapProvider;
16 15
17 class SkBitmapProcShader : public SkShader { 16 class SkBitmapProcLegacyShader : public SkShader {
f(malita) 2016/08/02 13:10:27 This is now just a collection of static private he
18 public:
19 SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty,
20 const SkMatrix* localMatrix = nullptr);
21
22 bool isOpaque() const override;
23
24 // SkBitmapProcShader stores bitmap coordinates in a 16bit buffer, as it
25 // communicates between its matrix-proc and its sampler-proc. Until we can
26 // widen that, we have to reject bitmaps that are larger.
27 static bool BitmapIsTooBig(const SkBitmap&);
28
29 SK_TO_STRING_OVERRIDE()
30 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader)
31
32 #if SK_SUPPORT_GPU
33 sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const overri de;
34 #endif
35
36 protected:
37 void flatten(SkWriteBuffer&) const override;
38 size_t onContextSize(const ContextRec& rec) const override {
39 return ContextSize(rec, fRawBitmap.info());
40 }
41 Context* onCreateContext(const ContextRec&, void* storage) const override;
42 bool onIsABitmap(SkBitmap*, SkMatrix*, TileMode*) const override;
43
44 SkBitmap fRawBitmap;
45 uint8_t fTileModeX, fTileModeY;
46
47 private: 17 private:
48 friend class SkImageShader; 18 friend class SkImageShader;
49 19
50 static size_t ContextSize(const ContextRec&, const SkImageInfo& srcInfo); 20 static size_t ContextSize(const ContextRec&, const SkImageInfo& srcInfo);
51 static Context* MakeContext(const SkShader&, TileMode tmx, TileMode tmy, 21 static Context* MakeContext(const SkShader&, TileMode tmx, TileMode tmy,
52 const SkBitmapProvider&, const ContextRec&, void * storage); 22 const SkBitmapProvider&, const ContextRec&, void * storage);
53 23
54 typedef SkShader INHERITED; 24 typedef SkShader INHERITED;
55 }; 25 };
56 26
57 enum {kSkBlitterContextSize = 3332}; 27 enum {kSkBlitterContextSize = 3332};
58 28
59 // Commonly used allocator. It currently is only used to allocate up to 3 object s. The total 29 // Commonly used allocator. It currently is only used to allocate up to 3 object s. The total
60 // bytes requested is calculated using one of our large shaders, its context siz e plus the size of 30 // bytes requested is calculated using one of our large shaders, its context siz e plus the size of
61 // an Sk3DBlitter in SkDraw.cpp 31 // an Sk3DBlitter in SkDraw.cpp
62 // Note that some contexts may contain other contexts (e.g. for compose shaders) , but we've not 32 // Note that some contexts may contain other contexts (e.g. for compose shaders) , but we've not
63 // yet found a situation where the size below isn't big enough. 33 // yet found a situation where the size below isn't big enough.
64 typedef SkSmallAllocator<3, kSkBlitterContextSize> SkTBlitterAllocator; 34 typedef SkSmallAllocator<3, kSkBlitterContextSize> SkTBlitterAllocator;
65 35
66 // If alloc is non-nullptr, it will be used to allocate the returned SkShader, a nd MUST outlive 36 // If alloc is non-nullptr, it will be used to allocate the returned SkShader, a nd MUST outlive
67 // the SkShader. 37 // the SkShader.
68 sk_sp<SkShader> SkMakeBitmapShader(const SkBitmap& src, SkShader::TileMode, SkSh ader::TileMode, 38 sk_sp<SkShader> SkMakeBitmapShader(const SkBitmap& src, SkShader::TileMode, SkSh ader::TileMode,
69 const SkMatrix* localMatrix, SkTBlitterAlloca tor* alloc); 39 const SkMatrix* localMatrix, SkTBlitterAlloca tor* alloc);
70 40
71 #endif 41 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698