Browse Source

Reversing BGRA addition

JoshEngebretson 10 years ago
parent
commit
a77280bd95

+ 1 - 5
Resources/CoreData/Shaders/HLSL/Basic.hlsl

@@ -73,11 +73,7 @@ void PS(
             if (diffInput.a < 0.5)
             if (diffInput.a < 0.5)
                 discard;
                 discard;
         #endif
         #endif
-        #ifdef DIFFMAPBGRA
-          oColor = diffColor * float4(diffInput.b, diffInput.g, diffInput.r, diffInput.a);
-        #else
-          oColor = diffColor * diffInput;
-        #endif
+        oColor = diffColor * diffInput;
     #endif
     #endif
     #ifdef ALPHAMAP
     #ifdef ALPHAMAP
         float alphaInput = Sample2D(DiffMap, iTexCoord).a;
         float alphaInput = Sample2D(DiffMap, iTexCoord).a;

+ 3 - 8
Source/Atomic/UI/UI.cpp

@@ -343,8 +343,6 @@ void UI::Render(VertexBuffer* buffer, const PODVector<UIBatch>& batches, unsigne
     ShaderVariation* diffMaskTexturePS = graphics_->GetShader(PS, "Basic", "DIFFMAP ALPHAMASK VERTEXCOLOR");
     ShaderVariation* diffMaskTexturePS = graphics_->GetShader(PS, "Basic", "DIFFMAP ALPHAMASK VERTEXCOLOR");
     ShaderVariation* alphaTexturePS = graphics_->GetShader(PS, "Basic", "ALPHAMAP VERTEXCOLOR");
     ShaderVariation* alphaTexturePS = graphics_->GetShader(PS, "Basic", "ALPHAMAP VERTEXCOLOR");
 
 
-    ShaderVariation* diffmapBGRAPS = graphics_->GetShader(PS, "Basic", "DIFFMAP VERTEXCOLOR DIFFMAPBGRA");
-
     unsigned alphaFormat = Graphics::GetAlphaFormat();
     unsigned alphaFormat = Graphics::GetAlphaFormat();
 
 
     for (unsigned i = batchStart; i < batchEnd; ++i)
     for (unsigned i = batchStart; i < batchEnd; ++i)
@@ -366,9 +364,7 @@ void UI::Render(VertexBuffer* buffer, const PODVector<UIBatch>& batches, unsigne
             // If texture contains only an alpha channel, use alpha shader (for fonts)
             // If texture contains only an alpha channel, use alpha shader (for fonts)
             vs = diffTextureVS;
             vs = diffTextureVS;
 
 
-            if (batch.useBGRA_)
-                ps = diffmapBGRAPS;
-            else if (batch.texture_->GetFormat() == alphaFormat)
+            if (batch.texture_->GetFormat() == alphaFormat)
                 ps = alphaTexturePS;
                 ps = alphaTexturePS;
             else if (batch.blendMode_ != BLEND_ALPHA && batch.blendMode_ != BLEND_ADDALPHA && batch.blendMode_ != BLEND_PREMULALPHA)
             else if (batch.blendMode_ != BLEND_ALPHA && batch.blendMode_ != BLEND_ADDALPHA && batch.blendMode_ != BLEND_PREMULALPHA)
                 ps = diffMaskTexturePS;
                 ps = diffMaskTexturePS;
@@ -448,10 +444,9 @@ void UI::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, c
     tb::g_renderer->EndPaint();
     tb::g_renderer->EndPaint();
 }
 }
 
 
-void UI::SubmitBatchVertexData(Texture* texture, const PODVector<float>& vertexData, BlendMode blendMode, bool useBGRA)
+void UI::SubmitBatchVertexData(Texture* texture, const PODVector<float>& vertexData)
 {
 {
-    UIBatch b(blendMode , renderer_->currentScissor_, texture, &vertexData_);
-    b.useBGRA_ = useBGRA;
+    UIBatch b(BLEND_ALPHA , renderer_->currentScissor_, texture, &vertexData_);
 
 
     unsigned begin = b.vertexData_->Size();
     unsigned begin = b.vertexData_->Size();
     b.vertexData_->Resize(begin + vertexData.Size());
     b.vertexData_->Resize(begin + vertexData.Size());

+ 1 - 1
Source/Atomic/UI/UI.h

@@ -59,7 +59,7 @@ public:
 
 
     void Render(bool resetRenderTargets = true);
     void Render(bool resetRenderTargets = true);
     void GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor);
     void GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor);
-    void SubmitBatchVertexData(Texture* texture, const PODVector<float>& vertexData, BlendMode blendMode = BLEND_ALPHA, bool useBGRA = false);
+    void SubmitBatchVertexData(Texture* texture, const PODVector<float>& vertexData);
 
 
     void Initialize(const String& languageFile);
     void Initialize(const String& languageFile);
 
 

+ 1 - 3
Source/Atomic/UI/UIBatch.cpp

@@ -74,7 +74,6 @@ void UIBatch::SetDefaultColor()
 {
 {
     color_ = 0xffffffff;
     color_ = 0xffffffff;
     useGradient_ = false;
     useGradient_ = false;
-    useBGRA_ = false;
 }
 }
 
 
 void UIBatch::AddQuad(int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth, int texHeight)
 void UIBatch::AddQuad(int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth, int texHeight)
@@ -209,8 +208,7 @@ bool UIBatch::Merge(const UIBatch& batch)
         batch.scissor_ != scissor_ ||
         batch.scissor_ != scissor_ ||
         batch.texture_ != texture_ ||
         batch.texture_ != texture_ ||
         batch.vertexData_ != vertexData_ ||
         batch.vertexData_ != vertexData_ ||
-        batch.vertexStart_ != vertexEnd_ ||
-        batch.useBGRA_ != useBGRA_    )
+        batch.vertexStart_ != vertexEnd_)
         return false;
         return false;
 
 
     vertexEnd_ = batch.vertexEnd_;
     vertexEnd_ = batch.vertexEnd_;

