| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 ScopedStateRestorer scopedStateRestorer(this); | 244 ScopedStateRestorer scopedStateRestorer(this); |
| 245 bool forceGpuResult = false; | 245 bool forceGpuResult = false; |
| 246 return prepareTextureMailboxInternal(outMailbox, outReleaseCallback, | 246 return prepareTextureMailboxInternal(outMailbox, outReleaseCallback, |
| 247 forceGpuResult); | 247 forceGpuResult); |
| 248 } | 248 } |
| 249 | 249 |
| 250 bool DrawingBuffer::prepareTextureMailboxInternal( | 250 bool DrawingBuffer::prepareTextureMailboxInternal( |
| 251 cc::TextureMailbox* outMailbox, | 251 cc::TextureMailbox* outMailbox, |
| 252 std::unique_ptr<cc::SingleReleaseCallback>* outReleaseCallback, | 252 std::unique_ptr<cc::SingleReleaseCallback>* outReleaseCallback, |
| 253 bool forceGpuResult) { | 253 bool forceGpuResult) { |
| 254 // TODO(ccameron): Make this a DCHECK after fixing crbug.com/658265 | 254 DCHECK(m_stateRestorer); |
| 255 CHECK(m_stateRestorer); | |
| 256 if (m_destructionInProgress) { | 255 if (m_destructionInProgress) { |
| 257 // It can be hit in the following sequence. | 256 // It can be hit in the following sequence. |
| 258 // 1. WebGL draws something. | 257 // 1. WebGL draws something. |
| 259 // 2. The compositor begins the frame. | 258 // 2. The compositor begins the frame. |
| 260 // 3. Javascript makes a context lost using WEBGL_lose_context extension. | 259 // 3. Javascript makes a context lost using WEBGL_lose_context extension. |
| 261 // 4. Here. | 260 // 4. Here. |
| 262 return false; | 261 return false; |
| 263 } | 262 } |
| 264 ASSERT(!m_isHidden); | 263 ASSERT(!m_isHidden); |
| 265 if (!m_contentsChanged) | 264 if (!m_contentsChanged) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 RefPtr<DrawingBuffer>(this), | 314 RefPtr<DrawingBuffer>(this), |
| 316 WTF::passed(std::move(bitmap)), m_size); | 315 WTF::passed(std::move(bitmap)), m_size); |
| 317 *outReleaseCallback = | 316 *outReleaseCallback = |
| 318 cc::SingleReleaseCallback::Create(convertToBaseCallback(std::move(func))); | 317 cc::SingleReleaseCallback::Create(convertToBaseCallback(std::move(func))); |
| 319 return true; | 318 return true; |
| 320 } | 319 } |
| 321 | 320 |
| 322 bool DrawingBuffer::finishPrepareTextureMailboxGpu( | 321 bool DrawingBuffer::finishPrepareTextureMailboxGpu( |
| 323 cc::TextureMailbox* outMailbox, | 322 cc::TextureMailbox* outMailbox, |
| 324 std::unique_ptr<cc::SingleReleaseCallback>* outReleaseCallback) { | 323 std::unique_ptr<cc::SingleReleaseCallback>* outReleaseCallback) { |
| 325 // TODO(ccameron): Make this a DCHECK after fixing crbug.com/658265 | 324 DCHECK(m_stateRestorer); |
| 326 CHECK(m_stateRestorer); | |
| 327 if (m_webGLVersion > WebGL1) { | 325 if (m_webGLVersion > WebGL1) { |
| 328 m_stateRestorer->setPixelUnpackBufferBindingDirty(); | 326 m_stateRestorer->setPixelUnpackBufferBindingDirty(); |
| 329 m_gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); | 327 m_gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); |
| 330 } | 328 } |
| 331 | 329 |
| 332 // Specify the buffer that we will put in the mailbox. | 330 // Specify the buffer that we will put in the mailbox. |
| 333 RefPtr<ColorBuffer> colorBufferForMailbox; | 331 RefPtr<ColorBuffer> colorBufferForMailbox; |
| 334 if (m_preserveDrawingBuffer == Discard) { | 332 if (m_preserveDrawingBuffer == Discard) { |
| 335 // If we can discard the backbuffer, send the old backbuffer directly | 333 // If we can discard the backbuffer, send the old backbuffer directly |
| 336 // into the mailbox, and allocate (or recycle) a new backbuffer. | 334 // into the mailbox, and allocate (or recycle) a new backbuffer. |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 defaultBufferRequiresAlphaChannelToBePreserved() ? GL_RGBA : GL_RGB; | 562 defaultBufferRequiresAlphaChannelToBePreserved() ? GL_RGBA : GL_RGB; |
| 565 parameters.creationInternalColorFormat = format; | 563 parameters.creationInternalColorFormat = format; |
| 566 parameters.internalColorFormat = format; | 564 parameters.internalColorFormat = format; |
| 567 parameters.colorFormat = format; | 565 parameters.colorFormat = format; |
| 568 } | 566 } |
| 569 return parameters; | 567 return parameters; |
| 570 } | 568 } |
| 571 | 569 |
| 572 PassRefPtr<DrawingBuffer::ColorBuffer> | 570 PassRefPtr<DrawingBuffer::ColorBuffer> |
| 573 DrawingBuffer::createOrRecycleColorBuffer() { | 571 DrawingBuffer::createOrRecycleColorBuffer() { |
| 574 // TODO(ccameron): Make this a DCHECK after fixing crbug.com/658265 | 572 DCHECK(m_stateRestorer); |
| 575 CHECK(m_stateRestorer); | |
| 576 if (!m_recycledColorBufferQueue.isEmpty()) { | 573 if (!m_recycledColorBufferQueue.isEmpty()) { |
| 577 RefPtr<ColorBuffer> recycled = m_recycledColorBufferQueue.takeLast(); | 574 RefPtr<ColorBuffer> recycled = m_recycledColorBufferQueue.takeLast(); |
| 578 if (recycled->receiveSyncToken.HasData()) | 575 if (recycled->receiveSyncToken.HasData()) |
| 579 m_gl->WaitSyncTokenCHROMIUM(recycled->receiveSyncToken.GetData()); | 576 m_gl->WaitSyncTokenCHROMIUM(recycled->receiveSyncToken.GetData()); |
| 580 DCHECK(recycled->size == m_size); | 577 DCHECK(recycled->size == m_size); |
| 581 return recycled; | 578 return recycled; |
| 582 } | 579 } |
| 583 return createColorBuffer(m_size); | 580 return createColorBuffer(m_size); |
| 584 } | 581 } |
| 585 | 582 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 m_multisampleFBO = 0; | 798 m_multisampleFBO = 0; |
| 802 m_fbo = 0; | 799 m_fbo = 0; |
| 803 | 800 |
| 804 if (m_layer) | 801 if (m_layer) |
| 805 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); | 802 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); |
| 806 | 803 |
| 807 m_client = nullptr; | 804 m_client = nullptr; |
| 808 } | 805 } |
| 809 | 806 |
| 810 bool DrawingBuffer::resizeDefaultFramebuffer(const IntSize& size) { | 807 bool DrawingBuffer::resizeDefaultFramebuffer(const IntSize& size) { |
| 811 // TODO(ccameron): Make this a DCHECK after fixing crbug.com/658265 | 808 DCHECK(m_stateRestorer); |
| 812 CHECK(m_stateRestorer); | |
| 813 // Recreate m_backColorBuffer. | 809 // Recreate m_backColorBuffer. |
| 814 m_backColorBuffer = createColorBuffer(size); | 810 m_backColorBuffer = createColorBuffer(size); |
| 815 | 811 |
| 816 attachColorBufferToReadFramebuffer(); | 812 attachColorBufferToReadFramebuffer(); |
| 817 | 813 |
| 818 if (wantExplicitResolve()) { | 814 if (wantExplicitResolve()) { |
| 819 m_stateRestorer->setFramebufferBindingDirty(); | 815 m_stateRestorer->setFramebufferBindingDirty(); |
| 820 m_stateRestorer->setRenderbufferBindingDirty(); | 816 m_stateRestorer->setRenderbufferBindingDirty(); |
| 821 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); | 817 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); |
| 822 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_multisampleRenderbuffer); | 818 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_multisampleRenderbuffer); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 return m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) == | 867 return m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) == |
| 872 GL_FRAMEBUFFER_COMPLETE; | 868 GL_FRAMEBUFFER_COMPLETE; |
| 873 } | 869 } |
| 874 | 870 |
| 875 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask) { | 871 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask) { |
| 876 ScopedStateRestorer scopedStateRestorer(this); | 872 ScopedStateRestorer scopedStateRestorer(this); |
| 877 clearFramebuffersInternal(clearMask); | 873 clearFramebuffersInternal(clearMask); |
| 878 } | 874 } |
| 879 | 875 |
| 880 void DrawingBuffer::clearFramebuffersInternal(GLbitfield clearMask) { | 876 void DrawingBuffer::clearFramebuffersInternal(GLbitfield clearMask) { |
| 881 // TODO(ccameron): Make this a DCHECK after fixing crbug.com/658265 | 877 DCHECK(m_stateRestorer); |
| 882 CHECK(m_stateRestorer); | |
| 883 m_stateRestorer->setFramebufferBindingDirty(); | 878 m_stateRestorer->setFramebufferBindingDirty(); |
| 884 // We will clear the multisample FBO, but we also need to clear the | 879 // We will clear the multisample FBO, but we also need to clear the |
| 885 // non-multisampled buffer. | 880 // non-multisampled buffer. |
| 886 if (m_multisampleFBO) { | 881 if (m_multisampleFBO) { |
| 887 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 882 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 888 m_gl->Clear(GL_COLOR_BUFFER_BIT); | 883 m_gl->Clear(GL_COLOR_BUFFER_BIT); |
| 889 } | 884 } |
| 890 | 885 |
| 891 m_gl->BindFramebuffer(GL_FRAMEBUFFER, | 886 m_gl->BindFramebuffer(GL_FRAMEBUFFER, |
| 892 m_multisampleFBO ? m_multisampleFBO : m_fbo); | 887 m_multisampleFBO ? m_multisampleFBO : m_fbo); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 908 | 903 |
| 909 return adjustedSize; | 904 return adjustedSize; |
| 910 } | 905 } |
| 911 | 906 |
| 912 bool DrawingBuffer::resize(const IntSize& newSize) { | 907 bool DrawingBuffer::resize(const IntSize& newSize) { |
| 913 ScopedStateRestorer scopedStateRestorer(this); | 908 ScopedStateRestorer scopedStateRestorer(this); |
| 914 return resizeFramebufferInternal(newSize); | 909 return resizeFramebufferInternal(newSize); |
| 915 } | 910 } |
| 916 | 911 |
| 917 bool DrawingBuffer::resizeFramebufferInternal(const IntSize& newSize) { | 912 bool DrawingBuffer::resizeFramebufferInternal(const IntSize& newSize) { |
| 918 // TODO(ccameron): Make this a DCHECK after fixing crbug.com/658265 | 913 DCHECK(m_stateRestorer); |
| 919 CHECK(m_stateRestorer); | 914 DCHECK(!newSize.isEmpty()); |
| 920 CHECK(!newSize.isEmpty()); | |
| 921 IntSize adjustedSize = adjustSize(newSize, m_size, m_maxTextureSize); | 915 IntSize adjustedSize = adjustSize(newSize, m_size, m_maxTextureSize); |
| 922 if (adjustedSize.isEmpty()) | 916 if (adjustedSize.isEmpty()) |
| 923 return false; | 917 return false; |
| 924 | 918 |
| 925 if (adjustedSize != m_size) { | 919 if (adjustedSize != m_size) { |
| 926 do { | 920 do { |
| 927 if (!resizeDefaultFramebuffer(adjustedSize)) { | 921 if (!resizeDefaultFramebuffer(adjustedSize)) { |
| 928 adjustedSize.scale(s_resourceAdjustedRatio); | 922 adjustedSize.scale(s_resourceAdjustedRatio); |
| 929 continue; | 923 continue; |
| 930 } | 924 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 | 959 |
| 966 void DrawingBuffer::resolveAndBindForReadAndDraw() { | 960 void DrawingBuffer::resolveAndBindForReadAndDraw() { |
| 967 { | 961 { |
| 968 ScopedStateRestorer scopedStateRestorer(this); | 962 ScopedStateRestorer scopedStateRestorer(this); |
| 969 resolveMultisampleFramebufferInternal(); | 963 resolveMultisampleFramebufferInternal(); |
| 970 } | 964 } |
| 971 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 965 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 972 } | 966 } |
| 973 | 967 |
| 974 void DrawingBuffer::resolveMultisampleFramebufferInternal() { | 968 void DrawingBuffer::resolveMultisampleFramebufferInternal() { |
| 975 // TODO(ccameron): Make this a DCHECK after fixing crbug.com/658265 | 969 DCHECK(m_stateRestorer); |
| 976 CHECK(m_stateRestorer); | |
| 977 m_stateRestorer->setFramebufferBindingDirty(); | 970 m_stateRestorer->setFramebufferBindingDirty(); |
| 978 if (wantExplicitResolve() && !m_contentsChangeCommitted) { | 971 if (wantExplicitResolve() && !m_contentsChangeCommitted) { |
| 979 m_stateRestorer->setClearStateDirty(); | 972 m_stateRestorer->setClearStateDirty(); |
| 980 m_gl->BindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); | 973 m_gl->BindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); |
| 981 m_gl->BindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, m_fbo); | 974 m_gl->BindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, m_fbo); |
| 982 m_gl->Disable(GL_SCISSOR_TEST); | 975 m_gl->Disable(GL_SCISSOR_TEST); |
| 983 | 976 |
| 984 int width = m_size.width(); | 977 int width = m_size.width(); |
| 985 int height = m_size.height(); | 978 int height = m_size.height(); |
| 986 // Use NEAREST, because there is no scale performed during the blit. | 979 // Use NEAREST, because there is no scale performed during the blit. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 | 1068 |
| 1076 pixels.transfer(contents); | 1069 pixels.transfer(contents); |
| 1077 return true; | 1070 return true; |
| 1078 } | 1071 } |
| 1079 | 1072 |
| 1080 void DrawingBuffer::readBackFramebuffer(unsigned char* pixels, | 1073 void DrawingBuffer::readBackFramebuffer(unsigned char* pixels, |
| 1081 int width, | 1074 int width, |
| 1082 int height, | 1075 int height, |
| 1083 ReadbackOrder readbackOrder, | 1076 ReadbackOrder readbackOrder, |
| 1084 WebGLImageConversion::AlphaOp op) { | 1077 WebGLImageConversion::AlphaOp op) { |
| 1085 // TODO(ccameron): Make this a DCHECK after fixing crbug.com/658265 | 1078 DCHECK(m_stateRestorer); |
| 1086 CHECK(m_stateRestorer); | |
| 1087 m_stateRestorer->setPixelPackAlignmentDirty(); | 1079 m_stateRestorer->setPixelPackAlignmentDirty(); |
| 1088 m_gl->PixelStorei(GL_PACK_ALIGNMENT, 1); | 1080 m_gl->PixelStorei(GL_PACK_ALIGNMENT, 1); |
| 1089 m_gl->ReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); | 1081 m_gl->ReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 1090 | 1082 |
| 1091 size_t bufferSize = 4 * width * height; | 1083 size_t bufferSize = 4 * width * height; |
| 1092 | 1084 |
| 1093 if (readbackOrder == ReadbackSkia) { | 1085 if (readbackOrder == ReadbackSkia) { |
| 1094 #if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT | 1086 #if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT |
| 1095 // Swizzle red and blue channels to match SkBitmap's byte ordering. | 1087 // Swizzle red and blue channels to match SkBitmap's byte ordering. |
| 1096 // TODO(kbr): expose GL_BGRA as extension. | 1088 // TODO(kbr): expose GL_BGRA as extension. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1121 uint8_t* rowA = framebuffer + i * rowBytes; | 1113 uint8_t* rowA = framebuffer + i * rowBytes; |
| 1122 uint8_t* rowB = framebuffer + (height - i - 1) * rowBytes; | 1114 uint8_t* rowB = framebuffer + (height - i - 1) * rowBytes; |
| 1123 memcpy(scanline.data(), rowB, rowBytes); | 1115 memcpy(scanline.data(), rowB, rowBytes); |
| 1124 memcpy(rowB, rowA, rowBytes); | 1116 memcpy(rowB, rowA, rowBytes); |
| 1125 memcpy(rowA, scanline.data(), rowBytes); | 1117 memcpy(rowA, scanline.data(), rowBytes); |
| 1126 } | 1118 } |
| 1127 } | 1119 } |
| 1128 | 1120 |
| 1129 RefPtr<DrawingBuffer::ColorBuffer> DrawingBuffer::createColorBuffer( | 1121 RefPtr<DrawingBuffer::ColorBuffer> DrawingBuffer::createColorBuffer( |
| 1130 const IntSize& size) { | 1122 const IntSize& size) { |
| 1131 // TODO(ccameron): Make this a DCHECK after fixing crbug.com/658265 | 1123 DCHECK(m_stateRestorer); |
| 1132 CHECK(m_stateRestorer); | |
| 1133 m_stateRestorer->setFramebufferBindingDirty(); | 1124 m_stateRestorer->setFramebufferBindingDirty(); |
| 1134 m_stateRestorer->setTextureBindingDirty(); | 1125 m_stateRestorer->setTextureBindingDirty(); |
| 1135 | 1126 |
| 1136 // Select the Parameters for the texture object. Allocate the backing | 1127 // Select the Parameters for the texture object. Allocate the backing |
| 1137 // GpuMemoryBuffer and GLImage, if one is going to be used. | 1128 // GpuMemoryBuffer and GLImage, if one is going to be used. |
| 1138 ColorBufferParameters parameters; | 1129 ColorBufferParameters parameters; |
| 1139 GLuint imageId = 0; | 1130 GLuint imageId = 0; |
| 1140 if (shouldUseChromiumImage()) { | 1131 if (shouldUseChromiumImage()) { |
| 1141 parameters = gpuMemoryBufferColorBufferParameters(); | 1132 parameters = gpuMemoryBufferColorBufferParameters(); |
| 1142 imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM( | 1133 imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM( |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 m_gl->Clear(GL_COLOR_BUFFER_BIT); | 1187 m_gl->Clear(GL_COLOR_BUFFER_BIT); |
| 1197 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 1188 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 1198 parameters.target, 0, 0); | 1189 parameters.target, 0, 0); |
| 1199 m_gl->DeleteFramebuffers(1, &fbo); | 1190 m_gl->DeleteFramebuffers(1, &fbo); |
| 1200 } | 1191 } |
| 1201 | 1192 |
| 1202 return adoptRef(new ColorBuffer(this, parameters, size, textureId, imageId)); | 1193 return adoptRef(new ColorBuffer(this, parameters, size, textureId, imageId)); |
| 1203 } | 1194 } |
| 1204 | 1195 |
| 1205 void DrawingBuffer::attachColorBufferToReadFramebuffer() { | 1196 void DrawingBuffer::attachColorBufferToReadFramebuffer() { |
| 1206 // TODO(ccameron): Make this a DCHECK after fixing crbug.com/658265 | 1197 DCHECK(m_stateRestorer); |
| 1207 CHECK(m_stateRestorer); | |
| 1208 m_stateRestorer->setFramebufferBindingDirty(); | 1198 m_stateRestorer->setFramebufferBindingDirty(); |
| 1209 m_stateRestorer->setTextureBindingDirty(); | 1199 m_stateRestorer->setTextureBindingDirty(); |
| 1210 | 1200 |
| 1211 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 1201 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 1212 | 1202 |
| 1213 GLenum target = m_backColorBuffer->parameters.target; | 1203 GLenum target = m_backColorBuffer->parameters.target; |
| 1214 GLenum id = m_backColorBuffer->textureId; | 1204 GLenum id = m_backColorBuffer->textureId; |
| 1215 | 1205 |
| 1216 m_gl->BindTexture(target, id); | 1206 m_gl->BindTexture(target, id); |
| 1217 | 1207 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1241 if (contextProvider() | 1231 if (contextProvider() |
| 1242 ->getCapabilities() | 1232 ->getCapabilities() |
| 1243 .disable_webgl_rgb_multisampling_usage) | 1233 .disable_webgl_rgb_multisampling_usage) |
| 1244 return GL_RGBA8_OES; | 1234 return GL_RGBA8_OES; |
| 1245 return GL_RGB8_OES; | 1235 return GL_RGB8_OES; |
| 1246 } | 1236 } |
| 1247 | 1237 |
| 1248 DrawingBuffer::ScopedStateRestorer::ScopedStateRestorer( | 1238 DrawingBuffer::ScopedStateRestorer::ScopedStateRestorer( |
| 1249 DrawingBuffer* drawingBuffer) | 1239 DrawingBuffer* drawingBuffer) |
| 1250 : m_drawingBuffer(drawingBuffer) { | 1240 : m_drawingBuffer(drawingBuffer) { |
| 1251 // TODO(ccameron): Make this a DCHECK after fixing crbug.com/658265 | 1241 // If this is a nested restorer, save the previous restorer. |
| 1252 CHECK(!m_drawingBuffer->m_stateRestorer); | 1242 m_previousStateRestorer = drawingBuffer->m_stateRestorer; |
| 1253 m_drawingBuffer->m_stateRestorer = this; | 1243 m_drawingBuffer->m_stateRestorer = this; |
| 1254 } | 1244 } |
| 1255 | 1245 |
| 1256 DrawingBuffer::ScopedStateRestorer::~ScopedStateRestorer() { | 1246 DrawingBuffer::ScopedStateRestorer::~ScopedStateRestorer() { |
| 1257 // TODO(ccameron): Make this a DCHECK after fixing crbug.com/658265 | 1247 DCHECK_EQ(m_drawingBuffer->m_stateRestorer, this); |
| 1258 CHECK_EQ(m_drawingBuffer->m_stateRestorer, this); | 1248 m_drawingBuffer->m_stateRestorer = m_previousStateRestorer; |
| 1259 m_drawingBuffer->m_stateRestorer = nullptr; | |
| 1260 Client* client = m_drawingBuffer->m_client; | 1249 Client* client = m_drawingBuffer->m_client; |
| 1261 if (!client) | 1250 if (!client) |
| 1262 return; | 1251 return; |
| 1263 | 1252 |
| 1264 if (m_clearStateDirty) { | 1253 if (m_clearStateDirty) { |
| 1265 client->DrawingBufferClientRestoreScissorTest(); | 1254 client->DrawingBufferClientRestoreScissorTest(); |
| 1266 client->DrawingBufferClientRestoreMaskAndClearValues(); | 1255 client->DrawingBufferClientRestoreMaskAndClearValues(); |
| 1267 } | 1256 } |
| 1268 if (m_pixelPackAlignmentDirty) | 1257 if (m_pixelPackAlignmentDirty) |
| 1269 client->DrawingBufferClientRestorePixelPackAlignment(); | 1258 client->DrawingBufferClientRestorePixelPackAlignment(); |
| 1270 if (m_textureBindingDirty) | 1259 if (m_textureBindingDirty) |
| 1271 client->DrawingBufferClientRestoreTexture2DBinding(); | 1260 client->DrawingBufferClientRestoreTexture2DBinding(); |
| 1272 if (m_renderbufferBindingDirty) | 1261 if (m_renderbufferBindingDirty) |
| 1273 client->DrawingBufferClientRestoreRenderbufferBinding(); | 1262 client->DrawingBufferClientRestoreRenderbufferBinding(); |
| 1274 if (m_framebufferBindingDirty) | 1263 if (m_framebufferBindingDirty) |
| 1275 client->DrawingBufferClientRestoreFramebufferBinding(); | 1264 client->DrawingBufferClientRestoreFramebufferBinding(); |
| 1276 if (m_pixelUnpackBufferBindingDirty) | 1265 if (m_pixelUnpackBufferBindingDirty) |
| 1277 client->DrawingBufferClientRestorePixelUnpackBufferBinding(); | 1266 client->DrawingBufferClientRestorePixelUnpackBufferBinding(); |
| 1278 } | 1267 } |
| 1279 | 1268 |
| 1280 bool DrawingBuffer::shouldUseChromiumImage() { | 1269 bool DrawingBuffer::shouldUseChromiumImage() { |
| 1281 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && | 1270 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && |
| 1282 m_chromiumImageUsage == AllowChromiumImage; | 1271 m_chromiumImageUsage == AllowChromiumImage; |
| 1283 } | 1272 } |
| 1284 | 1273 |
| 1285 } // namespace blink | 1274 } // namespace blink |
| OLD | NEW |