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

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

Issue 964543002: Revert of Improve tracking of bound FBOs in GrGLGpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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 | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLRenderTarget.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 2011 Google Inc. 2 * Copyright 2011 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 8
9 #include "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 #include "GrGLStencilBuffer.h" 10 #include "GrGLStencilBuffer.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 SkDebugf("\n"); 144 SkDebugf("\n");
145 SkDebugf("%s", this->glCaps().dump().c_str()); 145 SkDebugf("%s", this->glCaps().dump().c_str());
146 } 146 }
147 147
148 fProgramCache = SkNEW_ARGS(ProgramCache, (this)); 148 fProgramCache = SkNEW_ARGS(ProgramCache, (this));
149 149
150 SkASSERT(this->glCaps().maxVertexAttributes() >= GrGeometryProcessor::kMaxVe rtexAttribs); 150 SkASSERT(this->glCaps().maxVertexAttributes() >= GrGeometryProcessor::kMaxVe rtexAttribs);
151 151
152 fLastSuccessfulStencilFmtIdx = 0; 152 fLastSuccessfulStencilFmtIdx = 0;
153 fHWProgramID = 0; 153 fHWProgramID = 0;
154 fTempSrcFBOID = 0;
155 fTempDstFBOID = 0;
156 fStencilClearFBOID = 0;
154 157
155 if (this->glCaps().pathRenderingSupport()) { 158 if (this->glCaps().pathRenderingSupport()) {
156 fPathRendering.reset(new GrGLPathRendering(this)); 159 fPathRendering.reset(new GrGLPathRendering(this));
157 } 160 }
158 } 161 }
159 162
160 GrGLGpu::~GrGLGpu() { 163 GrGLGpu::~GrGLGpu() {
161 if (0 != fHWProgramID) { 164 if (0 != fHWProgramID) {
162 // detach the current program so there is no confusion on OpenGL's part 165 // detach the current program so there is no confusion on OpenGL's part
163 // that we want it to be deleted 166 // that we want it to be deleted
164 SkASSERT(fHWProgramID == fCurrentProgram->programID()); 167 SkASSERT(fHWProgramID == fCurrentProgram->programID());
165 GL_CALL(UseProgram(0)); 168 GL_CALL(UseProgram(0));
166 } 169 }
167 170
168 if (fTempSrcFBO) { 171 if (0 != fTempSrcFBOID) {
169 fTempSrcFBO->release(this->glInterface()); 172 GL_CALL(DeleteFramebuffers(1, &fTempSrcFBOID));
170 fTempSrcFBO.reset(NULL);
171 } 173 }
172 if (fTempDstFBO) { 174 if (0 != fTempDstFBOID) {
173 fTempDstFBO->release(this->glInterface()); 175 GL_CALL(DeleteFramebuffers(1, &fTempDstFBOID));
174 fTempDstFBO.reset(NULL);
175 } 176 }
176 if (fStencilClearFBO) { 177 if (0 != fStencilClearFBOID) {
177 fStencilClearFBO->release(this->glInterface()); 178 GL_CALL(DeleteFramebuffers(1, &fStencilClearFBOID));
178 fStencilClearFBO.reset(NULL);
179 } 179 }
180 180
181 delete fProgramCache; 181 delete fProgramCache;
182 } 182 }
183 183
184 void GrGLGpu::contextAbandoned() { 184 void GrGLGpu::contextAbandoned() {
185 INHERITED::contextAbandoned(); 185 INHERITED::contextAbandoned();
186 fProgramCache->abandon(); 186 fProgramCache->abandon();
187 fHWProgramID = 0; 187 fHWProgramID = 0;
188 if (fTempSrcFBO) { 188 fTempSrcFBOID = 0;
189 fTempSrcFBO->abandon(); 189 fTempDstFBOID = 0;
190 fTempSrcFBO.reset(NULL); 190 fStencilClearFBOID = 0;
191 }
192 if (fTempDstFBO) {
193 fTempDstFBO->abandon();
194 fTempDstFBO.reset(NULL);
195 }
196 if (fStencilClearFBO) {
197 fStencilClearFBO->abandon();
198 fStencilClearFBO.reset(NULL);
199 }
200
201 if (this->glCaps().pathRenderingSupport()) { 191 if (this->glCaps().pathRenderingSupport()) {
202 this->glPathRendering()->abandonGpuResources(); 192 this->glPathRendering()->abandonGpuResources();
203 } 193 }
204 } 194 }
205 195
206 /////////////////////////////////////////////////////////////////////////////// 196 ///////////////////////////////////////////////////////////////////////////////
207 GrPixelConfig GrGLGpu::preferredReadPixelsConfig(GrPixelConfig readConfig, 197 GrPixelConfig GrGLGpu::preferredReadPixelsConfig(GrPixelConfig readConfig,
208 GrPixelConfig surfaceConfig) co nst { 198 GrPixelConfig surfaceConfig) co nst {
209 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig ) { 199 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig ) {
210 return kBGRA_8888_GrPixelConfig; 200 return kBGRA_8888_GrPixelConfig;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 fHWStencilSettings.invalidate(); 324 fHWStencilSettings.invalidate();
335 fHWStencilTestEnabled = kUnknown_TriState; 325 fHWStencilTestEnabled = kUnknown_TriState;
336 } 326 }
337 327
338 // Vertex 328 // Vertex
339 if (resetBits & kVertex_GrGLBackendState) { 329 if (resetBits & kVertex_GrGLBackendState) {
340 fHWGeometryState.invalidate(); 330 fHWGeometryState.invalidate();
341 } 331 }
342 332
343 if (resetBits & kRenderTarget_GrGLBackendState) { 333 if (resetBits & kRenderTarget_GrGLBackendState) {
344 for (size_t i = 0; i < SK_ARRAY_COUNT(fHWFBOBinding); ++i) { 334 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
345 fHWFBOBinding[i].invalidate();
346 }
347 } 335 }
348 336
349 if (resetBits & kPathRendering_GrGLBackendState) { 337 if (resetBits & kPathRendering_GrGLBackendState) {
350 if (this->caps()->pathRenderingSupport()) { 338 if (this->caps()->pathRenderingSupport()) {
351 this->glPathRendering()->resetContext(); 339 this->glPathRendering()->resetContext();
352 } 340 }
353 } 341 }
354 342
355 // we assume these values 343 // we assume these values
356 if (resetBits & kPixelStore_GrGLBackendState) { 344 if (resetBits & kPixelStore_GrGLBackendState) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 425 }
438 if (NULL == texture) { 426 if (NULL == texture) {
439 return NULL; 427 return NULL;
440 } 428 }
441 429
442 return texture; 430 return texture;
443 } 431 }
444 432
445 GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe sc& wrapDesc) { 433 GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe sc& wrapDesc) {
446 GrGLRenderTarget::IDDesc idDesc; 434 GrGLRenderTarget::IDDesc idDesc;
447 GrGLuint fboID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); 435 idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle);
448 idDesc.fRenderFBO.reset(SkNEW_ARGS(GrGLFBO, (fboID)));
449 idDesc.fMSColorRenderbufferID = 0; 436 idDesc.fMSColorRenderbufferID = 0;
437 idDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID;
450 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; 438 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle;
451 439
452 GrSurfaceDesc desc; 440 GrSurfaceDesc desc;
453 desc.fConfig = wrapDesc.fConfig; 441 desc.fConfig = wrapDesc.fConfig;
454 desc.fFlags = kCheckAllocation_GrSurfaceFlag; 442 desc.fFlags = kCheckAllocation_GrSurfaceFlag;
455 desc.fWidth = wrapDesc.fWidth; 443 desc.fWidth = wrapDesc.fWidth;
456 desc.fHeight = wrapDesc.fHeight; 444 desc.fHeight = wrapDesc.fHeight;
457 desc.fSampleCnt = wrapDesc.fSampleCnt; 445 desc.fSampleCnt = wrapDesc.fSampleCnt;
458 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); 446 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true);
459 447
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 case GrGLCaps::kNone_MSFBOType: 807 case GrGLCaps::kNone_MSFBOType:
820 SkFAIL("Shouldn't be here if we don't support multisampled renderbuf fers."); 808 SkFAIL("Shouldn't be here if we don't support multisampled renderbuf fers.");
821 break; 809 break;
822 } 810 }
823 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));; 811 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));;
824 } 812 }
825 813
826 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, bool budgeted , GrGLuint texID, 814 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, bool budgeted , GrGLuint texID,
827 GrGLRenderTarget::IDDesc* idDesc) { 815 GrGLRenderTarget::IDDesc* idDesc) {
828 idDesc->fMSColorRenderbufferID = 0; 816 idDesc->fMSColorRenderbufferID = 0;
817 idDesc->fRTFBOID = 0;
818 idDesc->fTexFBOID = 0;
829 idDesc->fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle : 819 idDesc->fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle :
830 GrGpuResource::kUncached_LifeCycle; 820 GrGpuResource::kUncached_LifeCycle;
831 821
832 GrGLenum status; 822 GrGLenum status;
833 823
834 GrGLenum msColorFormat = 0; // suppress warning 824 GrGLenum msColorFormat = 0; // suppress warning
835 825
836 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) { 826 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) {
837 goto FAILED; 827 goto FAILED;
838 } 828 }
839 829
840 idDesc->fTextureFBO.reset(SkNEW_ARGS(GrGLFBO, (this->glInterface()))); 830 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID));
841 if (!idDesc->fTextureFBO->isValid()) { 831 if (!idDesc->fTexFBOID) {
842 goto FAILED; 832 goto FAILED;
843 } 833 }
844 834
835
845 // If we are using multisampling we will create two FBOS. We render to one a nd then resolve to 836 // If we are using multisampling we will create two FBOS. We render to one a nd then resolve to
846 // the texture bound to the other. The exception is the IMG multisample exte nsion. With this 837 // the texture bound to the other. The exception is the IMG multisample exte nsion. With this
847 // extension the texture is multisampled when rendered to and then auto-reso lves it when it is 838 // extension the texture is multisampled when rendered to and then auto-reso lves it when it is
848 // rendered from. 839 // rendered from.
849 if (desc.fSampleCnt > 0 && this->glCaps().usesMSAARenderBuffers()) { 840 if (desc.fSampleCnt > 0 && this->glCaps().usesMSAARenderBuffers()) {
850 idDesc->fRenderFBO.reset(SkNEW_ARGS(GrGLFBO, (this->glInterface()))); 841 GL_CALL(GenFramebuffers(1, &idDesc->fRTFBOID));
851 if (!idDesc->fRenderFBO->isValid()) {
852 goto FAILED;
853 }
854 GL_CALL(GenRenderbuffers(1, &idDesc->fMSColorRenderbufferID)); 842 GL_CALL(GenRenderbuffers(1, &idDesc->fMSColorRenderbufferID));
855 if (!idDesc->fMSColorRenderbufferID || 843 if (!idDesc->fRTFBOID ||
844 !idDesc->fMSColorRenderbufferID ||
856 !this->configToGLFormats(desc.fConfig, 845 !this->configToGLFormats(desc.fConfig,
857 // ES2 and ES3 require sized internal forma ts for rb storage. 846 // ES2 and ES3 require sized internal forma ts for rb storage.
858 kGLES_GrGLStandard == this->glStandard(), 847 kGLES_GrGLStandard == this->glStandard(),
859 &msColorFormat, 848 &msColorFormat,
860 NULL, 849 NULL,
861 NULL)) { 850 NULL)) {
862 goto FAILED; 851 goto FAILED;
863 } 852 }
864 } else { 853 } else {
865 idDesc->fRenderFBO.reset(SkRef(idDesc->fTextureFBO.get())); 854 idDesc->fRTFBOID = idDesc->fTexFBOID;
866 } 855 }
867 856
868 if (idDesc->fRenderFBO != idDesc->fTextureFBO) { 857 // below here we may bind the FBO
858 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
859 if (idDesc->fRTFBOID != idDesc->fTexFBOID) {
869 SkASSERT(desc.fSampleCnt > 0); 860 SkASSERT(desc.fSampleCnt > 0);
870 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, idDesc->fMSColorRenderbuffe rID)); 861 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, idDesc->fMSColorRenderbuffe rID));
871 if (!renderbuffer_storage_msaa(fGLContext, 862 if (!renderbuffer_storage_msaa(fGLContext,
872 desc.fSampleCnt, 863 desc.fSampleCnt,
873 msColorFormat, 864 msColorFormat,
874 desc.fWidth, desc.fHeight)) { 865 desc.fWidth, desc.fHeight)) {
875 goto FAILED; 866 goto FAILED;
876 } 867 }
877 this->bindFBO(kDraw_FBOBinding, idDesc->fRenderFBO); 868 fStats.incRenderTargetBinds();
869 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, idDesc->fRTFBOID));
878 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 870 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
879 GR_GL_COLOR_ATTACHMENT0, 871 GR_GL_COLOR_ATTACHMENT0,
880 GR_GL_RENDERBUFFER, 872 GR_GL_RENDERBUFFER,
881 idDesc->fMSColorRenderbufferID)); 873 idDesc->fMSColorRenderbufferID));
882 if ((desc.fFlags & kCheckAllocation_GrSurfaceFlag) || 874 if ((desc.fFlags & kCheckAllocation_GrSurfaceFlag) ||
883 !this->glCaps().isConfigVerifiedColorAttachment(desc.fConfig)) { 875 !this->glCaps().isConfigVerifiedColorAttachment(desc.fConfig)) {
884 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); 876 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
885 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { 877 if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
886 goto FAILED; 878 goto FAILED;
887 } 879 }
888 fGLContext.caps()->markConfigAsValidColorAttachment(desc.fConfig); 880 fGLContext.caps()->markConfigAsValidColorAttachment(desc.fConfig);
889 } 881 }
890 } 882 }
891 this->bindFBO(kDraw_FBOBinding, idDesc->fTextureFBO); 883 fStats.incRenderTargetBinds();
884 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, idDesc->fTexFBOID));
892 885
893 if (this->glCaps().usesImplicitMSAAResolve() && desc.fSampleCnt > 0) { 886 if (this->glCaps().usesImplicitMSAAResolve() && desc.fSampleCnt > 0) {
894 GL_CALL(FramebufferTexture2DMultisample(GR_GL_FRAMEBUFFER, 887 GL_CALL(FramebufferTexture2DMultisample(GR_GL_FRAMEBUFFER,
895 GR_GL_COLOR_ATTACHMENT0, 888 GR_GL_COLOR_ATTACHMENT0,
896 GR_GL_TEXTURE_2D, 889 GR_GL_TEXTURE_2D,
897 texID, 0, desc.fSampleCnt)); 890 texID, 0, desc.fSampleCnt));
898 } else { 891 } else {
899 GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER, 892 GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER,
900 GR_GL_COLOR_ATTACHMENT0, 893 GR_GL_COLOR_ATTACHMENT0,
901 GR_GL_TEXTURE_2D, 894 GR_GL_TEXTURE_2D,
902 texID, 0)); 895 texID, 0));
903 } 896 }
904 if ((desc.fFlags & kCheckAllocation_GrSurfaceFlag) || 897 if ((desc.fFlags & kCheckAllocation_GrSurfaceFlag) ||
905 !this->glCaps().isConfigVerifiedColorAttachment(desc.fConfig)) { 898 !this->glCaps().isConfigVerifiedColorAttachment(desc.fConfig)) {
906 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); 899 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
907 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { 900 if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
908 goto FAILED; 901 goto FAILED;
909 } 902 }
910 fGLContext.caps()->markConfigAsValidColorAttachment(desc.fConfig); 903 fGLContext.caps()->markConfigAsValidColorAttachment(desc.fConfig);
911 } 904 }
912 905
913 return true; 906 return true;
914 907
915 FAILED: 908 FAILED:
916 if (idDesc->fMSColorRenderbufferID) { 909 if (idDesc->fMSColorRenderbufferID) {
917 GL_CALL(DeleteRenderbuffers(1, &idDesc->fMSColorRenderbufferID)); 910 GL_CALL(DeleteRenderbuffers(1, &idDesc->fMSColorRenderbufferID));
918 } 911 }
919 if (idDesc->fRenderFBO) { 912 if (idDesc->fRTFBOID != idDesc->fTexFBOID) {
920 idDesc->fRenderFBO->release(this->glInterface()); 913 GL_CALL(DeleteFramebuffers(1, &idDesc->fRTFBOID));
921 } 914 }
922 if (idDesc->fTextureFBO) { 915 if (idDesc->fTexFBOID) {
923 idDesc->fTextureFBO->release(this->glInterface()); 916 GL_CALL(DeleteFramebuffers(1, &idDesc->fTexFBOID));
924 } 917 }
925 return false; 918 return false;
926 } 919 }
927 920
928 // good to set a break-point here to know when createTexture fails 921 // good to set a break-point here to know when createTexture fails
929 static GrTexture* return_null_texture() { 922 static GrTexture* return_null_texture() {
930 // SkDEBUGFAIL("null texture"); 923 // SkDEBUGFAIL("null texture");
931 return NULL; 924 return NULL;
932 } 925 }
933 926
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 get_stencil_rb_sizes(this->glInterface(), &format); 1179 get_stencil_rb_sizes(this->glInterface(), &format);
1187 SkAutoTUnref<GrGLStencilBuffer> sb(SkNEW_ARGS(GrGLStencilBuffer, 1180 SkAutoTUnref<GrGLStencilBuffer> sb(SkNEW_ARGS(GrGLStencilBuffer,
1188 (this, sbDesc, width, height, samples, format))); 1181 (this, sbDesc, width, height, samples, format)));
1189 if (this->attachStencilBufferToRenderTarget(sb, rt)) { 1182 if (this->attachStencilBufferToRenderTarget(sb, rt)) {
1190 fLastSuccessfulStencilFmtIdx = sIdx; 1183 fLastSuccessfulStencilFmtIdx = sIdx;
1191 rt->renderTargetPriv().didAttachStencilBuffer(sb); 1184 rt->renderTargetPriv().didAttachStencilBuffer(sb);
1192 1185
1193 // Clear the stencil buffer. We use a special purpose FBO for th is so that the 1186 // Clear the stencil buffer. We use a special purpose FBO for th is so that the
1194 // entire stencil buffer is cleared, even if it is attached to a n FBO with a 1187 // entire stencil buffer is cleared, even if it is attached to a n FBO with a
1195 // smaller color target. 1188 // smaller color target.
1196 if (!fStencilClearFBO) { 1189 if (0 == fStencilClearFBOID) {
1197 fStencilClearFBO.reset(SkNEW_ARGS(GrGLFBO, (this->glInterfac e()))); 1190 GL_CALL(GenFramebuffers(1, &fStencilClearFBOID));
1198 } 1191 }
1199 SkASSERT(fStencilClearFBO->isValid()); 1192
1200 this->bindFBO(kDraw_FBOBinding, fStencilClearFBO); 1193 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fStencilClearFBOID));
1194 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
1195 fStats.incRenderTargetBinds();
1201 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1196 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1202 GR_GL_STENCIL_ATTACHMENT, 1197 GR_GL_STENCIL_ATTACHMENT,
1203 GR_GL_RENDERBUFFER, sbDesc.fRend erbufferID)); 1198 GR_GL_RENDERBUFFER, sbDesc.fRend erbufferID));
1204 if (sFmt.fPacked) { 1199 if (sFmt.fPacked) {
1205 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1200 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1206 GR_GL_DEPTH_ATTACHMENT, 1201 GR_GL_DEPTH_ATTACHMENT,
1207 GR_GL_RENDERBUFFER, sbDesc.f RenderbufferID)); 1202 GR_GL_RENDERBUFFER, sbDesc.f RenderbufferID));
1208 } 1203 }
1209 1204
1210 GL_CALL(ClearStencil(0)); 1205 GL_CALL(ClearStencil(0));
(...skipping 17 matching lines...) Expand all
1228 // Set this to 0 since we handed the valid ID off to the failed sten cil buffer resource. 1223 // Set this to 0 since we handed the valid ID off to the failed sten cil buffer resource.
1229 sbDesc.fRenderbufferID = 0; 1224 sbDesc.fRenderbufferID = 0;
1230 } 1225 }
1231 } 1226 }
1232 GL_CALL(DeleteRenderbuffers(1, &sbDesc.fRenderbufferID)); 1227 GL_CALL(DeleteRenderbuffers(1, &sbDesc.fRenderbufferID));
1233 return false; 1228 return false;
1234 } 1229 }
1235 1230
1236 bool GrGLGpu::attachStencilBufferToRenderTarget(GrStencilBuffer* sb, GrRenderTar get* rt) { 1231 bool GrGLGpu::attachStencilBufferToRenderTarget(GrStencilBuffer* sb, GrRenderTar get* rt) {
1237 GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(rt); 1232 GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(rt);
1233
1234 GrGLuint fbo = glrt->renderFBOID();
1235
1238 if (NULL == sb) { 1236 if (NULL == sb) {
1239 if (rt->renderTargetPriv().getStencilBuffer()) { 1237 if (rt->renderTargetPriv().getStencilBuffer()) {
1240 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1238 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1241 GR_GL_STENCIL_ATTACHMENT, 1239 GR_GL_STENCIL_ATTACHMENT,
1242 GR_GL_RENDERBUFFER, 0)); 1240 GR_GL_RENDERBUFFER, 0));
1243 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1241 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1244 GR_GL_DEPTH_ATTACHMENT, 1242 GR_GL_DEPTH_ATTACHMENT,
1245 GR_GL_RENDERBUFFER, 0)); 1243 GR_GL_RENDERBUFFER, 0));
1246 #ifdef SK_DEBUG 1244 #ifdef SK_DEBUG
1247 GrGLenum status; 1245 GrGLenum status;
1248 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); 1246 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
1249 SkASSERT(GR_GL_FRAMEBUFFER_COMPLETE == status); 1247 SkASSERT(GR_GL_FRAMEBUFFER_COMPLETE == status);
1250 #endif 1248 #endif
1251 } 1249 }
1252 return true; 1250 return true;
1253 } else { 1251 } else {
1254 GrGLStencilBuffer* glsb = static_cast<GrGLStencilBuffer*>(sb); 1252 GrGLStencilBuffer* glsb = static_cast<GrGLStencilBuffer*>(sb);
1255 GrGLuint rb = glsb->renderbufferID(); 1253 GrGLuint rb = glsb->renderbufferID();
1256 1254
1257 this->bindFBO(kDraw_FBOBinding, glrt->renderFBO()); 1255 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
1258 1256 fStats.incRenderTargetBinds();
1257 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fbo));
1259 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1258 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1260 GR_GL_STENCIL_ATTACHMENT, 1259 GR_GL_STENCIL_ATTACHMENT,
1261 GR_GL_RENDERBUFFER, rb)); 1260 GR_GL_RENDERBUFFER, rb));
1262 if (glsb->format().fPacked) { 1261 if (glsb->format().fPacked) {
1263 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1262 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1264 GR_GL_DEPTH_ATTACHMENT, 1263 GR_GL_DEPTH_ATTACHMENT,
1265 GR_GL_RENDERBUFFER, rb)); 1264 GR_GL_RENDERBUFFER, rb));
1266 } else { 1265 } else {
1267 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1266 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1268 GR_GL_DEPTH_ATTACHMENT, 1267 GR_GL_DEPTH_ATTACHMENT,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 1416
1418 fCurrentProgram->setData(*args.fPrimitiveProcessor, pipeline, *args.fBatchTr acker); 1417 fCurrentProgram->setData(*args.fPrimitiveProcessor, pipeline, *args.fBatchTr acker);
1419 1418
1420 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa rget()); 1419 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa rget());
1421 this->flushStencil(pipeline.getStencil()); 1420 this->flushStencil(pipeline.getStencil());
1422 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or igin()); 1421 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or igin());
1423 this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), isLineDraw); 1422 this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), isLineDraw);
1424 1423
1425 // This must come after textures are flushed because a texture may need 1424 // This must come after textures are flushed because a texture may need
1426 // to be msaa-resolved (which will modify bound FBO state). 1425 // to be msaa-resolved (which will modify bound FBO state).
1427 this->prepareToDrawToRenderTarget(glRT, NULL); 1426 this->flushRenderTarget(glRT, NULL);
1428 1427
1429 return true; 1428 return true;
1430 } 1429 }
1431 1430
1432 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, 1431 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc,
1433 const GrDrawTarget::DrawInfo& info, 1432 const GrDrawTarget::DrawInfo& info,
1434 size_t* indexOffsetInBytes) { 1433 size_t* indexOffsetInBytes) {
1435 GrGLVertexBuffer* vbuf; 1434 GrGLVertexBuffer* vbuf;
1436 vbuf = (GrGLVertexBuffer*) info.vertexBuffer(); 1435 vbuf = (GrGLVertexBuffer*) info.vertexBuffer();
1437 1436
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 // flushScissor expects rect to be clipped to the target. 1513 // flushScissor expects rect to be clipped to the target.
1515 clippedRect = *rect; 1514 clippedRect = *rect;
1516 SkIRect rtRect = SkIRect::MakeWH(target->width(), target->height()); 1515 SkIRect rtRect = SkIRect::MakeWH(target->width(), target->height());
1517 if (clippedRect.intersect(rtRect)) { 1516 if (clippedRect.intersect(rtRect)) {
1518 rect = &clippedRect; 1517 rect = &clippedRect;
1519 } else { 1518 } else {
1520 return; 1519 return;
1521 } 1520 }
1522 } 1521 }
1523 1522
1524 this->prepareToDrawToRenderTarget(glRT, rect); 1523 this->flushRenderTarget(glRT, rect);
1525 GrScissorState scissorState; 1524 GrScissorState scissorState;
1526 if (rect) { 1525 if (rect) {
1527 scissorState.set(*rect); 1526 scissorState.set(*rect);
1528 } 1527 }
1529 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin()); 1528 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin());
1530 1529
1531 GrGLfloat r, g, b, a; 1530 GrGLfloat r, g, b, a;
1532 static const GrGLfloat scale255 = 1.f / 255.f; 1531 static const GrGLfloat scale255 = 1.f / 255.f;
1533 a = GrColorUnpackA(color) * scale255; 1532 a = GrColorUnpackA(color) * scale255;
1534 GrGLfloat scaleRGB = scale255; 1533 GrGLfloat scaleRGB = scale255;
1535 r = GrColorUnpackR(color) * scaleRGB; 1534 r = GrColorUnpackR(color) * scaleRGB;
1536 g = GrColorUnpackG(color) * scaleRGB; 1535 g = GrColorUnpackG(color) * scaleRGB;
1537 b = GrColorUnpackB(color) * scaleRGB; 1536 b = GrColorUnpackB(color) * scaleRGB;
1538 1537
1539 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); 1538 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE));
1540 fHWWriteToColor = kYes_TriState; 1539 fHWWriteToColor = kYes_TriState;
1541 GL_CALL(ClearColor(r, g, b, a)); 1540 GL_CALL(ClearColor(r, g, b, a));
1542 GL_CALL(Clear(GR_GL_COLOR_BUFFER_BIT)); 1541 GL_CALL(Clear(GR_GL_COLOR_BUFFER_BIT));
1543 } 1542 }
1544 1543
1545 void GrGLGpu::discard(GrRenderTarget* renderTarget) { 1544 void GrGLGpu::discard(GrRenderTarget* renderTarget) {
1546 SkASSERT(renderTarget); 1545 SkASSERT(renderTarget);
1547 if (!this->caps()->discardRenderTargetSupport()) { 1546 if (!this->caps()->discardRenderTargetSupport()) {
1548 return; 1547 return;
1549 } 1548 }
1550 1549
1551 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget); 1550 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget);
1552 this->bindFBO(kDraw_FBOBinding, glRT->renderFBO()); 1551 if (renderTarget->getUniqueID() != fHWBoundRenderTargetUniqueID) {
1552 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
1553 fStats.incRenderTargetBinds();
1554 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID()));
1555 }
1553 switch (this->glCaps().invalidateFBType()) { 1556 switch (this->glCaps().invalidateFBType()) {
1554 case GrGLCaps::kNone_InvalidateFBType: 1557 case GrGLCaps::kNone_InvalidateFBType:
1555 SkFAIL("Should never get here."); 1558 SkFAIL("Should never get here.");
1556 break; 1559 break;
1557 case GrGLCaps::kInvalidate_InvalidateFBType: 1560 case GrGLCaps::kInvalidate_InvalidateFBType:
1558 if (glRT->renderFBO()->isDefaultFramebuffer()) { 1561 if (0 == glRT->renderFBOID()) {
1559 // When rendering to the default framebuffer the legal values f or attachments 1562 // When rendering to the default framebuffer the legal values f or attachments
1560 // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the vari ous FBO attachment 1563 // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the vari ous FBO attachment
1561 // types. 1564 // types.
1562 static const GrGLenum attachments[] = { GR_GL_COLOR }; 1565 static const GrGLenum attachments[] = { GR_GL_COLOR };
1563 GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT( attachments), 1566 GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT( attachments),
1564 attachments)); 1567 attachments));
1565 } else { 1568 } else {
1566 static const GrGLenum attachments[] = { GR_GL_COLOR_ATTACHMENT0 }; 1569 static const GrGLenum attachments[] = { GR_GL_COLOR_ATTACHMENT0 };
1567 GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT( attachments), 1570 GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT( attachments),
1568 attachments)); 1571 attachments));
1569 } 1572 }
1570 break; 1573 break;
1571 case GrGLCaps::kDiscard_InvalidateFBType: { 1574 case GrGLCaps::kDiscard_InvalidateFBType: {
1572 if (glRT->renderFBO()->isDefaultFramebuffer()) { 1575 if (0 == glRT->renderFBOID()) {
1573 // When rendering to the default framebuffer the legal values f or attachments 1576 // When rendering to the default framebuffer the legal values f or attachments
1574 // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the vari ous FBO attachment 1577 // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the vari ous FBO attachment
1575 // types. See glDiscardFramebuffer() spec. 1578 // types. See glDiscardFramebuffer() spec.
1576 static const GrGLenum attachments[] = { GR_GL_COLOR }; 1579 static const GrGLenum attachments[] = { GR_GL_COLOR };
1577 GL_CALL(DiscardFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(att achments), 1580 GL_CALL(DiscardFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(att achments),
1578 attachments)); 1581 attachments));
1579 } else { 1582 } else {
1580 static const GrGLenum attachments[] = { GR_GL_COLOR_ATTACHMENT0 }; 1583 static const GrGLenum attachments[] = { GR_GL_COLOR_ATTACHMENT0 };
1581 GL_CALL(DiscardFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(att achments), 1584 GL_CALL(DiscardFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(att achments),
1582 attachments)); 1585 attachments));
1583 } 1586 }
1584 break; 1587 break;
1585 } 1588 }
1586 } 1589 }
1587 renderTarget->flagAsResolved(); 1590 renderTarget->flagAsResolved();
1588 } 1591 }
1589 1592
1590 1593
1591 void GrGLGpu::clearStencil(GrRenderTarget* target) { 1594 void GrGLGpu::clearStencil(GrRenderTarget* target) {
1592 if (NULL == target) { 1595 if (NULL == target) {
1593 return; 1596 return;
1594 } 1597 }
1595 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); 1598 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
1596 this->prepareToDrawToRenderTarget(glRT, &SkIRect::EmptyIRect()); 1599 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect());
1597 1600
1598 this->disableScissor(); 1601 this->disableScissor();
1599 1602
1600 GL_CALL(StencilMask(0xffffffff)); 1603 GL_CALL(StencilMask(0xffffffff));
1601 GL_CALL(ClearStencil(0)); 1604 GL_CALL(ClearStencil(0));
1602 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); 1605 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT));
1603 fHWStencilSettings.invalidate(); 1606 fHWStencilSettings.invalidate();
1604 } 1607 }
1605 1608
1606 void GrGLGpu::onClearStencilClip(GrRenderTarget* target, const SkIRect& rect, bo ol insideClip) { 1609 void GrGLGpu::onClearStencilClip(GrRenderTarget* target, const SkIRect& rect, bo ol insideClip) {
(...skipping 15 matching lines...) Expand all
1622 // zero the client's clip bits. So we just clear the whole thing. 1625 // zero the client's clip bits. So we just clear the whole thing.
1623 static const GrGLint clipStencilMask = ~0; 1626 static const GrGLint clipStencilMask = ~0;
1624 #endif 1627 #endif
1625 GrGLint value; 1628 GrGLint value;
1626 if (insideClip) { 1629 if (insideClip) {
1627 value = (1 << (stencilBitCount - 1)); 1630 value = (1 << (stencilBitCount - 1));
1628 } else { 1631 } else {
1629 value = 0; 1632 value = 0;
1630 } 1633 }
1631 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); 1634 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
1632 this->prepareToDrawToRenderTarget(glRT, &SkIRect::EmptyIRect()); 1635 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect());
1633 1636
1634 GrScissorState scissorState; 1637 GrScissorState scissorState;
1635 scissorState.set(rect); 1638 scissorState.set(rect);
1636 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin()); 1639 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin());
1637 1640
1638 GL_CALL(StencilMask((uint32_t) clipStencilMask)); 1641 GL_CALL(StencilMask((uint32_t) clipStencilMask));
1639 GL_CALL(ClearStencil(value)); 1642 GL_CALL(ClearStencil(value));
1640 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); 1643 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT));
1641 fHWStencilSettings.invalidate(); 1644 fHWStencilSettings.invalidate();
1642 } 1645 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1692 size_t bpp = GrBytesPerPixel(config); 1695 size_t bpp = GrBytesPerPixel(config);
1693 if (!adjust_pixel_ops_params(target->width(), target->height(), bpp, 1696 if (!adjust_pixel_ops_params(target->width(), target->height(), bpp,
1694 &left, &top, &width, &height, 1697 &left, &top, &width, &height,
1695 const_cast<const void**>(&buffer), 1698 const_cast<const void**>(&buffer),
1696 &rowBytes)) { 1699 &rowBytes)) {
1697 return false; 1700 return false;
1698 } 1701 }
1699 1702
1700 // resolve the render target if necessary 1703 // resolve the render target if necessary
1701 GrGLRenderTarget* tgt = static_cast<GrGLRenderTarget*>(target); 1704 GrGLRenderTarget* tgt = static_cast<GrGLRenderTarget*>(target);
1702 if (tgt->getResolveType() == GrGLRenderTarget::kCantResolve_ResolveType) { 1705 switch (tgt->getResolveType()) {
1703 return false; 1706 case GrGLRenderTarget::kCantResolve_ResolveType:
1707 return false;
1708 case GrGLRenderTarget::kAutoResolves_ResolveType:
1709 this->flushRenderTarget(static_cast<GrGLRenderTarget*>(target), &SkI Rect::EmptyIRect());
1710 break;
1711 case GrGLRenderTarget::kCanResolve_ResolveType:
1712 this->onResolveRenderTarget(tgt);
1713 // we don't track the state of the READ FBO ID.
1714 fStats.incRenderTargetBinds();
1715 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER,
1716 tgt->textureFBOID()));
1717 break;
1718 default:
1719 SkFAIL("Unknown resolve type");
1704 } 1720 }
1705 if (tgt->getResolveType() == GrGLRenderTarget::kCanResolve_ResolveType) {
1706 this->onResolveRenderTarget(tgt);
1707 }
1708 this->bindFBO(kRead_FBOBinding, tgt->textureFBO());
1709 1721
1710 const GrGLIRect& glvp = tgt->getViewport(); 1722 const GrGLIRect& glvp = tgt->getViewport();
1711 1723
1712 // the read rect is viewport-relative 1724 // the read rect is viewport-relative
1713 GrGLIRect readRect; 1725 GrGLIRect readRect;
1714 readRect.setRelativeTo(glvp, left, top, width, height, target->origin()); 1726 readRect.setRelativeTo(glvp, left, top, width, height, target->origin());
1715 1727
1716 size_t tightRowBytes = bpp * width; 1728 size_t tightRowBytes = bpp * width;
1717 if (0 == rowBytes) { 1729 if (0 == rowBytes) {
1718 rowBytes = tightRowBytes; 1730 rowBytes = tightRowBytes;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 if (!flipY) { 1796 if (!flipY) {
1785 dst += rowBytes; 1797 dst += rowBytes;
1786 } else { 1798 } else {
1787 dst -= rowBytes; 1799 dst -= rowBytes;
1788 } 1800 }
1789 } 1801 }
1790 } 1802 }
1791 return true; 1803 return true;
1792 } 1804 }
1793 1805
1794 GrGLenum GrGLGpu::bindFBO(FBOBinding binding, const GrGLFBO* fbo) { 1806 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound) {
1795 SkASSERT(fbo);
1796 SkASSERT(fbo->isValid());
1797 GrGLenum target;
1798 HWFBOBinding* hwFBOState;
1799 if (!this->glCaps().usesMSAARenderBuffers()) {
1800 target = GR_GL_FRAMEBUFFER;
1801 hwFBOState = &fHWFBOBinding[0];
1802 } else {
1803 target = kDraw_FBOBinding == binding ? GR_GL_DRAW_FRAMEBUFFER : GR_GL_RE AD_FRAMEBUFFER;
1804 hwFBOState = &fHWFBOBinding[binding];
1805 }
1806 1807
1807 if (hwFBOState->fFBO != fbo) { 1808 SkASSERT(target);
1809
1810 uint32_t rtID = target->getUniqueID();
1811 if (fHWBoundRenderTargetUniqueID != rtID) {
1808 fStats.incRenderTargetBinds(); 1812 fStats.incRenderTargetBinds();
1809 GL_CALL(BindFramebuffer(target, fbo->fboID())); 1813 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID()));
1810 hwFBOState->fFBO.reset(SkRef(fbo));
1811 }
1812 return target;
1813 }
1814
1815 void GrGLGpu::setViewport(const GrGLIRect& viewport) {
1816 if (viewport != fHWViewport) {
1817 viewport.pushToGLViewport(this->glInterface());
1818 fHWViewport = viewport;
1819 }
1820 }
1821
1822 void GrGLGpu::prepareToDrawToRenderTarget(GrGLRenderTarget* target, const SkIRec t* bound) {
1823 SkASSERT(target);
1824 this->bindFBO(kDraw_FBOBinding, target->renderFBO());
1825
1826 #ifdef SK_DEBUG 1814 #ifdef SK_DEBUG
1827 // don't do this check in Chromium -- this is causing 1815 // don't do this check in Chromium -- this is causing
1828 // lots of repeated command buffer flushes when the compositor is 1816 // lots of repeated command buffer flushes when the compositor is
1829 // rendering with Ganesh, which is really slow; even too slow for 1817 // rendering with Ganesh, which is really slow; even too slow for
1830 // Debug mode. 1818 // Debug mode.
1831 if (!this->glContext().isChromium()) { 1819 if (!this->glContext().isChromium()) {
1832 GrGLenum status; 1820 GrGLenum status;
1833 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); 1821 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
1834 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { 1822 if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
1835 SkDebugf("GrGLGpu::flushRenderTarget glCheckFramebufferStatus %x\n", status); 1823 SkDebugf("GrGLGpu::flushRenderTarget glCheckFramebufferStatus %x \n", status);
1824 }
1825 }
1826 #endif
1827 fHWBoundRenderTargetUniqueID = rtID;
1828 const GrGLIRect& vp = target->getViewport();
1829 if (fHWViewport != vp) {
1830 vp.pushToGLViewport(this->glInterface());
1831 fHWViewport = vp;
1836 } 1832 }
1837 } 1833 }
1838 #endif
1839 this->setViewport(target->getViewport());
1840 if (NULL == bound || !bound->isEmpty()) { 1834 if (NULL == bound || !bound->isEmpty()) {
1841 target->flagAsNeedingResolve(bound); 1835 target->flagAsNeedingResolve(bound);
1842 } 1836 }
1843 1837
1844 GrTexture *texture = target->asTexture(); 1838 GrTexture *texture = target->asTexture();
1845 if (texture) { 1839 if (texture) {
1846 texture->texturePriv().dirtyMipMaps(true); 1840 texture->texturePriv().dirtyMipMaps(true);
1847 } 1841 }
1848 } 1842 }
1849 1843
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 1912
1919 void GrGLGpu::onStencilPath(const GrPath* path, const StencilPathState& state) { 1913 void GrGLGpu::onStencilPath(const GrPath* path, const StencilPathState& state) {
1920 this->flushColorWrite(false); 1914 this->flushColorWrite(false);
1921 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); 1915 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace);
1922 1916
1923 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(state.fRenderTarget); 1917 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(state.fRenderTarget);
1924 SkISize size = SkISize::Make(rt->width(), rt->height()); 1918 SkISize size = SkISize::Make(rt->width(), rt->height());
1925 this->glPathRendering()->setProjectionMatrix(*state.fViewMatrix, size, rt->o rigin()); 1919 this->glPathRendering()->setProjectionMatrix(*state.fViewMatrix, size, rt->o rigin());
1926 this->flushScissor(*state.fScissor, rt->getViewport(), rt->origin()); 1920 this->flushScissor(*state.fScissor, rt->getViewport(), rt->origin());
1927 this->flushHWAAState(rt, state.fUseHWAA, false); 1921 this->flushHWAAState(rt, state.fUseHWAA, false);
1928 this->prepareToDrawToRenderTarget(rt, NULL); 1922 this->flushRenderTarget(rt, NULL);
1929 1923
1930 fPathRendering->stencilPath(path, *state.fStencil); 1924 fPathRendering->stencilPath(path, *state.fStencil);
1931 } 1925 }
1932 1926
1933 void GrGLGpu::onDrawPath(const DrawArgs& args, const GrPath* path, 1927 void GrGLGpu::onDrawPath(const DrawArgs& args, const GrPath* path,
1934 const GrStencilSettings& stencil) { 1928 const GrStencilSettings& stencil) {
1935 if (!this->flushGLState(args, false)) { 1929 if (!this->flushGLState(args, false)) {
1936 return; 1930 return;
1937 } 1931 }
1938 fPathRendering->drawPath(path, stencil); 1932 fPathRendering->drawPath(path, stencil);
(...skipping 12 matching lines...) Expand all
1951 } 1945 }
1952 fPathRendering->drawPaths(pathRange, indices, indexType, transformValues, 1946 fPathRendering->drawPaths(pathRange, indices, indexType, transformValues,
1953 transformType, count, stencil); 1947 transformType, count, stencil);
1954 } 1948 }
1955 1949
1956 void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) { 1950 void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) {
1957 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); 1951 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target);
1958 if (rt->needsResolve()) { 1952 if (rt->needsResolve()) {
1959 // Some extensions automatically resolves the texture when it is read. 1953 // Some extensions automatically resolves the texture when it is read.
1960 if (this->glCaps().usesMSAARenderBuffers()) { 1954 if (this->glCaps().usesMSAARenderBuffers()) {
1961 SkASSERT(rt->textureFBO() != rt->renderFBO()); 1955 SkASSERT(rt->textureFBOID() != rt->renderFBOID());
1962 this->bindFBO(kRead_FBOBinding, rt->renderFBO()); 1956 fStats.incRenderTargetBinds();
1963 this->bindFBO(kDraw_FBOBinding, rt->textureFBO()); 1957 fStats.incRenderTargetBinds();
1958 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID()));
1959 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID())) ;
1960 // make sure we go through flushRenderTarget() since we've modified
1961 // the bound DRAW FBO ID.
1962 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
1964 const GrGLIRect& vp = rt->getViewport(); 1963 const GrGLIRect& vp = rt->getViewport();
1965 const SkIRect dirtyRect = rt->getResolveRect(); 1964 const SkIRect dirtyRect = rt->getResolveRect();
1966 1965
1967 if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) { 1966 if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) {
1968 // Apple's extension uses the scissor as the blit bounds. 1967 // Apple's extension uses the scissor as the blit bounds.
1969 GrScissorState scissorState; 1968 GrScissorState scissorState;
1970 scissorState.set(dirtyRect); 1969 scissorState.set(dirtyRect);
1971 this->flushScissor(scissorState, vp, rt->origin()); 1970 this->flushScissor(scissorState, vp, rt->origin());
1972 GL_CALL(ResolveMultisampleFramebuffer()); 1971 GL_CALL(ResolveMultisampleFramebuffer());
1973 } else { 1972 } else {
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 // Table 3.9 of the ES2 spec indicates the supported formats with CopyTexSub Image 2515 // Table 3.9 of the ES2 spec indicates the supported formats with CopyTexSub Image
2517 // and BGRA isn't in the spec. There doesn't appear to be any extension that adds it. Perhaps 2516 // and BGRA isn't in the spec. There doesn't appear to be any extension that adds it. Perhaps
2518 // many drivers would allow it to work, but ANGLE does not. 2517 // many drivers would allow it to work, but ANGLE does not.
2519 if (kGLES_GrGLStandard == gpu->glStandard() && gpu->glCaps().bgraIsInternalF ormat() && 2518 if (kGLES_GrGLStandard == gpu->glStandard() && gpu->glCaps().bgraIsInternalF ormat() &&
2520 (kBGRA_8888_GrPixelConfig == dst->config() || kBGRA_8888_GrPixelConfig = = src->config())) { 2519 (kBGRA_8888_GrPixelConfig == dst->config() || kBGRA_8888_GrPixelConfig = = src->config())) {
2521 return false; 2520 return false;
2522 } 2521 }
2523 const GrGLRenderTarget* dstRT = static_cast<const GrGLRenderTarget*>(dst->as RenderTarget()); 2522 const GrGLRenderTarget* dstRT = static_cast<const GrGLRenderTarget*>(dst->as RenderTarget());
2524 // If dst is multisampled (and uses an extension where there is a separate M SAA renderbuffer) 2523 // If dst is multisampled (and uses an extension where there is a separate M SAA renderbuffer)
2525 // then we don't want to copy to the texture but to the MSAA buffer. 2524 // then we don't want to copy to the texture but to the MSAA buffer.
2526 if (dstRT && dstRT->renderFBO() != dstRT->textureFBO()) { 2525 if (dstRT && dstRT->renderFBOID() != dstRT->textureFBOID()) {
2527 return false; 2526 return false;
2528 } 2527 }
2529 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as RenderTarget()); 2528 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as RenderTarget());
2530 // If the src is multisampled (and uses an extension where there is a separa te MSAA 2529 // If the src is multisampled (and uses an extension where there is a separa te MSAA
2531 // renderbuffer) then it is an invalid operation to call CopyTexSubImage 2530 // renderbuffer) then it is an invalid operation to call CopyTexSubImage
2532 if (srcRT && srcRT->renderFBO() != srcRT->textureFBO()) { 2531 if (srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) {
2533 return false; 2532 return false;
2534 } 2533 }
2535 if (gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt > 0) && 2534 if (gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt > 0) &&
2536 dst->asTexture() && 2535 dst->asTexture() &&
2537 dst->origin() == src->origin() && 2536 dst->origin() == src->origin() &&
2538 !GrPixelConfigIsCompressed(src->config())) { 2537 !GrPixelConfigIsCompressed(src->config())) {
2539 return true; 2538 return true;
2540 } else { 2539 } else {
2541 return false; 2540 return false;
2542 } 2541 }
2543 } 2542 }
2544 2543
2545 } 2544 }
2546 2545
2547 // If a temporary FBO was created, its non-zero ID is returned. The viewport tha t the copy rect is 2546 // If a temporary FBO was created, its non-zero ID is returned. The viewport tha t the copy rect is
2548 // relative to is output. 2547 // relative to is output.
2549 GrGLGpu::FBOBinding GrGLGpu::bindSurfaceAsFBOForCopy(GrSurface* surface, FBOBind ing binding, 2548 GrGLuint GrGLGpu::bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLI Rect* viewport,
2550 GrGLIRect* viewport) { 2549 TempFBOTarget tempFBOTarget) {
2551 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(surface->asRenderTarge t()); 2550 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(surface->asRenderTarge t());
2552 if (NULL == rt) { 2551 if (NULL == rt) {
2553 SkASSERT(surface->asTexture()); 2552 SkASSERT(surface->asTexture());
2554 GrGLuint texID = static_cast<GrGLTexture*>(surface->asTexture())->textur eID(); 2553 GrGLuint texID = static_cast<GrGLTexture*>(surface->asTexture())->textur eID();
2555 GrGLFBO* tempFBO; 2554 GrGLuint* tempFBOID;
2555 tempFBOID = kSrc_TempFBOTarget == tempFBOTarget ? &fTempSrcFBOID : &fTem pDstFBOID;
2556 2556
2557 if (kRead_FBOBinding == binding) { 2557 if (0 == *tempFBOID) {
2558 if (!fTempSrcFBO) { 2558 GR_GL_CALL(this->glInterface(), GenFramebuffers(1, tempFBOID));
2559 fTempSrcFBO.reset(SkNEW_ARGS(GrGLFBO, (this->glInterface())));
2560 SkASSERT(fTempSrcFBO->isValid());
2561 }
2562 tempFBO = fTempSrcFBO;
2563 } else {
2564 SkASSERT(kDraw_FBOBinding == binding);
2565 if (!fTempDstFBO) {
2566 fTempDstFBO.reset(SkNEW_ARGS(GrGLFBO, (this->glInterface())));
2567 SkASSERT(fTempDstFBO->isValid());
2568 }
2569 tempFBO = fTempDstFBO;
2570 } 2559 }
2571 2560
2572 GrGLenum target = this->bindFBO(binding, tempFBO); 2561 fStats.incRenderTargetBinds();
2573 GR_GL_CALL(this->glInterface(), FramebufferTexture2D(target, 2562 GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, *tempFBOID));
2563 GR_GL_CALL(this->glInterface(), FramebufferTexture2D(fboTarget,
2574 GR_GL_COLOR_ATTACHM ENT0, 2564 GR_GL_COLOR_ATTACHM ENT0,
2575 GR_GL_TEXTURE_2D, 2565 GR_GL_TEXTURE_2D,
2576 texID, 2566 texID,
2577 0)); 2567 0));
2578 viewport->fLeft = 0; 2568 viewport->fLeft = 0;
2579 viewport->fBottom = 0; 2569 viewport->fBottom = 0;
2580 viewport->fWidth = surface->width(); 2570 viewport->fWidth = surface->width();
2581 viewport->fHeight = surface->height(); 2571 viewport->fHeight = surface->height();
2582 return binding; 2572 return *tempFBOID;
2583 } else { 2573 } else {
2584 this->bindFBO(binding, rt->renderFBO()); 2574 GrGLuint tempFBOID = 0;
2575 fStats.incRenderTargetBinds();
2576 GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, rt->renderFBO ID()));
2585 *viewport = rt->getViewport(); 2577 *viewport = rt->getViewport();
2586 return kInvalidFBOBinding; 2578 return tempFBOID;
2587 } 2579 }
2588 } 2580 }
2589 2581
2590 void GrGLGpu::unbindSurfaceAsFBOForCopy(FBOBinding binding) { 2582 void GrGLGpu::unbindTextureFromFBO(GrGLenum fboTarget) {
2591 if (kInvalidFBOBinding == binding) { 2583 GR_GL_CALL(this->glInterface(), FramebufferTexture2D(fboTarget,
2592 return;
2593 }
2594 GrGLFBO* tempFBO = kDraw_FBOBinding == binding ? fTempSrcFBO : fTempDstFBO;
2595 GrGLenum target = this->bindFBO(binding, tempFBO);
2596 GR_GL_CALL(this->glInterface(), FramebufferTexture2D(target,
2597 GR_GL_COLOR_ATTACHMENT0 , 2584 GR_GL_COLOR_ATTACHMENT0 ,
2598 GR_GL_TEXTURE_2D, 2585 GR_GL_TEXTURE_2D,
2599 0, 2586 0,
2600 0)); 2587 0));
2601 } 2588 }
2602 2589
2603 bool GrGLGpu::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) { 2590 bool GrGLGpu::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) {
2604 // In here we look for opportunities to use CopyTexSubImage, or fbo blit. If neither are 2591 // In here we look for opportunities to use CopyTexSubImage, or fbo blit. If neither are
2605 // possible and we return false to fallback to creating a render target dst for render-to- 2592 // possible and we return false to fallback to creating a render target dst for render-to-
2606 // texture. This code prefers CopyTexSubImage to fbo blit and avoids trigger ing temporary fbo 2593 // texture. This code prefers CopyTexSubImage to fbo blit and avoids trigger ing temporary fbo
(...skipping 10 matching lines...) Expand all
2617 desc->fConfig = kBGRA_8888_GrPixelConfig; 2604 desc->fConfig = kBGRA_8888_GrPixelConfig;
2618 return true; 2605 return true;
2619 } 2606 }
2620 return false; 2607 return false;
2621 } else if (NULL == src->asRenderTarget()) { 2608 } else if (NULL == src->asRenderTarget()) {
2622 // CopyTexSubImage2D or fbo blit would require creating a temp fbo for t he src. 2609 // CopyTexSubImage2D or fbo blit would require creating a temp fbo for t he src.
2623 return false; 2610 return false;
2624 } 2611 }
2625 2612
2626 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as RenderTarget()); 2613 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as RenderTarget());
2627 if (srcRT && srcRT->renderFBO() != srcRT->textureFBO()) { 2614 if (srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) {
2628 // It's illegal to call CopyTexSubImage2D on a MSAA renderbuffer. Set up for FBO blit or 2615 // It's illegal to call CopyTexSubImage2D on a MSAA renderbuffer. Set up for FBO blit or
2629 // fail. 2616 // fail.
2630 if (this->caps()->isConfigRenderable(src->config(), false)) { 2617 if (this->caps()->isConfigRenderable(src->config(), false)) {
2631 desc->fOrigin = kDefault_GrSurfaceOrigin; 2618 desc->fOrigin = kDefault_GrSurfaceOrigin;
2632 desc->fFlags = kRenderTarget_GrSurfaceFlag; 2619 desc->fFlags = kRenderTarget_GrSurfaceFlag;
2633 desc->fConfig = src->config(); 2620 desc->fConfig = src->config();
2634 return true; 2621 return true;
2635 } 2622 }
2636 return false; 2623 return false;
2637 } 2624 }
2638 2625
2639 // We'll do a CopyTexSubImage. Make the dst a plain old texture. 2626 // We'll do a CopyTexSubImage. Make the dst a plain old texture.
2640 desc->fConfig = src->config(); 2627 desc->fConfig = src->config();
2641 desc->fOrigin = src->origin(); 2628 desc->fOrigin = src->origin();
2642 desc->fFlags = kNone_GrSurfaceFlags; 2629 desc->fFlags = kNone_GrSurfaceFlags;
2643 return true; 2630 return true;
2644 } 2631 }
2645 2632
2646 bool GrGLGpu::copySurface(GrSurface* dst, 2633 bool GrGLGpu::copySurface(GrSurface* dst,
2647 GrSurface* src, 2634 GrSurface* src,
2648 const SkIRect& srcRect, 2635 const SkIRect& srcRect,
2649 const SkIPoint& dstPoint) { 2636 const SkIPoint& dstPoint) {
2650 bool copied = false; 2637 bool copied = false;
2651 if (can_copy_texsubimage(dst, src, this)) { 2638 if (can_copy_texsubimage(dst, src, this)) {
2639 GrGLuint srcFBO;
2652 GrGLIRect srcVP; 2640 GrGLIRect srcVP;
2653 FBOBinding srcFBOBinding = this->bindSurfaceAsFBOForCopy(src, kRead_FBOB inding, &srcVP); 2641 srcFBO = this->bindSurfaceAsFBO(src, GR_GL_FRAMEBUFFER, &srcVP, kSrc_Tem pFBOTarget);
2654 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture()); 2642 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture());
2655 SkASSERT(dstTex); 2643 SkASSERT(dstTex);
2644 // We modified the bound FBO
2645 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
2656 GrGLIRect srcGLRect; 2646 GrGLIRect srcGLRect;
2657 srcGLRect.setRelativeTo(srcVP, 2647 srcGLRect.setRelativeTo(srcVP,
2658 srcRect.fLeft, 2648 srcRect.fLeft,
2659 srcRect.fTop, 2649 srcRect.fTop,
2660 srcRect.width(), 2650 srcRect.width(),
2661 srcRect.height(), 2651 srcRect.height(),
2662 src->origin()); 2652 src->origin());
2663 2653
2664 this->setScratchTextureUnit(); 2654 this->setScratchTextureUnit();
2665 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, dstTex->textureID())); 2655 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, dstTex->textureID()));
2666 GrGLint dstY; 2656 GrGLint dstY;
2667 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { 2657 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) {
2668 dstY = dst->height() - (dstPoint.fY + srcGLRect.fHeight); 2658 dstY = dst->height() - (dstPoint.fY + srcGLRect.fHeight);
2669 } else { 2659 } else {
2670 dstY = dstPoint.fY; 2660 dstY = dstPoint.fY;
2671 } 2661 }
2672 GL_CALL(CopyTexSubImage2D(GR_GL_TEXTURE_2D, 0, 2662 GL_CALL(CopyTexSubImage2D(GR_GL_TEXTURE_2D, 0,
2673 dstPoint.fX, dstY, 2663 dstPoint.fX, dstY,
2674 srcGLRect.fLeft, srcGLRect.fBottom, 2664 srcGLRect.fLeft, srcGLRect.fBottom,
2675 srcGLRect.fWidth, srcGLRect.fHeight)); 2665 srcGLRect.fWidth, srcGLRect.fHeight));
2676 copied = true; 2666 copied = true;
2677 this->unbindSurfaceAsFBOForCopy(srcFBOBinding); 2667 if (srcFBO) {
2668 this->unbindTextureFromFBO(GR_GL_FRAMEBUFFER);
2669 }
2678 } else if (can_blit_framebuffer(dst, src, this)) { 2670 } else if (can_blit_framebuffer(dst, src, this)) {
2679 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, 2671 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY,
2680 srcRect.width(), srcRect.height()); 2672 srcRect.width(), srcRect.height());
2681 bool selfOverlap = false; 2673 bool selfOverlap = false;
2682 if (dst == src) { 2674 if (dst == src) {
2683 selfOverlap = SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect); 2675 selfOverlap = SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect);
2684 } 2676 }
2685 2677
2686 if (!selfOverlap) { 2678 if (!selfOverlap) {
2679 GrGLuint dstFBO;
2680 GrGLuint srcFBO;
2687 GrGLIRect dstVP; 2681 GrGLIRect dstVP;
2688 GrGLIRect srcVP; 2682 GrGLIRect srcVP;
2689 FBOBinding dstFBOBinding = this->bindSurfaceAsFBOForCopy(dst, kDraw_ FBOBinding, &dstVP); 2683 dstFBO = this->bindSurfaceAsFBO(dst, GR_GL_DRAW_FRAMEBUFFER, &dstVP,
2690 FBOBinding srcFBOBinding = this->bindSurfaceAsFBOForCopy(src, kRead_ FBOBinding, &srcVP); 2684 kDst_TempFBOTarget);
2691 2685 srcFBO = this->bindSurfaceAsFBO(src, GR_GL_READ_FRAMEBUFFER, &srcVP,
2686 kSrc_TempFBOTarget);
2687 // We modified the bound FBO
2688 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
2692 GrGLIRect srcGLRect; 2689 GrGLIRect srcGLRect;
2693 GrGLIRect dstGLRect; 2690 GrGLIRect dstGLRect;
2694 srcGLRect.setRelativeTo(srcVP, 2691 srcGLRect.setRelativeTo(srcVP,
2695 srcRect.fLeft, 2692 srcRect.fLeft,
2696 srcRect.fTop, 2693 srcRect.fTop,
2697 srcRect.width(), 2694 srcRect.width(),
2698 srcRect.height(), 2695 srcRect.height(),
2699 src->origin()); 2696 src->origin());
2700 dstGLRect.setRelativeTo(dstVP, 2697 dstGLRect.setRelativeTo(dstVP,
2701 dstRect.fLeft, 2698 dstRect.fLeft,
(...skipping 17 matching lines...) Expand all
2719 } 2716 }
2720 GL_CALL(BlitFramebuffer(srcGLRect.fLeft, 2717 GL_CALL(BlitFramebuffer(srcGLRect.fLeft,
2721 srcY0, 2718 srcY0,
2722 srcGLRect.fLeft + srcGLRect.fWidth, 2719 srcGLRect.fLeft + srcGLRect.fWidth,
2723 srcY1, 2720 srcY1,
2724 dstGLRect.fLeft, 2721 dstGLRect.fLeft,
2725 dstGLRect.fBottom, 2722 dstGLRect.fBottom,
2726 dstGLRect.fLeft + dstGLRect.fWidth, 2723 dstGLRect.fLeft + dstGLRect.fWidth,
2727 dstGLRect.fBottom + dstGLRect.fHeight, 2724 dstGLRect.fBottom + dstGLRect.fHeight,
2728 GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST)); 2725 GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST));
2729 this->unbindSurfaceAsFBOForCopy(dstFBOBinding); 2726 if (dstFBO) {
2730 this->unbindSurfaceAsFBOForCopy(srcFBOBinding); 2727 this->unbindTextureFromFBO(GR_GL_DRAW_FRAMEBUFFER);
2728 }
2729 if (srcFBO) {
2730 this->unbindTextureFromFBO(GR_GL_READ_FRAMEBUFFER);
2731 }
2731 copied = true; 2732 copied = true;
2732 } 2733 }
2733 } 2734 }
2734 return copied; 2735 return copied;
2735 } 2736 }
2736 2737
2737 bool GrGLGpu::canCopySurface(const GrSurface* dst, 2738 bool GrGLGpu::canCopySurface(const GrSurface* dst,
2738 const GrSurface* src, 2739 const GrSurface* src,
2739 const SkIRect& srcRect, 2740 const SkIRect& srcRect,
2740 const SkIPoint& dstPoint) { 2741 const SkIPoint& dstPoint) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2796 this->setVertexArrayID(gpu, 0); 2797 this->setVertexArrayID(gpu, 0);
2797 } 2798 }
2798 int attrCount = gpu->glCaps().maxVertexAttributes(); 2799 int attrCount = gpu->glCaps().maxVertexAttributes();
2799 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2800 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2800 fDefaultVertexArrayAttribState.resize(attrCount); 2801 fDefaultVertexArrayAttribState.resize(attrCount);
2801 } 2802 }
2802 attribState = &fDefaultVertexArrayAttribState; 2803 attribState = &fDefaultVertexArrayAttribState;
2803 } 2804 }
2804 return attribState; 2805 return attribState;
2805 } 2806 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLRenderTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698