Esempio n. 1
0
        }                                                                           // For diagnostics really

        public void Construct()
        {
            // The default allocs refer to four startup pages to be allocated as below from the atlas
            // once the atlas is used for the first time. The page coordinates correspond to the atlas's
            // internal algorithm's results. If that algorithm changes, the new results must be put here to match
            m_OpacityAllocator = m_ColorAllocator = m_ClipRectAllocator = m_TransformAllocator = m_TextSettingsAllocator = new BitmapAllocator32();
            m_TransformAllocator.Construct(pageHeight, 1, 3);
            m_TransformAllocator.ForceFirstAlloc((ushort)identityTransformTexel.x, (ushort)identityTransformTexel.y);
            m_ClipRectAllocator.Construct(pageHeight);
            m_ClipRectAllocator.ForceFirstAlloc((ushort)infiniteClipRectTexel.x, (ushort)infiniteClipRectTexel.y);
            m_OpacityAllocator.Construct(pageHeight);
            m_OpacityAllocator.ForceFirstAlloc((ushort)fullOpacityTexel.x, (ushort)fullOpacityTexel.y);
            m_ColorAllocator.Construct(pageHeight);
            m_ColorAllocator.ForceFirstAlloc((ushort)clearColorTexel.x, (ushort)clearColorTexel.y);
            m_TextSettingsAllocator.Construct(pageHeight, 1, 4);
            m_TextSettingsAllocator.ForceFirstAlloc((ushort)defaultTextCoreSettingsTexel.x, (ushort)defaultTextCoreSettingsTexel.y);

            m_VertexTexturingEnabled = UIRenderDevice.vertexTexturingIsAvailable;
            if (!m_VertexTexturingEnabled)
            {
                int constantCount = 20; // Once custom materials are exposed, this number must be parameterized
                // Note that we can't do a lazy late allocation on the constants array size here (e.g. allocate only the default entry)
                // because once the material receives an array parameter value for the first time, it clings to its size and never
                // allows size changes afterwards without recreating the material, so we need to get the size right pessimistically
                m_Transforms    = new NativeArray <Transform3x4>(constantCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
                m_ClipRects     = new NativeArray <Vector4>(constantCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
                m_Transforms[0] = new Transform3x4()
                {
                    v0 = identityTransformRow0Value, v1 = identityTransformRow1Value, v2 = identityTransformRow2Value
                };
                m_ClipRects[0] = infiniteClipRectValue;
            }
        }
Esempio n. 2
0
 public void SetTransformValue(BMPAlloc alloc, Matrix4x4 xform)
 {
     Debug.Assert(alloc.IsValid());
     if (m_VertexTexturingEnabled)
     {
         var allocXY = AllocToTexelCoord(ref m_TransformAllocator, alloc);
         m_Storage.SetTexel(allocXY.x, allocXY.y + 0, xform.GetRow(0));
         m_Storage.SetTexel(allocXY.x, allocXY.y + 1, xform.GetRow(1));
         m_Storage.SetTexel(allocXY.x, allocXY.y + 2, xform.GetRow(2));
     }
     else
     {
         m_Transforms[AllocToConstantBufferIndex(alloc)] = new Transform3x4()
         {
             v0 = xform.GetRow(0),
             v1 = xform.GetRow(1),
             v2 = xform.GetRow(2)
         }
     };
 }
Esempio n. 3
0
 public void SetTransformValue(BMPAlloc alloc, Matrix4x4 xform)
 {
     Debug.Assert(alloc.IsValid());
     if (m_VertexTexturingEnabled)
     {
         var allocXY = AllocToTexelCoord(ref m_TransformAllocator, alloc);
         m_Atlas.EnqueueBlit(UIRenderDevice.whiteTexel, allocXY.x, allocXY.y + 0, false, xform.GetRow(0));
         m_Atlas.EnqueueBlit(UIRenderDevice.whiteTexel, allocXY.x, allocXY.y + 1, false, xform.GetRow(1));
         m_Atlas.EnqueueBlit(UIRenderDevice.whiteTexel, allocXY.x, allocXY.y + 2, false, xform.GetRow(2));
     }
     else
     {
         m_Transforms[AllocToConstantBufferIndex(alloc)] = new Transform3x4()
         {
             v0 = xform.GetRow(0),
             v1 = xform.GetRow(1),
             v2 = xform.GetRow(2)
         }
     };
 }