Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Unified Diff: tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp

Issue 1850543003: Revert of rename sk_gpu_test::GLContext to sk_gpu_test::GLTestContext (Closed) Base URL: https://chromium.googlesource.com/skia.git@move
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gpu/gl/win/CreatePlatformGLContext_win.cpp ('k') | tools/kilobench/kilobench.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp
diff --git a/tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp b/tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp
deleted file mode 100644
index 3d70be82cd07328607236ff8a01f634f87b09d68..0000000000000000000000000000000000000000
--- a/tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "gl/GLTestContext.h"
-
-#include <windows.h>
-#include <GL/GL.h>
-#include "win/SkWGL.h"
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-namespace {
-
-class WinGLTestContext : public sk_gpu_test::GLTestContext {
-public:
- WinGLTestContext(GrGLStandard forcedGpuAPI);
- ~WinGLTestContext() override;
-
-private:
- void destroyGLContext();
-
- void onPlatformMakeCurrent() const override;
- void onPlatformSwapBuffers() const override;
- GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override;
-
- HWND fWindow;
- HDC fDeviceContext;
- HGLRC fGlRenderContext;
- static ATOM gWC;
- SkWGLPbufferContext* fPbufferContext;
-};
-
-ATOM WinGLTestContext::gWC = 0;
-
-WinGLTestContext::WinGLTestContext(GrGLStandard forcedGpuAPI)
- : fWindow(nullptr)
- , fDeviceContext(nullptr)
- , fGlRenderContext(0)
- , fPbufferContext(nullptr) {
- HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(nullptr);
-
- if (!gWC) {
- WNDCLASS wc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hbrBackground = nullptr;
- wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
- wc.hIcon = LoadIcon(nullptr, IDI_APPLICATION);
- wc.hInstance = hInstance;
- wc.lpfnWndProc = (WNDPROC) DefWindowProc;
- wc.lpszClassName = TEXT("Griffin");
- wc.lpszMenuName = nullptr;
- wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
-
- gWC = RegisterClass(&wc);
- if (!gWC) {
- SkDebugf("Could not register window class.\n");
- return;
- }
- }
-
- if (!(fWindow = CreateWindow(TEXT("Griffin"),
- TEXT("The Invisible Man"),
- WS_OVERLAPPEDWINDOW,
- 0, 0, 1, 1,
- nullptr, nullptr,
- hInstance, nullptr))) {
- SkDebugf("Could not create window.\n");
- return;
- }
-
- if (!(fDeviceContext = GetDC(fWindow))) {
- SkDebugf("Could not get device context.\n");
- this->destroyGLContext();
- return;
- }
- // Requesting a Core profile would bar us from using NVPR. So we request
- // compatibility profile or GL ES.
- SkWGLContextRequest contextType =
- kGLES_GrGLStandard == forcedGpuAPI ?
- kGLES_SkWGLContextRequest : kGLPreferCompatibilityProfile_SkWGLContextRequest;
-
- fPbufferContext = SkWGLPbufferContext::Create(fDeviceContext, 0, contextType);
-
- HDC dc;
- HGLRC glrc;
-
- if (nullptr == fPbufferContext) {
- if (!(fGlRenderContext = SkCreateWGLContext(fDeviceContext, 0, contextType))) {
- SkDebugf("Could not create rendering context.\n");
- this->destroyGLContext();
- return;
- }
- dc = fDeviceContext;
- glrc = fGlRenderContext;
- } else {
- ReleaseDC(fWindow, fDeviceContext);
- fDeviceContext = 0;
- DestroyWindow(fWindow);
- fWindow = 0;
-
- dc = fPbufferContext->getDC();
- glrc = fPbufferContext->getGLRC();
- }
-
- if (!(wglMakeCurrent(dc, glrc))) {
- SkDebugf("Could not set the context.\n");
- this->destroyGLContext();
- return;
- }
-
- SkAutoTUnref<const GrGLInterface> gl(GrGLCreateNativeInterface());
- if (nullptr == gl.get()) {
- SkDebugf("Could not create GL interface.\n");
- this->destroyGLContext();
- return;
- }
- if (!gl->validate()) {
- SkDebugf("Could not validate GL interface.\n");
- this->destroyGLContext();
- return;
- }
-
- this->init(gl.release());
-}
-
-WinGLTestContext::~WinGLTestContext() {
- this->teardown();
- this->destroyGLContext();
-}
-
-void WinGLTestContext::destroyGLContext() {
- SkSafeSetNull(fPbufferContext);
- if (fGlRenderContext) {
- wglDeleteContext(fGlRenderContext);
- fGlRenderContext = 0;
- }
- if (fWindow && fDeviceContext) {
- ReleaseDC(fWindow, fDeviceContext);
- fDeviceContext = 0;
- }
- if (fWindow) {
- DestroyWindow(fWindow);
- fWindow = 0;
- }
-}
-
-void WinGLTestContext::onPlatformMakeCurrent() const {
- HDC dc;
- HGLRC glrc;
-
- if (nullptr == fPbufferContext) {
- dc = fDeviceContext;
- glrc = fGlRenderContext;
- } else {
- dc = fPbufferContext->getDC();
- glrc = fPbufferContext->getGLRC();
- }
-
- if (!wglMakeCurrent(dc, glrc)) {
- SkDebugf("Could not create rendering context.\n");
- }
-}
-
-void WinGLTestContext::onPlatformSwapBuffers() const {
- HDC dc;
-
- if (nullptr == fPbufferContext) {
- dc = fDeviceContext;
- } else {
- dc = fPbufferContext->getDC();
- }
- if (!SwapBuffers(dc)) {
- SkDebugf("Could not complete SwapBuffers.\n");
- }
-}
-
-GrGLFuncPtr WinGLTestContext::onPlatformGetProcAddress(const char* name) const {
- return reinterpret_cast<GrGLFuncPtr>(wglGetProcAddress(name));
-}
-
-} // anonymous namespace
-
-namespace sk_gpu_test {
-GLTestContext* CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI,
- GLTestContext *shareContext) {
- SkASSERT(!shareContext);
- if (shareContext) {
- return nullptr;
- }
- WinGLTestContext *ctx = new WinGLTestContext(forcedGpuAPI);
- if (!ctx->isValid()) {
- delete ctx;
- return nullptr;
- }
- return ctx;
-}
-} // namespace sk_gpu_test
-
« no previous file with comments | « tools/gpu/gl/win/CreatePlatformGLContext_win.cpp ('k') | tools/kilobench/kilobench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698