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

Side by Side Diff: tools/gpu/gl/null/NullGLContext.cpp

Issue 1815823002: Move SkGLContext and some GrGLInterface implementations to skgputest module (Closed) Base URL: https://chromium.googlesource.com/skia.git@debugobject
Patch Set: fix windows and android? Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « tools/gpu/gl/null/NullGLContext.h ('k') | tools/gpu/gl/win/CreatePlatformGLContext_win.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1
1 /* 2 /*
2 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
3 * 4 *
4 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 6 * found in the LICENSE file.
6 */ 7 */
7 8
8 9 #include "NullGLContext.h"
10 #include "gl/GrGLTestInterface.h"
11 #include "gl/GrGLDefines.h"
9 #include "gl/GrGLInterface.h" 12 #include "gl/GrGLInterface.h"
10 #include "GrGLTestInterface.h" 13 #include "gl/GrGLTypes.h"
11 #include "SkMutex.h" 14 #include "SkMutex.h"
12 #include "SkTDArray.h" 15 #include "SkTDArray.h"
13 16
14 // added to suppress 'no previous prototype' warning and because this code is du plicated in
15 // SkNullGLContext.cpp
16 namespace { 17 namespace {
17 18
18 class BufferObj { 19 class BufferObj {
19 public: 20 public:
20 BufferObj(GrGLuint id) : fID(id), fDataPtr(nullptr), fSize(0), fMapped(false ) {} 21 BufferObj(GrGLuint id) : fID(id), fDataPtr(nullptr), fSize(0), fMapped(false ) {}
21 ~BufferObj() { delete[] fDataPtr; } 22 ~BufferObj() { delete[] fDataPtr; }
22 23
23 void allocate(GrGLsizeiptr size, const GrGLchar* dataPtr) { 24 void allocate(GrGLsizeiptr size, const GrGLchar* dataPtr) {
24 if (fDataPtr) { 25 if (fDataPtr) {
25 SkASSERT(0 != fSize); 26 SkASSERT(0 != fSize);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 }; 108 };
108 109
109 /** Null interface implementation */ 110 /** Null interface implementation */
110 class NullInterface : public GrGLTestInterface { 111 class NullInterface : public GrGLTestInterface {
111 public: 112 public:
112 NullInterface() 113 NullInterface()
113 : fCurrArrayBuffer(0) 114 : fCurrArrayBuffer(0)
114 , fCurrElementArrayBuffer(0) 115 , fCurrElementArrayBuffer(0)
115 , fCurrPixelPackBuffer(0) 116 , fCurrPixelPackBuffer(0)
116 , fCurrPixelUnpackBuffer(0) 117 , fCurrPixelUnpackBuffer(0)
117 , fCurrProgramID(0)
118 , fCurrShaderID(0) 118 , fCurrShaderID(0)
119 , fCurrGenericID(0) 119 , fCurrGenericID(0)
120 , fCurrUniformLocation(0) { 120 , fCurrUniformLocation(0) {
121 this->init(kGL_GrGLStandard); 121 this->init(kGL_GrGLStandard);
122 } 122 }
123 123
124 GrGLenum checkFramebufferStatus(GrGLenum target) override { 124 GrGLenum checkFramebufferStatus(GrGLenum target) override {
125 return GR_GL_FRAMEBUFFER_COMPLETE; 125 return GR_GL_FRAMEBUFFER_COMPLETE;
126 } 126 }
127 127
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 break; 178 break;
179 case GR_GL_PIXEL_PACK_BUFFER: 179 case GR_GL_PIXEL_PACK_BUFFER:
180 fCurrPixelPackBuffer = buffer; 180 fCurrPixelPackBuffer = buffer;
181 break; 181 break;
182 case GR_GL_PIXEL_UNPACK_BUFFER: 182 case GR_GL_PIXEL_UNPACK_BUFFER:
183 fCurrPixelUnpackBuffer = buffer; 183 fCurrPixelUnpackBuffer = buffer;
184 break; 184 break;
185 } 185 }
186 } 186 }
187 187
188 // deleting a bound buffer has the side effect of binding 0 188 // deleting a bound buffer has the side effect of binding 0
189 GrGLvoid deleteBuffers(GrGLsizei n, const GrGLuint* ids) override { 189 GrGLvoid deleteBuffers(GrGLsizei n, const GrGLuint* ids) override {
190 for (int i = 0; i < n; ++i) { 190 for (int i = 0; i < n; ++i) {
191 if (ids[i] == fCurrArrayBuffer) { 191 if (ids[i] == fCurrArrayBuffer) {
192 fCurrArrayBuffer = 0; 192 fCurrArrayBuffer = 0;
193 } 193 }
194 if (ids[i] == fCurrElementArrayBuffer) { 194 if (ids[i] == fCurrElementArrayBuffer) {
195 fCurrElementArrayBuffer = 0; 195 fCurrElementArrayBuffer = 0;
196 } 196 }
197 if (ids[i] == fCurrPixelPackBuffer) { 197 if (ids[i] == fCurrPixelPackBuffer) {
198 fCurrPixelPackBuffer = 0; 198 fCurrPixelPackBuffer = 0;
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 const char* NullInterface::kExtensions[] = { 598 const char* NullInterface::kExtensions[] = {
599 "GL_ARB_framebuffer_object", 599 "GL_ARB_framebuffer_object",
600 "GL_ARB_blend_func_extended", 600 "GL_ARB_blend_func_extended",
601 "GL_ARB_timer_query", 601 "GL_ARB_timer_query",
602 "GL_ARB_draw_buffers", 602 "GL_ARB_draw_buffers",
603 "GL_ARB_occlusion_query", 603 "GL_ARB_occlusion_query",
604 "GL_EXT_stencil_wrap", 604 "GL_EXT_stencil_wrap",
605 nullptr, // signifies the end of the array. 605 nullptr, // signifies the end of the array.
606 }; 606 };
607 607
608 class NullGLContext : public sk_gpu_test::GLContext {
609 public:
610 NullGLContext() { this->init(new NullInterface); }
611 ~NullGLContext() override { this->teardown(); }
612
613 private:
614 void onPlatformMakeCurrent() const override {};
615 void onPlatformSwapBuffers() const override {}
616 GrGLFuncPtr onPlatformGetProcAddress(const char*) const override { return nu llptr; }
617 };
608 } // anonymous namespace 618 } // anonymous namespace
609 619
610 const GrGLInterface* GrGLCreateNullInterface() { return new NullInterface; } 620 namespace sk_gpu_test {
621 GLContext* CreateNullGLContext() {
622 GLContext* ctx = new NullGLContext();
623 if (ctx->isValid()) {
624 return ctx;
625 }
626 delete ctx;
627 return nullptr;
628 }
629 } // namespace sk_gpu_test
630
OLDNEW
« no previous file with comments | « tools/gpu/gl/null/NullGLContext.h ('k') | tools/gpu/gl/win/CreatePlatformGLContext_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698