Remove dos-style line-endings (EOL changes only)

git-svn-id: https://angleproject.googlecode.com/svn/trunk@1218 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 9fba10e9
// //
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// debug.cpp: Debugging utilities. // debug.cpp: Debugging utilities.
#include "common/debug.h" #include "common/debug.h"
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <d3d9.h> #include <d3d9.h>
#include <windows.h> #include <windows.h>
namespace gl namespace gl
{ {
typedef void (WINAPI *PerfOutputFunction)(D3DCOLOR, LPCWSTR); typedef void (WINAPI *PerfOutputFunction)(D3DCOLOR, LPCWSTR);
static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const char *format, va_list vararg) static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const char *format, va_list vararg)
{ {
#if !defined(ANGLE_DISABLE_PERF) #if !defined(ANGLE_DISABLE_PERF)
if (perfActive()) if (perfActive())
{ {
char message[32768]; char message[32768];
int len = vsprintf_s(message, format, vararg); int len = vsprintf_s(message, format, vararg);
if (len < 0) if (len < 0)
{ {
return; return;
} }
// There are no ASCII variants of these D3DPERF functions. // There are no ASCII variants of these D3DPERF functions.
wchar_t wideMessage[32768]; wchar_t wideMessage[32768];
for (int i = 0; i < len; ++i) for (int i = 0; i < len; ++i)
{ {
wideMessage[i] = message[i]; wideMessage[i] = message[i];
} }
wideMessage[len] = 0; wideMessage[len] = 0;
perfFunc(0, wideMessage); perfFunc(0, wideMessage);
} }
#endif #endif
#if !defined(ANGLE_DISABLE_TRACE) #if !defined(ANGLE_DISABLE_TRACE)
#if defined(NDEBUG) #if defined(NDEBUG)
if (traceFileDebugOnly) if (traceFileDebugOnly)
{ {
return; return;
} }
#endif #endif
FILE* file = fopen(TRACE_OUTPUT_FILE, "a"); FILE* file = fopen(TRACE_OUTPUT_FILE, "a");
if (file) if (file)
{ {
vfprintf(file, format, vararg); vfprintf(file, format, vararg);
fclose(file); fclose(file);
} }
#endif #endif
} }
void trace(bool traceFileDebugOnly, const char *format, ...) void trace(bool traceFileDebugOnly, const char *format, ...)
{ {
va_list vararg; va_list vararg;
va_start(vararg, format); va_start(vararg, format);
#if defined(ANGLE_DISABLE_PERF) #if defined(ANGLE_DISABLE_PERF)
output(traceFileDebugOnly, NULL, format, vararg); output(traceFileDebugOnly, NULL, format, vararg);
#else #else
output(traceFileDebugOnly, D3DPERF_SetMarker, format, vararg); output(traceFileDebugOnly, D3DPERF_SetMarker, format, vararg);
#endif #endif
va_end(vararg); va_end(vararg);
} }
bool perfActive() bool perfActive()
{ {
#if defined(ANGLE_DISABLE_PERF) #if defined(ANGLE_DISABLE_PERF)
return false; return false;
#else #else
static bool active = D3DPERF_GetStatus() != 0; static bool active = D3DPERF_GetStatus() != 0;
return active; return active;
#endif #endif
} }
ScopedPerfEventHelper::ScopedPerfEventHelper(const char* format, ...) ScopedPerfEventHelper::ScopedPerfEventHelper(const char* format, ...)
{ {
#if !defined(ANGLE_DISABLE_PERF) #if !defined(ANGLE_DISABLE_PERF)
va_list vararg; va_list vararg;
va_start(vararg, format); va_start(vararg, format);
output(true, reinterpret_cast<PerfOutputFunction>(D3DPERF_BeginEvent), format, vararg); output(true, reinterpret_cast<PerfOutputFunction>(D3DPERF_BeginEvent), format, vararg);
va_end(vararg); va_end(vararg);
#endif #endif
} }
ScopedPerfEventHelper::~ScopedPerfEventHelper() ScopedPerfEventHelper::~ScopedPerfEventHelper()
{ {
#if !defined(ANGLE_DISABLE_PERF) #if !defined(ANGLE_DISABLE_PERF)
if (perfActive()) if (perfActive())
{ {
D3DPERF_EndEvent(); D3DPERF_EndEvent();
} }
#endif #endif
} }
} }
// //
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// Surface.cpp: Implements the egl::Surface class, representing a drawing surface // Surface.cpp: Implements the egl::Surface class, representing a drawing surface
// such as the client area of a window, including any back buffers. // such as the client area of a window, including any back buffers.
// Implements EGLSurface and related functionality. [EGL 1.4] section 2.2 page 3. // Implements EGLSurface and related functionality. [EGL 1.4] section 2.2 page 3.
#include <tchar.h> #include <tchar.h>
#include "libEGL/Surface.h" #include "libEGL/Surface.h"
#include "common/debug.h" #include "common/debug.h"
#include "libGLESv2/Texture.h" #include "libGLESv2/Texture.h"
#include "libEGL/main.h" #include "libEGL/main.h"
#include "libEGL/Display.h" #include "libEGL/Display.h"
#include <dwmapi.h> #include <dwmapi.h>
namespace egl namespace egl
{ {
namespace namespace
{ {
const int versionWindowsVista = MAKEWORD(0x00, 0x06); const int versionWindowsVista = MAKEWORD(0x00, 0x06);
const int versionWindows7 = MAKEWORD(0x01, 0x06); const int versionWindows7 = MAKEWORD(0x01, 0x06);
// Return the version of the operating system in a format suitable for ordering // Return the version of the operating system in a format suitable for ordering
// comparison. // comparison.
int getComparableOSVersion() int getComparableOSVersion()
{ {
DWORD version = GetVersion(); DWORD version = GetVersion();
int majorVersion = LOBYTE(LOWORD(version)); int majorVersion = LOBYTE(LOWORD(version));
int minorVersion = HIBYTE(LOWORD(version)); int minorVersion = HIBYTE(LOWORD(version));
return MAKEWORD(minorVersion, majorVersion); return MAKEWORD(minorVersion, majorVersion);
} }
} }
Surface::Surface(Display *display, const Config *config, HWND window, EGLint postSubBufferSupported) Surface::Surface(Display *display, const Config *config, HWND window, EGLint postSubBufferSupported)
: mDisplay(display), mConfig(config), mWindow(window), mPostSubBufferSupported(postSubBufferSupported) : mDisplay(display), mConfig(config), mWindow(window), mPostSubBufferSupported(postSubBufferSupported)
{ {
mSwapChain = NULL; mSwapChain = NULL;
mBackBuffer = NULL; mBackBuffer = NULL;
mDepthStencil = NULL; mDepthStencil = NULL;
mRenderTarget = NULL; mRenderTarget = NULL;
mOffscreenTexture = NULL; mOffscreenTexture = NULL;
mShareHandle = NULL; mShareHandle = NULL;
mTexture = NULL; mTexture = NULL;
mTextureFormat = EGL_NO_TEXTURE; mTextureFormat = EGL_NO_TEXTURE;
mTextureTarget = EGL_NO_TEXTURE; mTextureTarget = EGL_NO_TEXTURE;
mPixelAspectRatio = (EGLint)(1.0 * EGL_DISPLAY_SCALING); // FIXME: Determine actual pixel aspect ratio mPixelAspectRatio = (EGLint)(1.0 * EGL_DISPLAY_SCALING); // FIXME: Determine actual pixel aspect ratio
mRenderBuffer = EGL_BACK_BUFFER; mRenderBuffer = EGL_BACK_BUFFER;
mSwapBehavior = EGL_BUFFER_PRESERVED; mSwapBehavior = EGL_BUFFER_PRESERVED;
mSwapInterval = -1; mSwapInterval = -1;
setSwapInterval(1); setSwapInterval(1);
subclassWindow(); subclassWindow();
} }
Surface::Surface(Display *display, const Config *config, HANDLE shareHandle, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureType) Surface::Surface(Display *display, const Config *config, HANDLE shareHandle, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureType)
: mDisplay(display), mWindow(NULL), mConfig(config), mShareHandle(shareHandle), mWidth(width), mHeight(height), mPostSubBufferSupported(EGL_FALSE) : mDisplay(display), mWindow(NULL), mConfig(config), mShareHandle(shareHandle), mWidth(width), mHeight(height), mPostSubBufferSupported(EGL_FALSE)
{ {
mSwapChain = NULL; mSwapChain = NULL;
mBackBuffer = NULL; mBackBuffer = NULL;
mDepthStencil = NULL; mDepthStencil = NULL;
mRenderTarget = NULL; mRenderTarget = NULL;
mOffscreenTexture = NULL; mOffscreenTexture = NULL;
mWindowSubclassed = false; mWindowSubclassed = false;
mTexture = NULL; mTexture = NULL;
mTextureFormat = textureFormat; mTextureFormat = textureFormat;
mTextureTarget = textureType; mTextureTarget = textureType;
mPixelAspectRatio = (EGLint)(1.0 * EGL_DISPLAY_SCALING); // FIXME: Determine actual pixel aspect ratio mPixelAspectRatio = (EGLint)(1.0 * EGL_DISPLAY_SCALING); // FIXME: Determine actual pixel aspect ratio
mRenderBuffer = EGL_BACK_BUFFER; mRenderBuffer = EGL_BACK_BUFFER;
mSwapBehavior = EGL_BUFFER_PRESERVED; mSwapBehavior = EGL_BUFFER_PRESERVED;
mSwapInterval = -1; mSwapInterval = -1;
setSwapInterval(1); setSwapInterval(1);
} }
Surface::~Surface() Surface::~Surface()
{ {
unsubclassWindow(); unsubclassWindow();
release(); release();
} }
bool Surface::initialize() bool Surface::initialize()
{ {
ASSERT(!mSwapChain && !mOffscreenTexture && !mDepthStencil); ASSERT(!mSwapChain && !mOffscreenTexture && !mDepthStencil);
if (!resetSwapChain()) if (!resetSwapChain())
return false; return false;
// Modify present parameters for this window, if we are composited, // Modify present parameters for this window, if we are composited,
// to minimize the amount of queuing done by DWM between our calls to // to minimize the amount of queuing done by DWM between our calls to
// present and the actual screen. // present and the actual screen.
if (mWindow && (getComparableOSVersion() >= versionWindowsVista)) { if (mWindow && (getComparableOSVersion() >= versionWindowsVista)) {
BOOL isComposited; BOOL isComposited;
HRESULT result = DwmIsCompositionEnabled(&isComposited); HRESULT result = DwmIsCompositionEnabled(&isComposited);
if (SUCCEEDED(result) && isComposited) { if (SUCCEEDED(result) && isComposited) {
DWM_PRESENT_PARAMETERS presentParams; DWM_PRESENT_PARAMETERS presentParams;
memset(&presentParams, 0, sizeof(presentParams)); memset(&presentParams, 0, sizeof(presentParams));
presentParams.cbSize = sizeof(DWM_PRESENT_PARAMETERS); presentParams.cbSize = sizeof(DWM_PRESENT_PARAMETERS);
presentParams.cBuffer = 2; presentParams.cBuffer = 2;
result = DwmSetPresentParameters(mWindow, &presentParams); result = DwmSetPresentParameters(mWindow, &presentParams);
if (FAILED(result)) if (FAILED(result))
ERR("Unable to set present parameters: 0x%08X", result); ERR("Unable to set present parameters: 0x%08X", result);
} }
} }
return true; return true;
} }
void Surface::release() void Surface::release()
{ {
if (mSwapChain) if (mSwapChain)
{ {
mSwapChain->Release(); mSwapChain->Release();
mSwapChain = NULL; mSwapChain = NULL;
} }
if (mBackBuffer) if (mBackBuffer)
{ {
mBackBuffer->Release(); mBackBuffer->Release();
mBackBuffer = NULL; mBackBuffer = NULL;
} }
if (mDepthStencil) if (mDepthStencil)
{ {
mDepthStencil->Release(); mDepthStencil->Release();
mDepthStencil = NULL; mDepthStencil = NULL;
} }
if (mRenderTarget) if (mRenderTarget)
{ {
mRenderTarget->Release(); mRenderTarget->Release();
mRenderTarget = NULL; mRenderTarget = NULL;
} }
if (mOffscreenTexture) if (mOffscreenTexture)
{ {
mOffscreenTexture->Release(); mOffscreenTexture->Release();
mOffscreenTexture = NULL; mOffscreenTexture = NULL;
} }
if (mTexture) if (mTexture)
{ {
mTexture->releaseTexImage(); mTexture->releaseTexImage();
mTexture = NULL; mTexture = NULL;
} }
mShareHandle = NULL; mShareHandle = NULL;
} }
bool Surface::resetSwapChain() bool Surface::resetSwapChain()
{ {
if (!mWindow) if (!mWindow)
{ {
return resetSwapChain(mWidth, mHeight); return resetSwapChain(mWidth, mHeight);
} }
RECT windowRect; RECT windowRect;
if (!GetClientRect(getWindowHandle(), &windowRect)) if (!GetClientRect(getWindowHandle(), &windowRect))
{ {
ASSERT(false); ASSERT(false);
ERR("Could not retrieve the window dimensions"); ERR("Could not retrieve the window dimensions");
return false; return false;
} }
return resetSwapChain(windowRect.right - windowRect.left, windowRect.bottom - windowRect.top); return resetSwapChain(windowRect.right - windowRect.left, windowRect.bottom - windowRect.top);
} }
bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
{ {
IDirect3DDevice9 *device = mDisplay->getDevice(); IDirect3DDevice9 *device = mDisplay->getDevice();
if (device == NULL) if (device == NULL)
{ {
return false; return false;
} }
// Evict all non-render target textures to system memory and release all resources // Evict all non-render target textures to system memory and release all resources
// before reallocating them to free up as much video memory as possible. // before reallocating them to free up as much video memory as possible.
device->EvictManagedResources(); device->EvictManagedResources();
D3DPRESENT_PARAMETERS presentParameters = {0}; D3DPRESENT_PARAMETERS presentParameters = {0};
HRESULT result; HRESULT result;
presentParameters.AutoDepthStencilFormat = mConfig->mDepthStencilFormat; presentParameters.AutoDepthStencilFormat = mConfig->mDepthStencilFormat;
// We set BackBufferCount = 1 even when we use D3DSWAPEFFECT_FLIPEX. // We set BackBufferCount = 1 even when we use D3DSWAPEFFECT_FLIPEX.
// We do this because DirectX docs are a bit vague whether to set this to 1 // We do this because DirectX docs are a bit vague whether to set this to 1
// or 2. The runtime seems to accept 1, so we speculate that either it is // or 2. The runtime seems to accept 1, so we speculate that either it is
// forcing it to 2 without telling us, or better, doing something smart // forcing it to 2 without telling us, or better, doing something smart
// behind the scenes knowing that we don't need more. // behind the scenes knowing that we don't need more.
presentParameters.BackBufferCount = 1; presentParameters.BackBufferCount = 1;
presentParameters.BackBufferFormat = mConfig->mRenderTargetFormat; presentParameters.BackBufferFormat = mConfig->mRenderTargetFormat;
presentParameters.EnableAutoDepthStencil = FALSE; presentParameters.EnableAutoDepthStencil = FALSE;
presentParameters.Flags = 0; presentParameters.Flags = 0;
presentParameters.hDeviceWindow = getWindowHandle(); presentParameters.hDeviceWindow = getWindowHandle();
presentParameters.MultiSampleQuality = 0; // FIXME: Unimplemented presentParameters.MultiSampleQuality = 0; // FIXME: Unimplemented
presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE; // FIXME: Unimplemented presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE; // FIXME: Unimplemented
presentParameters.PresentationInterval = mPresentInterval; presentParameters.PresentationInterval = mPresentInterval;
presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD; presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
presentParameters.Windowed = TRUE; presentParameters.Windowed = TRUE;
presentParameters.BackBufferWidth = backbufferWidth; presentParameters.BackBufferWidth = backbufferWidth;
presentParameters.BackBufferHeight = backbufferHeight; presentParameters.BackBufferHeight = backbufferHeight;
// Release specific resources to free up memory for the new render target, while the // Release specific resources to free up memory for the new render target, while the
// old render target still exists for the purpose of preserving its contents. // old render target still exists for the purpose of preserving its contents.
if (mSwapChain) if (mSwapChain)
{ {
mSwapChain->Release(); mSwapChain->Release();
mSwapChain = NULL; mSwapChain = NULL;
} }
if (mBackBuffer) if (mBackBuffer)
{ {
mBackBuffer->Release(); mBackBuffer->Release();
mBackBuffer = NULL; mBackBuffer = NULL;
} }
if (mOffscreenTexture) if (mOffscreenTexture)
{ {
mOffscreenTexture->Release(); mOffscreenTexture->Release();
mOffscreenTexture = NULL; mOffscreenTexture = NULL;
} }
if (mDepthStencil) if (mDepthStencil)
{ {
mDepthStencil->Release(); mDepthStencil->Release();
mDepthStencil = NULL; mDepthStencil = NULL;
} }
mShareHandle = NULL; mShareHandle = NULL;
HANDLE *pShareHandle = NULL; HANDLE *pShareHandle = NULL;
if (!mWindow && mDisplay->shareHandleSupported()) if (!mWindow && mDisplay->shareHandleSupported())
{ {
pShareHandle = &mShareHandle; pShareHandle = &mShareHandle;
} }
result = device->CreateTexture(presentParameters.BackBufferWidth, presentParameters.BackBufferHeight, 1, D3DUSAGE_RENDERTARGET, result = device->CreateTexture(presentParameters.BackBufferWidth, presentParameters.BackBufferHeight, 1, D3DUSAGE_RENDERTARGET,
presentParameters.BackBufferFormat, D3DPOOL_DEFAULT, &mOffscreenTexture, pShareHandle); presentParameters.BackBufferFormat, D3DPOOL_DEFAULT, &mOffscreenTexture, pShareHandle);
if (FAILED(result)) if (FAILED(result))
{ {
ERR("Could not create offscreen texture: %08lX", result); ERR("Could not create offscreen texture: %08lX", result);
release(); release();
if(isDeviceLostError(result)) if(isDeviceLostError(result))
{ {
mDisplay->notifyDeviceLost(); mDisplay->notifyDeviceLost();
return false; return false;
} }
else else
{ {
return error(EGL_BAD_ALLOC, false); return error(EGL_BAD_ALLOC, false);
} }
} }
IDirect3DSurface9 *oldRenderTarget = mRenderTarget; IDirect3DSurface9 *oldRenderTarget = mRenderTarget;
result = mOffscreenTexture->GetSurfaceLevel(0, &mRenderTarget); result = mOffscreenTexture->GetSurfaceLevel(0, &mRenderTarget);
ASSERT(SUCCEEDED(result)); ASSERT(SUCCEEDED(result));
if (oldRenderTarget) if (oldRenderTarget)
{ {
RECT rect = RECT rect =
{ {
0, 0, 0, 0,
mWidth, mHeight mWidth, mHeight
}; };
if (rect.right > static_cast<LONG>(presentParameters.BackBufferWidth)) if (rect.right > static_cast<LONG>(presentParameters.BackBufferWidth))
{ {
rect.right = presentParameters.BackBufferWidth; rect.right = presentParameters.BackBufferWidth;
} }
if (rect.bottom > static_cast<LONG>(presentParameters.BackBufferHeight)) if (rect.bottom > static_cast<LONG>(presentParameters.BackBufferHeight))
{ {
rect.bottom = presentParameters.BackBufferHeight; rect.bottom = presentParameters.BackBufferHeight;
} }
mDisplay->endScene(); mDisplay->endScene();
result = device->StretchRect(oldRenderTarget, &rect, mRenderTarget, &rect, D3DTEXF_NONE); result = device->StretchRect(oldRenderTarget, &rect, mRenderTarget, &rect, D3DTEXF_NONE);
ASSERT(SUCCEEDED(result)); ASSERT(SUCCEEDED(result));
oldRenderTarget->Release(); oldRenderTarget->Release();
} }
if (mWindow) if (mWindow)
{ {
result = device->CreateAdditionalSwapChain(&presentParameters, &mSwapChain); result = device->CreateAdditionalSwapChain(&presentParameters, &mSwapChain);
if (FAILED(result)) if (FAILED(result))
{ {
ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_INVALIDCALL || result == D3DERR_DEVICELOST); ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_INVALIDCALL || result == D3DERR_DEVICELOST);
ERR("Could not create additional swap chains or offscreen surfaces: %08lX", result); ERR("Could not create additional swap chains or offscreen surfaces: %08lX", result);
release(); release();
if(isDeviceLostError(result)) if(isDeviceLostError(result))
{ {
mDisplay->notifyDeviceLost(); mDisplay->notifyDeviceLost();
return false; return false;
} }
else else
{ {
return error(EGL_BAD_ALLOC, false); return error(EGL_BAD_ALLOC, false);
} }
} }
result = mSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &mBackBuffer); result = mSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &mBackBuffer);
ASSERT(SUCCEEDED(result)); ASSERT(SUCCEEDED(result));
} }
if (mConfig->mDepthStencilFormat != D3DFMT_UNKNOWN) if (mConfig->mDepthStencilFormat != D3DFMT_UNKNOWN)
{ {
result = device->CreateDepthStencilSurface(presentParameters.BackBufferWidth, presentParameters.BackBufferHeight, result = device->CreateDepthStencilSurface(presentParameters.BackBufferWidth, presentParameters.BackBufferHeight,
presentParameters.AutoDepthStencilFormat, presentParameters.MultiSampleType, presentParameters.AutoDepthStencilFormat, presentParameters.MultiSampleType,
presentParameters.MultiSampleQuality, FALSE, &mDepthStencil, NULL); presentParameters.MultiSampleQuality, FALSE, &mDepthStencil, NULL);
if (FAILED(result)) if (FAILED(result))
{ {
ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_INVALIDCALL); ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_INVALIDCALL);
ERR("Could not create depthstencil surface for new swap chain: 0x%08X", result); ERR("Could not create depthstencil surface for new swap chain: 0x%08X", result);
release(); release();
if(isDeviceLostError(result)) if(isDeviceLostError(result))
{ {
mDisplay->notifyDeviceLost(); mDisplay->notifyDeviceLost();
return false; return false;
} }
else else
{ {
return error(EGL_BAD_ALLOC, false); return error(EGL_BAD_ALLOC, false);
} }
} }
} }
mWidth = presentParameters.BackBufferWidth; mWidth = presentParameters.BackBufferWidth;
mHeight = presentParameters.BackBufferHeight; mHeight = presentParameters.BackBufferHeight;
mPresentIntervalDirty = false; mPresentIntervalDirty = false;
return true; return true;
} }
bool Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height) bool Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
{ {
if (!mSwapChain) if (!mSwapChain)
{ {
return true; return true;
} }
if (x + width > mWidth) if (x + width > mWidth)
{ {
width = mWidth - x; width = mWidth - x;
} }
if (y + height > mHeight) if (y + height > mHeight)
{ {
height = mHeight - y; height = mHeight - y;
} }
if (width == 0 || height == 0) if (width == 0 || height == 0)
{ {
return true; return true;
} }
IDirect3DDevice9 *device = mDisplay->getDevice(); IDirect3DDevice9 *device = mDisplay->getDevice();
// Disable all pipeline operations // Disable all pipeline operations
device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE); device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
device->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); device->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
device->SetRenderState(D3DRS_STENCILENABLE, FALSE); device->SetRenderState(D3DRS_STENCILENABLE, FALSE);
device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0); device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED); device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
device->SetRenderState(D3DRS_SRGBWRITEENABLE, FALSE); device->SetRenderState(D3DRS_SRGBWRITEENABLE, FALSE);
device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE); device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
device->SetPixelShader(NULL); device->SetPixelShader(NULL);
device->SetVertexShader(NULL); device->SetVertexShader(NULL);
device->SetRenderTarget(0, mBackBuffer); device->SetRenderTarget(0, mBackBuffer);
device->SetDepthStencilSurface(NULL); device->SetDepthStencilSurface(NULL);
device->SetTexture(0, mOffscreenTexture); device->SetTexture(0, mOffscreenTexture);
device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT); device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
device->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1); device->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
D3DVIEWPORT9 viewport = {0, 0, mWidth, mHeight, 0.0f, 1.0f}; D3DVIEWPORT9 viewport = {0, 0, mWidth, mHeight, 0.0f, 1.0f};
device->SetViewport(&viewport); device->SetViewport(&viewport);
float x1 = x - 0.5f; float x1 = x - 0.5f;
float y1 = (mHeight - y - height) - 0.5f; float y1 = (mHeight - y - height) - 0.5f;
float x2 = (x + width) - 0.5f; float x2 = (x + width) - 0.5f;
float y2 = (mHeight - y) - 0.5f; float y2 = (mHeight - y) - 0.5f;
float u1 = x / float(mWidth); float u1 = x / float(mWidth);
float v1 = y / float(mHeight); float v1 = y / float(mHeight);
float u2 = (x + width) / float(mWidth); float u2 = (x + width) / float(mWidth);
float v2 = (y + height) / float(mHeight); float v2 = (y + height) / float(mHeight);
float quad[4][6] = {{x1, y1, 0.0f, 1.0f, u1, v2}, float quad[4][6] = {{x1, y1, 0.0f, 1.0f, u1, v2},
{x2, y1, 0.0f, 1.0f, u2, v2}, {x2, y1, 0.0f, 1.0f, u2, v2},
{x2, y2, 0.0f, 1.0f, u2, v1}, {x2, y2, 0.0f, 1.0f, u2, v1},
{x1, y2, 0.0f, 1.0f, u1, v1}}; // x, y, z, rhw, u, v {x1, y2, 0.0f, 1.0f, u1, v1}}; // x, y, z, rhw, u, v
mDisplay->startScene(); mDisplay->startScene();
device->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, quad, 6 * sizeof(float)); device->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, quad, 6 * sizeof(float));
mDisplay->endScene(); mDisplay->endScene();
device->SetTexture(0, NULL); device->SetTexture(0, NULL);
RECT rect = RECT rect =
{ {
x, mHeight - y - height, x, mHeight - y - height,
x + width, mHeight - y x + width, mHeight - y
}; };
HRESULT result = mSwapChain->Present(&rect, &rect, NULL, NULL, 0); HRESULT result = mSwapChain->Present(&rect, &rect, NULL, NULL, 0);
gl::Context *context = static_cast<gl::Context*>(glGetCurrentContext()); gl::Context *context = static_cast<gl::Context*>(glGetCurrentContext());
if (context) if (context)
{ {
context->markAllStateDirty(); context->markAllStateDirty();
} }
if (isDeviceLostError(result)) if (isDeviceLostError(result))
{ {
mDisplay->notifyDeviceLost(); mDisplay->notifyDeviceLost();
return false; return false;
} }
if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_DRIVERINTERNALERROR) if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_DRIVERINTERNALERROR)
{ {
return error(EGL_BAD_ALLOC, false); return error(EGL_BAD_ALLOC, false);
} }
ASSERT(SUCCEEDED(result)); ASSERT(SUCCEEDED(result));
checkForOutOfDateSwapChain(); checkForOutOfDateSwapChain();
return true; return true;
} }
HWND Surface::getWindowHandle() HWND Surface::getWindowHandle()
{ {
return mWindow; return mWindow;
} }
#define kSurfaceProperty _TEXT("Egl::SurfaceOwner") #define kSurfaceProperty _TEXT("Egl::SurfaceOwner")
#define kParentWndProc _TEXT("Egl::SurfaceParentWndProc") #define kParentWndProc _TEXT("Egl::SurfaceParentWndProc")
static LRESULT CALLBACK SurfaceWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) static LRESULT CALLBACK SurfaceWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{ {
if (message == WM_SIZE) if (message == WM_SIZE)
{ {
Surface* surf = reinterpret_cast<Surface*>(GetProp(hwnd, kSurfaceProperty)); Surface* surf = reinterpret_cast<Surface*>(GetProp(hwnd, kSurfaceProperty));
if(surf) if(surf)
{ {
surf->checkForOutOfDateSwapChain(); surf->checkForOutOfDateSwapChain();
} }
} }
WNDPROC prevWndFunc = reinterpret_cast<WNDPROC >(GetProp(hwnd, kParentWndProc)); WNDPROC prevWndFunc = reinterpret_cast<WNDPROC >(GetProp(hwnd, kParentWndProc));
return CallWindowProc(prevWndFunc, hwnd, message, wparam, lparam); return CallWindowProc(prevWndFunc, hwnd, message, wparam, lparam);
} }
void Surface::subclassWindow() void Surface::subclassWindow()
{ {
if (!mWindow) if (!mWindow)
{ {
return; return;
} }
DWORD processId; DWORD processId;
DWORD threadId = GetWindowThreadProcessId(mWindow, &processId); DWORD threadId = GetWindowThreadProcessId(mWindow, &processId);
if (processId != GetCurrentProcessId() || threadId != GetCurrentThreadId()) if (processId != GetCurrentProcessId() || threadId != GetCurrentThreadId())
{ {
return; return;
} }
SetLastError(0); SetLastError(0);
LONG_PTR oldWndProc = SetWindowLongPtr(mWindow, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(SurfaceWindowProc)); LONG_PTR oldWndProc = SetWindowLongPtr(mWindow, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(SurfaceWindowProc));
if(oldWndProc == 0 && GetLastError() != ERROR_SUCCESS) if(oldWndProc == 0 && GetLastError() != ERROR_SUCCESS)
{ {
mWindowSubclassed = false; mWindowSubclassed = false;
return; return;
} }
SetProp(mWindow, kSurfaceProperty, reinterpret_cast<HANDLE>(this)); SetProp(mWindow, kSurfaceProperty, reinterpret_cast<HANDLE>(this));
SetProp(mWindow, kParentWndProc, reinterpret_cast<HANDLE>(oldWndProc)); SetProp(mWindow, kParentWndProc, reinterpret_cast<HANDLE>(oldWndProc));
mWindowSubclassed = true; mWindowSubclassed = true;
} }
void Surface::unsubclassWindow() void Surface::unsubclassWindow()
{ {
if(!mWindowSubclassed) if(!mWindowSubclassed)
{ {
return; return;
} }
// un-subclass // un-subclass
LONG_PTR parentWndFunc = reinterpret_cast<LONG_PTR>(GetProp(mWindow, kParentWndProc)); LONG_PTR parentWndFunc = reinterpret_cast<LONG_PTR>(GetProp(mWindow, kParentWndProc));
// Check the windowproc is still SurfaceWindowProc. // Check the windowproc is still SurfaceWindowProc.
// If this assert fails, then it is likely the application has subclassed the // If this assert fails, then it is likely the application has subclassed the
// hwnd as well and did not unsubclass before destroying its EGL context. The // hwnd as well and did not unsubclass before destroying its EGL context. The
// application should be modified to either subclass before initializing the // application should be modified to either subclass before initializing the
// EGL context, or to unsubclass before destroying the EGL context. // EGL context, or to unsubclass before destroying the EGL context.
if(parentWndFunc) if(parentWndFunc)
{ {
LONG_PTR prevWndFunc = SetWindowLongPtr(mWindow, GWLP_WNDPROC, parentWndFunc); LONG_PTR prevWndFunc = SetWindowLongPtr(mWindow, GWLP_WNDPROC, parentWndFunc);
ASSERT(prevWndFunc == reinterpret_cast<LONG_PTR>(SurfaceWindowProc)); ASSERT(prevWndFunc == reinterpret_cast<LONG_PTR>(SurfaceWindowProc));
} }
RemoveProp(mWindow, kSurfaceProperty); RemoveProp(mWindow, kSurfaceProperty);
RemoveProp(mWindow, kParentWndProc); RemoveProp(mWindow, kParentWndProc);
mWindowSubclassed = false; mWindowSubclassed = false;
} }
bool Surface::checkForOutOfDateSwapChain() bool Surface::checkForOutOfDateSwapChain()
{ {
RECT client; RECT client;
if (!GetClientRect(getWindowHandle(), &client)) if (!GetClientRect(getWindowHandle(), &client))
{ {
ASSERT(false); ASSERT(false);
return false; return false;
} }
// Grow the buffer now, if the window has grown. We need to grow now to avoid losing information. // Grow the buffer now, if the window has grown. We need to grow now to avoid losing information.
int clientWidth = client.right - client.left; int clientWidth = client.right - client.left;
int clientHeight = client.bottom - client.top; int clientHeight = client.bottom - client.top;
bool sizeDirty = clientWidth != getWidth() || clientHeight != getHeight(); bool sizeDirty = clientWidth != getWidth() || clientHeight != getHeight();
if (sizeDirty || mPresentIntervalDirty) if (sizeDirty || mPresentIntervalDirty)
{ {
resetSwapChain(clientWidth, clientHeight); resetSwapChain(clientWidth, clientHeight);
if (static_cast<egl::Surface*>(getCurrentDrawSurface()) == this) if (static_cast<egl::Surface*>(getCurrentDrawSurface()) == this)
{ {
glMakeCurrent(glGetCurrentContext(), static_cast<egl::Display*>(getCurrentDisplay()), this); glMakeCurrent(glGetCurrentContext(), static_cast<egl::Display*>(getCurrentDisplay()), this);
} }
return true; return true;
} }
return false; return false;
} }
DWORD Surface::convertInterval(EGLint interval) DWORD Surface::convertInterval(EGLint interval)
{ {
switch(interval) switch(interval)
{ {
case 0: return D3DPRESENT_INTERVAL_IMMEDIATE; case 0: return D3DPRESENT_INTERVAL_IMMEDIATE;
case 1: return D3DPRESENT_INTERVAL_ONE; case 1: return D3DPRESENT_INTERVAL_ONE;
case 2: return D3DPRESENT_INTERVAL_TWO; case 2: return D3DPRESENT_INTERVAL_TWO;
case 3: return D3DPRESENT_INTERVAL_THREE; case 3: return D3DPRESENT_INTERVAL_THREE;
case 4: return D3DPRESENT_INTERVAL_FOUR; case 4: return D3DPRESENT_INTERVAL_FOUR;
default: UNREACHABLE(); default: UNREACHABLE();
} }
return D3DPRESENT_INTERVAL_DEFAULT; return D3DPRESENT_INTERVAL_DEFAULT;
} }
bool Surface::swap() bool Surface::swap()
{ {
return swapRect(0, 0, mWidth, mHeight); return swapRect(0, 0, mWidth, mHeight);
} }
bool Surface::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) bool Surface::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height)
{ {
if (!mPostSubBufferSupported) if (!mPostSubBufferSupported)
{ {
// Spec is not clear about how this should be handled. // Spec is not clear about how this should be handled.
return true; return true;
} }
return swapRect(x, y, width, height); return swapRect(x, y, width, height);
} }
EGLint Surface::getWidth() const EGLint Surface::getWidth() const
{ {
return mWidth; return mWidth;
} }
EGLint Surface::getHeight() const EGLint Surface::getHeight() const
{ {
return mHeight; return mHeight;
} }
EGLint Surface::isPostSubBufferSupported() const EGLint Surface::isPostSubBufferSupported() const
{ {
return mPostSubBufferSupported; return mPostSubBufferSupported;
} }
// Increments refcount on surface. // Increments refcount on surface.
// caller must Release() the returned surface // caller must Release() the returned surface
IDirect3DSurface9 *Surface::getRenderTarget() IDirect3DSurface9 *Surface::getRenderTarget()
{ {
if (mRenderTarget) if (mRenderTarget)
{ {
mRenderTarget->AddRef(); mRenderTarget->AddRef();
} }
return mRenderTarget; return mRenderTarget;
} }
// Increments refcount on surface. // Increments refcount on surface.
// caller must Release() the returned surface // caller must Release() the returned surface
IDirect3DSurface9 *Surface::getDepthStencil() IDirect3DSurface9 *Surface::getDepthStencil()
{ {
if (mDepthStencil) if (mDepthStencil)
{ {
mDepthStencil->AddRef(); mDepthStencil->AddRef();
} }
return mDepthStencil; return mDepthStencil;
} }
IDirect3DTexture9 *Surface::getOffscreenTexture() IDirect3DTexture9 *Surface::getOffscreenTexture()
{ {
if (mOffscreenTexture) if (mOffscreenTexture)
{ {
mOffscreenTexture->AddRef(); mOffscreenTexture->AddRef();
} }
return mOffscreenTexture; return mOffscreenTexture;
} }
void Surface::setSwapInterval(EGLint interval) void Surface::setSwapInterval(EGLint interval)
{ {
if (mSwapInterval == interval) if (mSwapInterval == interval)
{ {
return; return;
} }
mSwapInterval = interval; mSwapInterval = interval;
mSwapInterval = std::max(mSwapInterval, mDisplay->getMinSwapInterval()); mSwapInterval = std::max(mSwapInterval, mDisplay->getMinSwapInterval());
mSwapInterval = std::min(mSwapInterval, mDisplay->getMaxSwapInterval()); mSwapInterval = std::min(mSwapInterval, mDisplay->getMaxSwapInterval());
mPresentInterval = convertInterval(mSwapInterval); mPresentInterval = convertInterval(mSwapInterval);
mPresentIntervalDirty = true; mPresentIntervalDirty = true;
} }
EGLenum Surface::getTextureFormat() const EGLenum Surface::getTextureFormat() const
{ {
return mTextureFormat; return mTextureFormat;
} }
EGLenum Surface::getTextureTarget() const EGLenum Surface::getTextureTarget() const
{ {
return mTextureTarget; return mTextureTarget;
} }
void Surface::setBoundTexture(gl::Texture2D *texture) void Surface::setBoundTexture(gl::Texture2D *texture)
{ {
mTexture = texture; mTexture = texture;
} }
gl::Texture2D *Surface::getBoundTexture() const gl::Texture2D *Surface::getBoundTexture() const
{ {
return mTexture; return mTexture;
} }
D3DFORMAT Surface::getFormat() const D3DFORMAT Surface::getFormat() const
{ {
return mConfig->mRenderTargetFormat; return mConfig->mRenderTargetFormat;
} }
} }
This source diff could not be displayed because it is too large. You can view the blob instead.
// //
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// Texture.h: Defines the abstract gl::Texture class and its concrete derived // Texture.h: Defines the abstract gl::Texture class and its concrete derived
// classes Texture2D and TextureCubeMap. Implements GL texture objects and // classes Texture2D and TextureCubeMap. Implements GL texture objects and
// related functionality. [OpenGL ES 2.0.24] section 3.7 page 63. // related functionality. [OpenGL ES 2.0.24] section 3.7 page 63.
#ifndef LIBGLESV2_TEXTURE_H_ #ifndef LIBGLESV2_TEXTURE_H_
#define LIBGLESV2_TEXTURE_H_ #define LIBGLESV2_TEXTURE_H_
#include <vector> #include <vector>
#define GL_APICALL #define GL_APICALL
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <d3d9.h> #include <d3d9.h>
#include "common/debug.h" #include "common/debug.h"
#include "common/RefCountObject.h" #include "common/RefCountObject.h"
#include "libGLESv2/Renderbuffer.h" #include "libGLESv2/Renderbuffer.h"
#include "libGLESv2/utilities.h" #include "libGLESv2/utilities.h"
namespace egl namespace egl
{ {
class Surface; class Surface;
} }
namespace gl namespace gl
{ {
class Blit; class Blit;
class Framebuffer; class Framebuffer;
enum enum
{ {
// These are the maximums the implementation can support // These are the maximums the implementation can support
// The actual GL caps are limited by the device caps // The actual GL caps are limited by the device caps
// and should be queried from the Context // and should be queried from the Context
IMPLEMENTATION_MAX_TEXTURE_SIZE = 16384, IMPLEMENTATION_MAX_TEXTURE_SIZE = 16384,
IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE = 16384, IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE = 16384,
IMPLEMENTATION_MAX_TEXTURE_LEVELS = 15 // 1+log2 of MAX_TEXTURE_SIZE IMPLEMENTATION_MAX_TEXTURE_LEVELS = 15 // 1+log2 of MAX_TEXTURE_SIZE
}; };
class Image class Image
{ {
public: public:
Image(); Image();
~Image(); ~Image();
bool redefine(GLenum format, GLsizei width, GLsizei height, GLenum type, bool forceRelease); bool redefine(GLenum format, GLsizei width, GLsizei height, GLenum type, bool forceRelease);
void markDirty() {mDirty = true;} void markDirty() {mDirty = true;}
void markClean() {mDirty = false;} void markClean() {mDirty = false;}
bool isRenderableFormat() const; bool isRenderableFormat() const;
D3DFORMAT getD3DFormat() const; D3DFORMAT getD3DFormat() const;
GLsizei getWidth() const {return mWidth;} GLsizei getWidth() const {return mWidth;}
GLsizei getHeight() const {return mHeight;} GLsizei getHeight() const {return mHeight;}
GLenum getFormat() const {return mFormat;} GLenum getFormat() const {return mFormat;}
GLenum getType() const {return mType;} GLenum getType() const {return mType;}
bool isDirty() const {return mSurface && mDirty;} bool isDirty() const {return mSurface && mDirty;}
IDirect3DSurface9 *getSurface(); IDirect3DSurface9 *getSurface();
void setManagedSurface(IDirect3DSurface9 *surface); void setManagedSurface(IDirect3DSurface9 *surface);
void updateSurface(IDirect3DSurface9 *dest, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); void updateSurface(IDirect3DSurface9 *dest, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
void loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum type, void loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum type,
GLint unpackAlignment, const void *input); GLint unpackAlignment, const void *input);
void loadAlphaData(GLsizei width, GLsizei height, void loadAlphaData(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadAlphaDataSSE2(GLsizei width, GLsizei height, void loadAlphaDataSSE2(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadAlphaFloatData(GLsizei width, GLsizei height, void loadAlphaFloatData(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadAlphaHalfFloatData(GLsizei width, GLsizei height, void loadAlphaHalfFloatData(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadLuminanceData(GLsizei width, GLsizei height, void loadLuminanceData(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output, bool native) const; int inputPitch, const void *input, size_t outputPitch, void *output, bool native) const;
void loadLuminanceFloatData(GLsizei width, GLsizei height, void loadLuminanceFloatData(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadLuminanceHalfFloatData(GLsizei width, GLsizei height, void loadLuminanceHalfFloatData(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadLuminanceAlphaData(GLsizei width, GLsizei height, void loadLuminanceAlphaData(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output, bool native) const; int inputPitch, const void *input, size_t outputPitch, void *output, bool native) const;
void loadLuminanceAlphaFloatData(GLsizei width, GLsizei height, void loadLuminanceAlphaFloatData(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadLuminanceAlphaHalfFloatData(GLsizei width, GLsizei height, void loadLuminanceAlphaHalfFloatData(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBUByteData(GLsizei width, GLsizei height, void loadRGBUByteData(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGB565Data(GLsizei width, GLsizei height, void loadRGB565Data(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBFloatData(GLsizei width, GLsizei height, void loadRGBFloatData(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBHalfFloatData(GLsizei width, GLsizei height, void loadRGBHalfFloatData(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBAUByteDataSSE2(GLsizei width, GLsizei height, void loadRGBAUByteDataSSE2(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBAUByteData(GLsizei width, GLsizei height, void loadRGBAUByteData(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBA4444Data(GLsizei width, GLsizei height, void loadRGBA4444Data(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBA5551Data(GLsizei width, GLsizei height, void loadRGBA5551Data(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBAFloatData(GLsizei width, GLsizei height, void loadRGBAFloatData(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBAHalfFloatData(GLsizei width, GLsizei height, void loadRGBAHalfFloatData(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadBGRAData(GLsizei width, GLsizei height, void loadBGRAData(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
const void *input); const void *input);
void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, IDirect3DSurface9 *renderTarget); void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, IDirect3DSurface9 *renderTarget);
private: private:
DISALLOW_COPY_AND_ASSIGN(Image); DISALLOW_COPY_AND_ASSIGN(Image);
void createSurface(); void createSurface();
HRESULT lock(D3DLOCKED_RECT *lockedRect, const RECT *rect); HRESULT lock(D3DLOCKED_RECT *lockedRect, const RECT *rect);
void unlock(); void unlock();
GLsizei mWidth; GLsizei mWidth;
GLsizei mHeight; GLsizei mHeight;
GLenum mFormat; GLenum mFormat;
GLenum mType; GLenum mType;
bool mDirty; bool mDirty;
D3DPOOL mD3DPool; // can only be D3DPOOL_SYSTEMMEM or D3DPOOL_MANAGED since it needs to be lockable. D3DPOOL mD3DPool; // can only be D3DPOOL_SYSTEMMEM or D3DPOOL_MANAGED since it needs to be lockable.
D3DFORMAT mD3DFormat; D3DFORMAT mD3DFormat;
IDirect3DSurface9 *mSurface; IDirect3DSurface9 *mSurface;
}; };
class TextureStorage class TextureStorage
{ {
public: public:
explicit TextureStorage(DWORD usage); explicit TextureStorage(DWORD usage);
virtual ~TextureStorage(); virtual ~TextureStorage();
bool isRenderTarget() const; bool isRenderTarget() const;
bool isManaged() const; bool isManaged() const;
D3DPOOL getPool() const; D3DPOOL getPool() const;
DWORD getUsage() const; DWORD getUsage() const;
unsigned int getTextureSerial() const; unsigned int getTextureSerial() const;
virtual unsigned int getRenderTargetSerial(GLenum target) const = 0; virtual unsigned int getRenderTargetSerial(GLenum target) const = 0;
private: private:
DISALLOW_COPY_AND_ASSIGN(TextureStorage); DISALLOW_COPY_AND_ASSIGN(TextureStorage);
const DWORD mD3DUsage; const DWORD mD3DUsage;
const D3DPOOL mD3DPool; const D3DPOOL mD3DPool;
const unsigned int mTextureSerial; const unsigned int mTextureSerial;
static unsigned int issueTextureSerial(); static unsigned int issueTextureSerial();
static unsigned int mCurrentTextureSerial; static unsigned int mCurrentTextureSerial;
}; };
class Texture : public RefCountObject class Texture : public RefCountObject
{ {
public: public:
explicit Texture(GLuint id); explicit Texture(GLuint id);
virtual ~Texture(); virtual ~Texture();
virtual void addProxyRef(const Renderbuffer *proxy) = 0; virtual void addProxyRef(const Renderbuffer *proxy) = 0;
virtual void releaseProxy(const Renderbuffer *proxy) = 0; virtual void releaseProxy(const Renderbuffer *proxy) = 0;
virtual GLenum getTarget() const = 0; virtual GLenum getTarget() const = 0;
bool setMinFilter(GLenum filter); bool setMinFilter(GLenum filter);
bool setMagFilter(GLenum filter); bool setMagFilter(GLenum filter);
bool setWrapS(GLenum wrap); bool setWrapS(GLenum wrap);
bool setWrapT(GLenum wrap); bool setWrapT(GLenum wrap);
bool setUsage(GLenum usage); bool setUsage(GLenum usage);
GLenum getMinFilter() const; GLenum getMinFilter() const;
GLenum getMagFilter() const; GLenum getMagFilter() const;
GLenum getWrapS() const; GLenum getWrapS() const;
GLenum getWrapT() const; GLenum getWrapT() const;
GLenum getUsage() const; GLenum getUsage() const;
virtual bool isSamplerComplete() const = 0; virtual bool isSamplerComplete() const = 0;
IDirect3DBaseTexture9 *getTexture(); IDirect3DBaseTexture9 *getTexture();
virtual Renderbuffer *getRenderbuffer(GLenum target) = 0; virtual Renderbuffer *getRenderbuffer(GLenum target) = 0;
virtual void generateMipmaps() = 0; virtual void generateMipmaps() = 0;
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) = 0; virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) = 0;
bool hasDirtyParameters() const; bool hasDirtyParameters() const;
bool hasDirtyImages() const; bool hasDirtyImages() const;
void resetDirty(); void resetDirty();
unsigned int getTextureSerial(); unsigned int getTextureSerial();
unsigned int getRenderTargetSerial(GLenum target); unsigned int getRenderTargetSerial(GLenum target);
bool isImmutable() const; bool isImmutable() const;
static const GLuint INCOMPLETE_TEXTURE_ID = static_cast<GLuint>(-1); // Every texture takes an id at creation time. The value is arbitrary because it is never registered with the resource manager. static const GLuint INCOMPLETE_TEXTURE_ID = static_cast<GLuint>(-1); // Every texture takes an id at creation time. The value is arbitrary because it is never registered with the resource manager.
protected: protected:
void setImage(GLint unpackAlignment, const void *pixels, Image *image); void setImage(GLint unpackAlignment, const void *pixels, Image *image);
bool subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *image); bool subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *image);
void setCompressedImage(GLsizei imageSize, const void *pixels, Image *image); void setCompressedImage(GLsizei imageSize, const void *pixels, Image *image);
bool subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels, Image *image); bool subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels, Image *image);
GLint creationLevels(GLsizei width, GLsizei height) const; GLint creationLevels(GLsizei width, GLsizei height) const;
GLint creationLevels(GLsizei size) const; GLint creationLevels(GLsizei size) const;
virtual IDirect3DBaseTexture9 *getBaseTexture() const = 0; virtual IDirect3DBaseTexture9 *getBaseTexture() const = 0;
virtual void createTexture() = 0; virtual void createTexture() = 0;
virtual void updateTexture() = 0; virtual void updateTexture() = 0;
virtual void convertToRenderTarget() = 0; virtual void convertToRenderTarget() = 0;
virtual IDirect3DSurface9 *getRenderTarget(GLenum target) = 0; virtual IDirect3DSurface9 *getRenderTarget(GLenum target) = 0;
int levelCount() const; int levelCount() const;
static Blit *getBlitter(); static Blit *getBlitter();
static bool copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *source, bool fromManaged); static bool copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *source, bool fromManaged);
GLenum mMinFilter; GLenum mMinFilter;
GLenum mMagFilter; GLenum mMagFilter;
GLenum mWrapS; GLenum mWrapS;
GLenum mWrapT; GLenum mWrapT;
bool mDirtyParameters; bool mDirtyParameters;
GLenum mUsage; GLenum mUsage;
bool mDirtyImages; bool mDirtyImages;
bool mImmutable; bool mImmutable;
private: private:
DISALLOW_COPY_AND_ASSIGN(Texture); DISALLOW_COPY_AND_ASSIGN(Texture);
virtual TextureStorage *getStorage(bool renderTarget) = 0; virtual TextureStorage *getStorage(bool renderTarget) = 0;
}; };
class TextureStorage2D : public TextureStorage class TextureStorage2D : public TextureStorage
{ {
public: public:
explicit TextureStorage2D(IDirect3DTexture9 *surfaceTexture); explicit TextureStorage2D(IDirect3DTexture9 *surfaceTexture);
TextureStorage2D(int levels, D3DFORMAT format, DWORD usage, int width, int height); TextureStorage2D(int levels, D3DFORMAT format, DWORD usage, int width, int height);
virtual ~TextureStorage2D(); virtual ~TextureStorage2D();
IDirect3DSurface9 *getSurfaceLevel(int level); IDirect3DSurface9 *getSurfaceLevel(int level);
IDirect3DBaseTexture9 *getBaseTexture() const; IDirect3DBaseTexture9 *getBaseTexture() const;
virtual unsigned int getRenderTargetSerial(GLenum target) const; virtual unsigned int getRenderTargetSerial(GLenum target) const;
private: private:
DISALLOW_COPY_AND_ASSIGN(TextureStorage2D); DISALLOW_COPY_AND_ASSIGN(TextureStorage2D);
IDirect3DTexture9 *mTexture; IDirect3DTexture9 *mTexture;
const unsigned int mRenderTargetSerial; const unsigned int mRenderTargetSerial;
}; };
class Texture2D : public Texture class Texture2D : public Texture
{ {
public: public:
explicit Texture2D(GLuint id); explicit Texture2D(GLuint id);
~Texture2D(); ~Texture2D();
void addProxyRef(const Renderbuffer *proxy); void addProxyRef(const Renderbuffer *proxy);
void releaseProxy(const Renderbuffer *proxy); void releaseProxy(const Renderbuffer *proxy);
virtual GLenum getTarget() const; virtual GLenum getTarget() const;
GLsizei getWidth(GLint level) const; GLsizei getWidth(GLint level) const;
GLsizei getHeight(GLint level) const; GLsizei getHeight(GLint level) const;
GLenum getInternalFormat(GLint level) const; GLenum getInternalFormat(GLint level) const;
D3DFORMAT getD3DFormat(GLint level) const; D3DFORMAT getD3DFormat(GLint level) const;
bool isCompressed(GLint level) const; bool isCompressed(GLint level) const;
bool isDepth(GLint level) const; bool isDepth(GLint level) const;
void setImage(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels); void setImage(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels); void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels); void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels); void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
void copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); void copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
virtual bool isSamplerComplete() const; virtual bool isSamplerComplete() const;
virtual void bindTexImage(egl::Surface *surface); virtual void bindTexImage(egl::Surface *surface);
virtual void releaseTexImage(); virtual void releaseTexImage();
virtual void generateMipmaps(); virtual void generateMipmaps();
virtual Renderbuffer *getRenderbuffer(GLenum target); virtual Renderbuffer *getRenderbuffer(GLenum target);
protected: protected:
friend class RenderbufferTexture2D; friend class RenderbufferTexture2D;
virtual IDirect3DSurface9 *getRenderTarget(GLenum target); virtual IDirect3DSurface9 *getRenderTarget(GLenum target);
virtual IDirect3DSurface9 *getDepthStencil(GLenum target); virtual IDirect3DSurface9 *getDepthStencil(GLenum target);
private: private:
DISALLOW_COPY_AND_ASSIGN(Texture2D); DISALLOW_COPY_AND_ASSIGN(Texture2D);
virtual IDirect3DBaseTexture9 *getBaseTexture() const; virtual IDirect3DBaseTexture9 *getBaseTexture() const;
virtual void createTexture(); virtual void createTexture();
virtual void updateTexture(); virtual void updateTexture();
virtual void convertToRenderTarget(); virtual void convertToRenderTarget();
virtual TextureStorage *getStorage(bool renderTarget); virtual TextureStorage *getStorage(bool renderTarget);
bool isMipmapComplete() const; bool isMipmapComplete() const;
void redefineImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLenum type); void redefineImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLenum type);
void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
Image mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS]; Image mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
TextureStorage2D *mTexStorage; TextureStorage2D *mTexStorage;
egl::Surface *mSurface; egl::Surface *mSurface;
// A specific internal reference count is kept for colorbuffer proxy references, // A specific internal reference count is kept for colorbuffer proxy references,
// because, as the renderbuffer acting as proxy will maintain a binding pointer // because, as the renderbuffer acting as proxy will maintain a binding pointer
// back to this texture, there would be a circular reference if we used a binding // back to this texture, there would be a circular reference if we used a binding
// pointer here. This reference count will cause the pointer to be set to NULL if // pointer here. This reference count will cause the pointer to be set to NULL if
// the count drops to zero, but will not cause deletion of the Renderbuffer. // the count drops to zero, but will not cause deletion of the Renderbuffer.
Renderbuffer *mColorbufferProxy; Renderbuffer *mColorbufferProxy;
unsigned int mProxyRefs; unsigned int mProxyRefs;
}; };
class TextureStorageCubeMap : public TextureStorage class TextureStorageCubeMap : public TextureStorage
{ {
public: public:
TextureStorageCubeMap(int levels, D3DFORMAT format, DWORD usage, int size); TextureStorageCubeMap(int levels, D3DFORMAT format, DWORD usage, int size);
virtual ~TextureStorageCubeMap(); virtual ~TextureStorageCubeMap();
IDirect3DSurface9 *getCubeMapSurface(GLenum faceTarget, int level); IDirect3DSurface9 *getCubeMapSurface(GLenum faceTarget, int level);
IDirect3DBaseTexture9 *getBaseTexture() const; IDirect3DBaseTexture9 *getBaseTexture() const;
virtual unsigned int getRenderTargetSerial(GLenum target) const; virtual unsigned int getRenderTargetSerial(GLenum target) const;
private: private:
DISALLOW_COPY_AND_ASSIGN(TextureStorageCubeMap); DISALLOW_COPY_AND_ASSIGN(TextureStorageCubeMap);
IDirect3DCubeTexture9 *mTexture; IDirect3DCubeTexture9 *mTexture;
const unsigned int mFirstRenderTargetSerial; const unsigned int mFirstRenderTargetSerial;
}; };
class TextureCubeMap : public Texture class TextureCubeMap : public Texture
{ {
public: public:
explicit TextureCubeMap(GLuint id); explicit TextureCubeMap(GLuint id);
~TextureCubeMap(); ~TextureCubeMap();
void addProxyRef(const Renderbuffer *proxy); void addProxyRef(const Renderbuffer *proxy);
void releaseProxy(const Renderbuffer *proxy); void releaseProxy(const Renderbuffer *proxy);
virtual GLenum getTarget() const; virtual GLenum getTarget() const;
GLsizei getWidth(GLenum target, GLint level) const; GLsizei getWidth(GLenum target, GLint level) const;
GLsizei getHeight(GLenum target, GLint level) const; GLsizei getHeight(GLenum target, GLint level) const;
GLenum getInternalFormat(GLenum target, GLint level) const; GLenum getInternalFormat(GLenum target, GLint level) const;
D3DFORMAT getD3DFormat(GLenum target, GLint level) const; D3DFORMAT getD3DFormat(GLenum target, GLint level) const;
bool isCompressed(GLenum target, GLint level) const; bool isCompressed(GLenum target, GLint level) const;
void setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels); void setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels); void setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels); void setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels); void setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels); void setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels); void setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void setCompressedImage(GLenum face, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels); void setCompressedImage(GLenum face, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels); void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels); void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
void storage(GLsizei levels, GLenum internalformat, GLsizei size); void storage(GLsizei levels, GLenum internalformat, GLsizei size);
virtual bool isSamplerComplete() const; virtual bool isSamplerComplete() const;
virtual void generateMipmaps(); virtual void generateMipmaps();
virtual Renderbuffer *getRenderbuffer(GLenum target); virtual Renderbuffer *getRenderbuffer(GLenum target);
static unsigned int faceIndex(GLenum face); static unsigned int faceIndex(GLenum face);
protected: protected:
friend class RenderbufferTextureCubeMap; friend class RenderbufferTextureCubeMap;
virtual IDirect3DSurface9 *getRenderTarget(GLenum target); virtual IDirect3DSurface9 *getRenderTarget(GLenum target);
private: private:
DISALLOW_COPY_AND_ASSIGN(TextureCubeMap); DISALLOW_COPY_AND_ASSIGN(TextureCubeMap);
virtual IDirect3DBaseTexture9 *getBaseTexture() const; virtual IDirect3DBaseTexture9 *getBaseTexture() const;
virtual void createTexture(); virtual void createTexture();
virtual void updateTexture(); virtual void updateTexture();
virtual void convertToRenderTarget(); virtual void convertToRenderTarget();
virtual TextureStorage *getStorage(bool renderTarget); virtual TextureStorage *getStorage(bool renderTarget);
bool isCubeComplete() const; bool isCubeComplete() const;
bool isMipmapCubeComplete() const; bool isMipmapCubeComplete() const;
void setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels); void setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); void commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
void redefineImage(int faceIndex, GLint level, GLenum format, GLsizei width, GLsizei height, GLenum type); void redefineImage(int faceIndex, GLint level, GLenum format, GLsizei width, GLsizei height, GLenum type);
Image mImageArray[6][IMPLEMENTATION_MAX_TEXTURE_LEVELS]; Image mImageArray[6][IMPLEMENTATION_MAX_TEXTURE_LEVELS];
TextureStorageCubeMap *mTexStorage; TextureStorageCubeMap *mTexStorage;
// A specific internal reference count is kept for colorbuffer proxy references, // A specific internal reference count is kept for colorbuffer proxy references,
// because, as the renderbuffer acting as proxy will maintain a binding pointer // because, as the renderbuffer acting as proxy will maintain a binding pointer
// back to this texture, there would be a circular reference if we used a binding // back to this texture, there would be a circular reference if we used a binding
// pointer here. This reference count will cause the pointer to be set to NULL if // pointer here. This reference count will cause the pointer to be set to NULL if
// the count drops to zero, but will not cause deletion of the Renderbuffer. // the count drops to zero, but will not cause deletion of the Renderbuffer.
Renderbuffer *mFaceProxies[6]; Renderbuffer *mFaceProxies[6];
unsigned int *mFaceProxyRefs[6]; unsigned int *mFaceProxyRefs[6];
}; };
} }
#endif // LIBGLESV2_TEXTURE_H_ #endif // LIBGLESV2_TEXTURE_H_
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment