blob: edb9864270791ee99c759d5603de74f3c11ef585 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001/*
2 * Copyright 2006 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
reed@android.com8a1c16f2008-12-17 15:59:43 +00007#ifndef SkBitmapProcShader_DEFINED
8#define SkBitmapProcShader_DEFINED
9
reed1ec04d92016-08-05 12:07:41 -070010#include "SkImagePriv.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000011#include "SkShader.h"
commit-bot@chromium.orga5572e52014-03-07 03:24:41 +000012#include "SkSmallAllocator.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000013
bungemanf3c15b72015-08-19 11:56:48 -070014struct SkBitmapProcState;
reed013e9e32015-09-15 14:46:27 -070015class SkBitmapProvider;
bungemanf3c15b72015-08-19 11:56:48 -070016
reed320a40d2016-08-02 06:12:06 -070017class SkBitmapProcLegacyShader : public SkShader {
reed@google.com7c2f27d2011-03-07 19:29:00 +000018private:
reed7a4d8472015-09-15 13:33:58 -070019 friend class SkImageShader;
20
reedd8829012016-03-04 11:07:43 -080021 static size_t ContextSize(const ContextRec&, const SkImageInfo& srcInfo);
reed013e9e32015-09-15 14:46:27 -070022 static Context* MakeContext(const SkShader&, TileMode tmx, TileMode tmy,
23 const SkBitmapProvider&, const ContextRec&, void* storage);
reed7a4d8472015-09-15 13:33:58 -070024
reed@android.com8a1c16f2008-12-17 15:59:43 +000025 typedef SkShader INHERITED;
26};
27
herb86a6c6d2016-07-22 14:06:27 -070028enum {kSkBlitterContextSize = 3332};
herb42da45d2016-04-08 14:24:37 -070029
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +000030// Commonly used allocator. It currently is only used to allocate up to 3 objects. The total
31// bytes requested is calculated using one of our large shaders, its context size plus the size of
32// an Sk3DBlitter in SkDraw.cpp
33// Note that some contexts may contain other contexts (e.g. for compose shaders), but we've not
34// yet found a situation where the size below isn't big enough.
herb42da45d2016-04-08 14:24:37 -070035typedef SkSmallAllocator<3, kSkBlitterContextSize> SkTBlitterAllocator;
commit-bot@chromium.orga5572e52014-03-07 03:24:41 +000036
halcanary96fcdcc2015-08-27 07:41:13 -070037// If alloc is non-nullptr, it will be used to allocate the returned SkShader, and MUST outlive
commit-bot@chromium.orga5572e52014-03-07 03:24:41 +000038// the SkShader.
reed8a21c9f2016-03-08 18:50:00 -080039sk_sp<SkShader> SkMakeBitmapShader(const SkBitmap& src, SkShader::TileMode, SkShader::TileMode,
reed1ec04d92016-08-05 12:07:41 -070040 const SkMatrix* localMatrix, SkCopyPixelsMode,
41 SkTBlitterAllocator* alloc);
commit-bot@chromium.orga5572e52014-03-07 03:24:41 +000042
reed@android.com8a1c16f2008-12-17 15:59:43 +000043#endif