+ 0 - 5
Source/Atomic/UI/UIBatch.h

@@ -80,11 +80,6 @@ public:
     unsigned vertexEnd_;
     unsigned vertexEnd_;
     /// Gradient flag.
     /// Gradient flag.
     bool useGradient_;
     bool useGradient_;
-
-    // ATOMIC BEGIN
-    /// Whether texture is in BGRA format
-    bool useBGRA_;
-    // ATOMIC END
 };
 };
 
 
 }
 }

+ 1 - 5
Source/AtomicWebView/UIWebView.cpp

@@ -113,11 +113,7 @@ public:
         data[30] = rect.x;
         data[30] = rect.x;
         data[31] = rect.y + rect.h;
         data[31] = rect.y + rect.h;
 
 
-        bool useBGRA = false;
-#ifdef ATOMIC_PLATFORM_WINDOWS
-        useBGRA = true;
-#endif
-        ui->SubmitBatchVertexData(webView_->GetWebTexture2D()->GetTexture2D(), vertexData_, BLEND_ALPHA, useBGRA );
+        ui->SubmitBatchVertexData(webView_->GetWebTexture2D()->GetTexture2D(), vertexData_);
 
 
     }
     }
 
 

+ 1 - 0
Source/AtomicWebView/WebTexture2D.cpp

@@ -212,6 +212,7 @@ WebTexture2D::WebTexture2D(Context* context) : WebRenderHandler(context)
     texture_ = new Texture2D(context_);
     texture_ = new Texture2D(context_);
     texture_->SetNumLevels(1);
     texture_->SetNumLevels(1);
     texture_->SetFilterMode(FILTER_NEAREST);
     texture_->SetFilterMode(FILTER_NEAREST);
+
 }
 }
 
 
 WebTexture2D::~WebTexture2D()
 WebTexture2D::~WebTexture2D()

+ 2 - 0
Source/AtomicWebView/WebTexture2D.h

@@ -32,10 +32,12 @@ public:
     CefRenderHandler* GetCEFRenderHandler();
     CefRenderHandler* GetCEFRenderHandler();
 
 
     Texture2D* GetTexture2D() const { return texture_; }
     Texture2D* GetTexture2D() const { return texture_; }
+    Material* GetMaterial() const { return material_; }
 
 
 private:
 private:
 
 
     SharedPtr<Texture2D> texture_;
     SharedPtr<Texture2D> texture_;
+    SharedPtr<Material> material_;
 
 
     WebTexture2DPrivate* d_;
     WebTexture2DPrivate* d_;