Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorr.kuznetsov <r.kuznetsov@corp.mail.ru>2018-08-27 12:37:52 +0300
committerAleksey Belousov <beloal@users.noreply.github.com>2018-09-25 12:33:08 +0300
commita81f1fc4d1f698a0f0aaaa1e7a29f41516b05d11 (patch)
treecf7c511247ca2ae4da08e2a11d2b22232846a3da /drape/hw_texture_ios.mm
parent5cca83542d89b081d668bccca7bf14c5c8c165ad (diff)
[drape][metal] Added states.
Diffstat (limited to 'drape/hw_texture_ios.mm')
-rw-r--r--drape/hw_texture_ios.mm57
1 files changed, 42 insertions, 15 deletions
diff --git a/drape/hw_texture_ios.mm b/drape/hw_texture_ios.mm
index 9f7a9f3cc1..914cc31348 100644
--- a/drape/hw_texture_ios.mm
+++ b/drape/hw_texture_ios.mm
@@ -1,6 +1,6 @@
#include "drape/hw_texture_ios.hpp"
-#include "drape/glfunctions.hpp"
-#include "drape/glIncludes.hpp"
+#include "drape/gl_functions.hpp"
+#include "drape/gl_includes.hpp"
#include "base/logging.hpp"
@@ -111,8 +111,9 @@ void HWTextureAllocatorApple::RiseFlushFlag()
m_needFlush = true;
}
-drape_ptr<HWTexture> HWTextureAllocatorApple::CreateTexture()
+drape_ptr<HWTexture> HWTextureAllocatorApple::CreateTexture(ref_ptr<dp::GraphicsContext> context)
{
+ UNUSED_VALUE(context);
return make_unique_dp<HWTextureApple>(make_ref<HWTextureAllocatorApple>(this));
}
@@ -142,12 +143,12 @@ HWTextureApple::~HWTextureApple()
}
}
-void HWTextureApple::Create(Params const & params, ref_ptr<void> data)
+void HWTextureApple::Create(ref_ptr<dp::GraphicsContext> context, Params const & params, ref_ptr<void> data)
{
- TBase::Create(params, data);
+ TBase::Create(context, params, data);
- m_allocator = params.m_allocator.downcast<HWTextureAllocatorApple>();
- m_directBuffer = m_allocator->CVCreatePixelBuffer(params.m_width, params.m_height, params.m_format);
+ m_allocator = m_params.m_allocator.downcast<HWTextureAllocatorApple>();
+ m_directBuffer = m_allocator->CVCreatePixelBuffer(m_params.m_width, m_params.m_height, params.m_format);
glConst layout, pixelType;
UnpackFormat(params.m_format, layout, pixelType);
@@ -156,17 +157,17 @@ void HWTextureApple::Create(Params const & params, ref_ptr<void> data)
m_textureID = CVOpenGLESTextureGetName(m_texture);
GLFunctions::glBindTexture(m_textureID);
- auto const f = DecodeTextureFilter(params.m_filter);
+ auto const f = DecodeTextureFilter(m_params.m_filter);
GLFunctions::glTexParameter(gl_const::GLMinFilter, f);
GLFunctions::glTexParameter(gl_const::GLMagFilter, f);
- GLFunctions::glTexParameter(gl_const::GLWrapS, DecodeTextureWrapping(params.m_wrapSMode));
- GLFunctions::glTexParameter(gl_const::GLWrapT, DecodeTextureWrapping(params.m_wrapTMode));
+ GLFunctions::glTexParameter(gl_const::GLWrapS, DecodeTextureWrapping(m_params.m_wrapSMode));
+ GLFunctions::glTexParameter(gl_const::GLWrapT, DecodeTextureWrapping(m_params.m_wrapTMode));
if (data == nullptr)
return;
Lock();
- memcpy(m_directPointer, data.get(), m_width * m_height * GetBytesPerPixel(m_format));
+ memcpy(m_directPointer, data.get(), m_params.m_width * m_params.m_height * GetBytesPerPixel(m_params.m_format));
Unlock();
}
@@ -177,7 +178,8 @@ void HWTextureApple::UploadData(uint32_t x, uint32_t y, uint32_t width, uint32_t
if (bytesPerPixel == 1)
{
gray8c_view_t srcView = interleaved_view(width, height, (gray8c_pixel_t *)data.get(), width);
- gray8_view_t dstView = interleaved_view(m_width, m_height, (gray8_pixel_t *)m_directPointer, m_width);
+ gray8_view_t dstView = interleaved_view(m_params.m_width, m_params.m_height,
+ (gray8_pixel_t *)m_directPointer, m_params.m_width);
gray8_view_t subDstView = subimage_view(dstView, x, y, width, height);
copy_pixels(srcView, subDstView);
}
@@ -186,22 +188,47 @@ void HWTextureApple::UploadData(uint32_t x, uint32_t y, uint32_t width, uint32_t
rgba8c_view_t srcView = interleaved_view(width, height,
(rgba8c_pixel_t *)data.get(),
width * bytesPerPixel);
- rgba8_view_t dstView = interleaved_view(m_width, m_height,
+ rgba8_view_t dstView = interleaved_view(m_params.m_width, m_params.m_height,
(rgba8_pixel_t *)m_directPointer,
- m_width * bytesPerPixel);
+ m_params.m_width * bytesPerPixel);
rgba8_view_t subDstView = subimage_view(dstView, x, y, width, height);
copy_pixels(srcView, subDstView);
}
Unlock();
}
+void HWTextureApple::Bind() const
+{
+ ASSERT(Validate(), ());
+ if (m_textureID != 0)
+ GLFunctions::glBindTexture(GetID());
+}
+
+void HWTextureApple::SetFilter(TextureFilter filter)
+{
+ ASSERT(Validate(), ());
+ if (m_params.m_filter != filter)
+ {
+ m_params.m_filter = filter;
+ auto const f = DecodeTextureFilter(m_params.m_filter);
+ GLFunctions::glTexParameter(gl_const::GLMinFilter, f);
+ GLFunctions::glTexParameter(gl_const::GLMagFilter, f);
+ }
+}
+
+bool HWTextureApple::Validate() const
+{
+ return GetID() != 0;
+}
+
void HWTextureApple::Lock()
{
ASSERT(m_directPointer == nullptr, ());
CHECK_EQUAL(CVPixelBufferLockBaseAddress(m_directBuffer, 0), kCVReturnSuccess, ());
- ASSERT_EQUAL(CVPixelBufferGetBytesPerRow(m_directBuffer), m_width * GetBytesPerPixel(m_format), ());
+ ASSERT_EQUAL(CVPixelBufferGetBytesPerRow(m_directBuffer),
+ m_params.m_width * GetBytesPerPixel(m_params.m_format), ());
m_directPointer = CVPixelBufferGetBaseAddress(m_directBuffer);
}