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

Side by Side Diff: src/gpu/gl/GrGLBufferImpl.cpp

Issue 1496843003: Revert of Add transfer buffer support. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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 | « src/gpu/gl/GrGLBufferImpl.h ('k') | src/gpu/gl/GrGLDefines.h » ('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 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrGLBufferImpl.h" 8 #include "GrGLBufferImpl.h"
9 #include "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 fCPUData = nullptr; 58 fCPUData = nullptr;
59 VALIDATE(); 59 VALIDATE();
60 } 60 }
61 61
62 void* GrGLBufferImpl::map(GrGLGpu* gpu) { 62 void* GrGLBufferImpl::map(GrGLGpu* gpu) {
63 VALIDATE(); 63 VALIDATE();
64 SkASSERT(!this->isMapped()); 64 SkASSERT(!this->isMapped());
65 if (0 == fDesc.fID) { 65 if (0 == fDesc.fID) {
66 fMapPtr = fCPUData; 66 fMapPtr = fCPUData;
67 } else { 67 } else {
68 fMapPtr = gpu->mapBuffer(fDesc.fID, fBufferType, fDesc.fUsage, fGLSizeIn Bytes, 68 fMapPtr = gpu->mapBuffer(fDesc.fID, fBufferType, fDesc.fDynamic, fGLSize InBytes,
69 fDesc.fSizeInBytes); 69 fDesc.fSizeInBytes);
70 fGLSizeInBytes = fDesc.fSizeInBytes; 70 fGLSizeInBytes = fDesc.fSizeInBytes;
71 } 71 }
72 VALIDATE(); 72 VALIDATE();
73 return fMapPtr; 73 return fMapPtr;
74 } 74 }
75 75
76 void GrGLBufferImpl::unmap(GrGLGpu* gpu) { 76 void GrGLBufferImpl::unmap(GrGLGpu* gpu) {
77 VALIDATE(); 77 VALIDATE();
78 SkASSERT(this->isMapped()); 78 SkASSERT(this->isMapped());
79 if (0 != fDesc.fID) { 79 if (0 != fDesc.fID) {
80 gpu->unmapBuffer(fDesc.fID, fBufferType, fMapPtr); 80 gpu->unmapBuffer(fDesc.fID, fBufferType, fMapPtr);
81 } 81 }
82 fMapPtr = nullptr; 82 fMapPtr = nullptr;
83 } 83 }
84 84
85 bool GrGLBufferImpl::isMapped() const { 85 bool GrGLBufferImpl::isMapped() const {
86 VALIDATE(); 86 VALIDATE();
87 return SkToBool(fMapPtr); 87 return SkToBool(fMapPtr);
88 } 88 }
89 89
90 bool GrGLBufferImpl::updateData(GrGLGpu* gpu, const void* src, size_t srcSizeInB ytes) { 90 bool GrGLBufferImpl::updateData(GrGLGpu* gpu, const void* src, size_t srcSizeInB ytes) {
91 SkASSERT(!this->isMapped()); 91 SkASSERT(!this->isMapped());
92 SkASSERT(GR_GL_ARRAY_BUFFER == fBufferType || GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType);
93 VALIDATE(); 92 VALIDATE();
94 if (srcSizeInBytes > fDesc.fSizeInBytes) { 93 if (srcSizeInBytes > fDesc.fSizeInBytes) {
95 return false; 94 return false;
96 } 95 }
97 if (0 == fDesc.fID) { 96 if (0 == fDesc.fID) {
98 memcpy(fCPUData, src, srcSizeInBytes); 97 memcpy(fCPUData, src, srcSizeInBytes);
99 return true; 98 return true;
100 } 99 }
101 gpu->bufferData(fDesc.fID, fBufferType, fDesc.fUsage, fDesc.fSizeInBytes, sr c, 100 gpu->bufferData(fDesc.fID, fBufferType, fDesc.fDynamic, fDesc.fSizeInBytes, src,
102 srcSizeInBytes); 101 srcSizeInBytes);
103 #if GR_GL_USE_BUFFER_DATA_NULL_HINT 102 #if GR_GL_USE_BUFFER_DATA_NULL_HINT
104 fGLSizeInBytes = fDesc.fSizeInBytes; 103 fGLSizeInBytes = fDesc.fSizeInBytes;
105 #else 104 #else
106 fGLSizeInBytes = srcSizeInBytes; 105 fGLSizeInBytes = srcSizeInBytes;
107 #endif 106 #endif
108 VALIDATE(); 107 VALIDATE();
109 return true; 108 return true;
110 } 109 }
111 110
112 void GrGLBufferImpl::validate() const { 111 void GrGLBufferImpl::validate() const {
113 SkASSERT(GR_GL_ARRAY_BUFFER == fBufferType || GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType || 112 SkASSERT(GR_GL_ARRAY_BUFFER == fBufferType || GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType);
114 GR_GL_PIXEL_PACK_BUFFER == fBufferType || GR_GL_PIXEL_UNPACK_BUFFER == fBufferType);
115 // The following assert isn't valid when the buffer has been abandoned: 113 // The following assert isn't valid when the buffer has been abandoned:
116 // SkASSERT((0 == fDesc.fID) == (fCPUData)); 114 // SkASSERT((0 == fDesc.fID) == (fCPUData));
117 SkASSERT(nullptr == fCPUData || 0 == fGLSizeInBytes); 115 SkASSERT(nullptr == fCPUData || 0 == fGLSizeInBytes);
118 SkASSERT(nullptr == fMapPtr || fCPUData || fGLSizeInBytes <= fDesc.fSizeInBy tes); 116 SkASSERT(nullptr == fMapPtr || fCPUData || fGLSizeInBytes <= fDesc.fSizeInBy tes);
119 SkASSERT(nullptr == fCPUData || nullptr == fMapPtr || fCPUData == fMapPtr); 117 SkASSERT(nullptr == fCPUData || nullptr == fMapPtr || fCPUData == fMapPtr);
120 } 118 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLBufferImpl.h ('k') | src/gpu/gl/GrGLDefines.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698