1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 #ifndef sw_Blitter_hpp
16 #define sw_Blitter_hpp
18 #include "Surface.hpp"
19 #include "RoutineCache.hpp"
20 #include "Reactor/Reactor.hpp"
28 enum Options : unsigned char
35 WRITE_RGBA = WRITE_RED | WRITE_GREEN | WRITE_BLUE | WRITE_ALPHA,
37 CLEAR_OPERATION = 0x20,
43 bool operator==(const BlitState &state) const
45 return memcmp(this, &state, sizeof(BlitState)) == 0;
50 Blitter::Options options;
78 void clear(void* pixel, sw::Format format, Surface *dest, const SliceRect &dRect, unsigned int rgbaMask);
79 void blit(Surface *source, const SliceRect &sRect, Surface *dest, const SliceRect &dRect, bool filter, bool isStencil = false);
80 void blit3D(Surface *source, Surface *dest);
83 bool fastClear(void* pixel, sw::Format format, Surface *dest, const SliceRect &dRect, unsigned int rgbaMask);
85 bool read(Float4 &color, Pointer<Byte> element, Format format);
86 bool write(Float4 &color, Pointer<Byte> element, Format format, const Blitter::Options& options);
87 bool read(Int4 &color, Pointer<Byte> element, Format format);
88 bool write(Int4 &color, Pointer<Byte> element, Format format, const Blitter::Options& options);
89 static bool GetScale(float4& scale, Format format);
90 static bool ApplyScaleAndClamp(Float4& value, const BlitState& state);
91 static Int ComputeOffset(Int& x, Int& y, Int& pitchB, int bytes, bool quadLayout);
92 void blit(Surface *source, const SliceRect &sRect, Surface *dest, const SliceRect &dRect, const Blitter::Options& options);
93 bool blitReactor(Surface *source, const SliceRect &sRect, Surface *dest, const SliceRect &dRect, const Blitter::Options& options);
94 Routine *generate(BlitState &state);
96 RoutineCache<BlitState> *blitCache;
97 MutexLock criticalSection;
101 #endif // sw_Blitter_hpp