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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 2862963003: Replace ASSERT with DCHECK in modules/ (Closed)
Patch Set: NOTREACHED instead of DCHECK(false) Created 3 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // This will call deactivateContext once the context has actually been lost. 184 // This will call deactivateContext once the context has actually been lost.
185 candidate->ForceLostContext(WebGLRenderingContextBase::kSyntheticLostContext, 185 candidate->ForceLostContext(WebGLRenderingContextBase::kSyntheticLostContext,
186 WebGLRenderingContextBase::kWhenAvailable); 186 WebGLRenderingContextBase::kWhenAvailable);
187 } 187 }
188 188
189 WebGLRenderingContextBase* WebGLRenderingContextBase::OldestContext() { 189 WebGLRenderingContextBase* WebGLRenderingContextBase::OldestContext() {
190 if (ActiveContexts().IsEmpty()) 190 if (ActiveContexts().IsEmpty())
191 return nullptr; 191 return nullptr;
192 192
193 WebGLRenderingContextBase* candidate = *(ActiveContexts().begin()); 193 WebGLRenderingContextBase* candidate = *(ActiveContexts().begin());
194 ASSERT(!candidate->isContextLost()); 194 DCHECK(!candidate->isContextLost());
195 for (WebGLRenderingContextBase* context : ActiveContexts()) { 195 for (WebGLRenderingContextBase* context : ActiveContexts()) {
196 ASSERT(!context->isContextLost()); 196 DCHECK(!context->isContextLost());
197 if (context->ContextGL()->GetLastFlushIdCHROMIUM() < 197 if (context->ContextGL()->GetLastFlushIdCHROMIUM() <
198 candidate->ContextGL()->GetLastFlushIdCHROMIUM()) { 198 candidate->ContextGL()->GetLastFlushIdCHROMIUM()) {
199 candidate = context; 199 candidate = context;
200 } 200 }
201 } 201 }
202 202
203 return candidate; 203 return candidate;
204 } 204 }
205 205
206 WebGLRenderingContextBase* WebGLRenderingContextBase::OldestEvictedContext() { 206 WebGLRenderingContextBase* WebGLRenderingContextBase::OldestEvictedContext() {
(...skipping 17 matching lines...) Expand all
224 unsigned max_gl_contexts = CurrentMaxGLContexts(); 224 unsigned max_gl_contexts = CurrentMaxGLContexts();
225 unsigned removed_contexts = 0; 225 unsigned removed_contexts = 0;
226 while (ActiveContexts().size() >= max_gl_contexts && 226 while (ActiveContexts().size() >= max_gl_contexts &&
227 removed_contexts < max_gl_contexts) { 227 removed_contexts < max_gl_contexts) {
228 ForciblyLoseOldestContext( 228 ForciblyLoseOldestContext(
229 "WARNING: Too many active WebGL contexts. Oldest context will be " 229 "WARNING: Too many active WebGL contexts. Oldest context will be "
230 "lost."); 230 "lost.");
231 removed_contexts++; 231 removed_contexts++;
232 } 232 }
233 233
234 ASSERT(!context->isContextLost()); 234 DCHECK(!context->isContextLost());
235 ActiveContexts().insert(context); 235 ActiveContexts().insert(context);
236 } 236 }
237 237
238 void WebGLRenderingContextBase::DeactivateContext( 238 void WebGLRenderingContextBase::DeactivateContext(
239 WebGLRenderingContextBase* context) { 239 WebGLRenderingContextBase* context) {
240 ActiveContexts().erase(context); 240 ActiveContexts().erase(context);
241 } 241 }
242 242
243 void WebGLRenderingContextBase::AddToEvictedList( 243 void WebGLRenderingContextBase::AddToEvictedList(
244 WebGLRenderingContextBase* context) { 244 WebGLRenderingContextBase* context) {
245 static int generation = 0; 245 static int generation = 0;
246 ForciblyEvictedContexts().Set(context, generation++); 246 ForciblyEvictedContexts().Set(context, generation++);
247 } 247 }
248 248
249 void WebGLRenderingContextBase::RemoveFromEvictedList( 249 void WebGLRenderingContextBase::RemoveFromEvictedList(
250 WebGLRenderingContextBase* context) { 250 WebGLRenderingContextBase* context) {
251 ForciblyEvictedContexts().erase(context); 251 ForciblyEvictedContexts().erase(context);
252 } 252 }
253 253
254 void WebGLRenderingContextBase::RestoreEvictedContext( 254 void WebGLRenderingContextBase::RestoreEvictedContext(
255 WebGLRenderingContextBase* context) { 255 WebGLRenderingContextBase* context) {
256 // These two sets keep weak references to their contexts; 256 // These two sets keep weak references to their contexts;
257 // verify that the GC already removed the |context| entries. 257 // verify that the GC already removed the |context| entries.
258 ASSERT(!ForciblyEvictedContexts().Contains(context)); 258 DCHECK(!ForciblyEvictedContexts().Contains(context));
259 ASSERT(!ActiveContexts().Contains(context)); 259 DCHECK(!ActiveContexts().Contains(context));
260 260
261 unsigned max_gl_contexts = CurrentMaxGLContexts(); 261 unsigned max_gl_contexts = CurrentMaxGLContexts();
262 // Try to re-enable the oldest inactive contexts. 262 // Try to re-enable the oldest inactive contexts.
263 while (ActiveContexts().size() < max_gl_contexts && 263 while (ActiveContexts().size() < max_gl_contexts &&
264 ForciblyEvictedContexts().size()) { 264 ForciblyEvictedContexts().size()) {
265 WebGLRenderingContextBase* evicted_context = OldestEvictedContext(); 265 WebGLRenderingContextBase* evicted_context = OldestEvictedContext();
266 if (!evicted_context->restore_allowed_) { 266 if (!evicted_context->restore_allowed_) {
267 ForciblyEvictedContexts().erase(evicted_context); 267 ForciblyEvictedContexts().erase(evicted_context);
268 continue; 268 continue;
269 } 269 }
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 Platform::ContextAttributes context_attributes; 584 Platform::ContextAttributes context_attributes;
585 Platform::GraphicsInfo* gl_info; 585 Platform::GraphicsInfo* gl_info;
586 KURL url; 586 KURL url;
587 // Outputs. 587 // Outputs.
588 std::unique_ptr<WebGraphicsContext3DProvider> created_context_provider; 588 std::unique_ptr<WebGraphicsContext3DProvider> created_context_provider;
589 }; 589 };
590 590
591 static void CreateContextProviderOnMainThread( 591 static void CreateContextProviderOnMainThread(
592 ContextProviderCreationInfo* creation_info, 592 ContextProviderCreationInfo* creation_info,
593 WaitableEvent* waitable_event) { 593 WaitableEvent* waitable_event) {
594 ASSERT(IsMainThread()); 594 DCHECK(IsMainThread());
595 creation_info->created_context_provider = 595 creation_info->created_context_provider =
596 Platform::Current()->CreateOffscreenGraphicsContext3DProvider( 596 Platform::Current()->CreateOffscreenGraphicsContext3DProvider(
597 creation_info->context_attributes, creation_info->url, 0, 597 creation_info->context_attributes, creation_info->url, 0,
598 creation_info->gl_info); 598 creation_info->gl_info);
599 waitable_event->Signal(); 599 waitable_event->Signal();
600 } 600 }
601 601
602 static std::unique_ptr<WebGraphicsContext3DProvider> 602 static std::unique_ptr<WebGraphicsContext3DProvider>
603 CreateContextProviderOnWorkerThread( 603 CreateContextProviderOnWorkerThread(
604 Platform::ContextAttributes context_attributes, 604 Platform::ContextAttributes context_attributes,
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 one_plus_max_non_default_texture_unit_(0), 1031 one_plus_max_non_default_texture_unit_(0),
1032 is_web_gl2_formats_types_added_(false), 1032 is_web_gl2_formats_types_added_(false),
1033 is_web_gl2_tex_image_source_formats_types_added_(false), 1033 is_web_gl2_tex_image_source_formats_types_added_(false),
1034 is_web_gl2_internal_formats_copy_tex_image_added_(false), 1034 is_web_gl2_internal_formats_copy_tex_image_added_(false),
1035 is_oes_texture_float_formats_types_added_(false), 1035 is_oes_texture_float_formats_types_added_(false),
1036 is_oes_texture_half_float_formats_types_added_(false), 1036 is_oes_texture_half_float_formats_types_added_(false),
1037 is_web_gl_depth_texture_formats_types_added_(false), 1037 is_web_gl_depth_texture_formats_types_added_(false),
1038 is_ext_srgb_formats_types_added_(false), 1038 is_ext_srgb_formats_types_added_(false),
1039 is_ext_color_buffer_float_formats_added_(false), 1039 is_ext_color_buffer_float_formats_added_(false),
1040 version_(version) { 1040 version_(version) {
1041 ASSERT(context_provider); 1041 DCHECK(context_provider);
1042 1042
1043 context_group_->AddContext(this); 1043 context_group_->AddContext(this);
1044 1044
1045 max_viewport_dims_[0] = max_viewport_dims_[1] = 0; 1045 max_viewport_dims_[0] = max_viewport_dims_[1] = 0;
1046 context_provider->ContextGL()->GetIntegerv(GL_MAX_VIEWPORT_DIMS, 1046 context_provider->ContextGL()->GetIntegerv(GL_MAX_VIEWPORT_DIMS,
1047 max_viewport_dims_); 1047 max_viewport_dims_);
1048 1048
1049 RefPtr<DrawingBuffer> buffer; 1049 RefPtr<DrawingBuffer> buffer;
1050 buffer = CreateDrawingBuffer(std::move(context_provider)); 1050 buffer = CreateDrawingBuffer(std::move(context_provider));
1051 if (!buffer) { 1051 if (!buffer) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 : DrawingBuffer::kAllowChromiumImage; 1108 : DrawingBuffer::kAllowChromiumImage;
1109 1109
1110 return DrawingBuffer::Create( 1110 return DrawingBuffer::Create(
1111 std::move(context_provider), this, ClampedCanvasSize(), 1111 std::move(context_provider), this, ClampedCanvasSize(),
1112 premultiplied_alpha, want_alpha_channel, want_depth_buffer, 1112 premultiplied_alpha, want_alpha_channel, want_depth_buffer,
1113 want_stencil_buffer, want_antialiasing, preserve, web_gl_version, 1113 want_stencil_buffer, want_antialiasing, preserve, web_gl_version,
1114 chromium_image_usage, color_params()); 1114 chromium_image_usage, color_params());
1115 } 1115 }
1116 1116
1117 void WebGLRenderingContextBase::InitializeNewContext() { 1117 void WebGLRenderingContextBase::InitializeNewContext() {
1118 ASSERT(!isContextLost()); 1118 DCHECK(!isContextLost());
1119 ASSERT(GetDrawingBuffer()); 1119 DCHECK(GetDrawingBuffer());
1120 1120
1121 marked_canvas_dirty_ = false; 1121 marked_canvas_dirty_ = false;
1122 animation_frame_in_progress_ = false; 1122 animation_frame_in_progress_ = false;
1123 active_texture_unit_ = 0; 1123 active_texture_unit_ = 0;
1124 pack_alignment_ = 4; 1124 pack_alignment_ = 4;
1125 unpack_alignment_ = 4; 1125 unpack_alignment_ = 4;
1126 unpack_flip_y_ = false; 1126 unpack_flip_y_ = false;
1127 unpack_premultiply_alpha_ = false; 1127 unpack_premultiply_alpha_ = false;
1128 unpack_colorspace_conversion_ = GC3D_BROWSER_DEFAULT_WEBGL; 1128 unpack_colorspace_conversion_ = GC3D_BROWSER_DEFAULT_WEBGL;
1129 bound_array_buffer_ = nullptr; 1129 bound_array_buffer_ = nullptr;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 supported_tex_image_source_types_.clear(); 1249 supported_tex_image_source_types_.clear();
1250 ADD_VALUES_TO_SET(supported_tex_image_source_types_, kSupportedTypesES2); 1250 ADD_VALUES_TO_SET(supported_tex_image_source_types_, kSupportedTypesES2);
1251 1251
1252 // The DrawingBuffer was unable to store the state that dirtied when it was 1252 // The DrawingBuffer was unable to store the state that dirtied when it was
1253 // initialized. Restore it now. 1253 // initialized. Restore it now.
1254 GetDrawingBuffer()->RestoreAllState(); 1254 GetDrawingBuffer()->RestoreAllState();
1255 ActivateContext(this); 1255 ActivateContext(this);
1256 } 1256 }
1257 1257
1258 void WebGLRenderingContextBase::SetupFlags() { 1258 void WebGLRenderingContextBase::SetupFlags() {
1259 ASSERT(GetDrawingBuffer()); 1259 DCHECK(GetDrawingBuffer());
1260 if (canvas()) { 1260 if (canvas()) {
1261 if (Page* p = canvas()->GetDocument().GetPage()) { 1261 if (Page* p = canvas()->GetDocument().GetPage()) {
1262 synthesized_errors_to_console_ = 1262 synthesized_errors_to_console_ =
1263 p->GetSettings().GetWebGLErrorsToConsoleEnabled(); 1263 p->GetSettings().GetWebGLErrorsToConsoleEnabled();
1264 } 1264 }
1265 } 1265 }
1266 1266
1267 is_depth_stencil_supported_ = 1267 is_depth_stencil_supported_ =
1268 ExtensionsUtil()->IsExtensionEnabled("GL_OES_packed_depth_stencil"); 1268 ExtensionsUtil()->IsExtensionEnabled("GL_OES_packed_depth_stencil");
1269 } 1269 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 extensions_util_.reset(); 1312 extensions_util_.reset();
1313 1313
1314 std::unique_ptr<WTF::Closure> null_closure; 1314 std::unique_ptr<WTF::Closure> null_closure;
1315 std::unique_ptr<WTF::Function<void(const char*, int32_t)>> null_function; 1315 std::unique_ptr<WTF::Function<void(const char*, int32_t)>> null_function;
1316 GetDrawingBuffer()->ContextProvider()->SetLostContextCallback( 1316 GetDrawingBuffer()->ContextProvider()->SetLostContextCallback(
1317 ConvertToBaseCallback(std::move(null_closure))); 1317 ConvertToBaseCallback(std::move(null_closure)));
1318 GetDrawingBuffer()->ContextProvider()->SetErrorMessageCallback( 1318 GetDrawingBuffer()->ContextProvider()->SetErrorMessageCallback(
1319 ConvertToBaseCallback(std::move(null_function))); 1319 ConvertToBaseCallback(std::move(null_function)));
1320 GetDrawingBuffer()->AddNewMailboxCallback(nullptr); 1320 GetDrawingBuffer()->AddNewMailboxCallback(nullptr);
1321 1321
1322 ASSERT(GetDrawingBuffer()); 1322 DCHECK(GetDrawingBuffer());
1323 drawing_buffer_->BeginDestruction(); 1323 drawing_buffer_->BeginDestruction();
1324 drawing_buffer_.Clear(); 1324 drawing_buffer_.Clear();
1325 } 1325 }
1326 1326
1327 void WebGLRenderingContextBase::MarkContextChanged( 1327 void WebGLRenderingContextBase::MarkContextChanged(
1328 ContentChangeType change_type) { 1328 ContentChangeType change_type) {
1329 if (framebuffer_binding_ || isContextLost()) 1329 if (framebuffer_binding_ || isContextLost())
1330 return; 1330 return;
1331 1331
1332 if (!GetDrawingBuffer()->MarkContentsChanged() && marked_canvas_dirty_) { 1332 if (!GetDrawingBuffer()->MarkContentsChanged() && marked_canvas_dirty_) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 GetDrawingBuffer()->SetBufferClearNeeded(true); 1476 GetDrawingBuffer()->SetBufferClearNeeded(true);
1477 } 1477 }
1478 1478
1479 void WebGLRenderingContextBase::SetIsHidden(bool hidden) { 1479 void WebGLRenderingContextBase::SetIsHidden(bool hidden) {
1480 is_hidden_ = hidden; 1480 is_hidden_ = hidden;
1481 if (GetDrawingBuffer()) 1481 if (GetDrawingBuffer())
1482 GetDrawingBuffer()->SetIsHidden(hidden); 1482 GetDrawingBuffer()->SetIsHidden(hidden);
1483 1483
1484 if (!hidden && isContextLost() && restore_allowed_ && 1484 if (!hidden && isContextLost() && restore_allowed_ &&
1485 auto_recovery_method_ == kAuto) { 1485 auto_recovery_method_ == kAuto) {
1486 ASSERT(!restore_timer_.IsActive()); 1486 DCHECK(!restore_timer_.IsActive());
1487 restore_timer_.StartOneShot(0, BLINK_FROM_HERE); 1487 restore_timer_.StartOneShot(0, BLINK_FROM_HERE);
1488 } 1488 }
1489 } 1489 }
1490 1490
1491 bool WebGLRenderingContextBase::PaintRenderingResultsToCanvas( 1491 bool WebGLRenderingContextBase::PaintRenderingResultsToCanvas(
1492 SourceDrawingBuffer source_buffer) { 1492 SourceDrawingBuffer source_buffer) {
1493 if (isContextLost()) 1493 if (isContextLost())
1494 return false; 1494 return false;
1495 1495
1496 bool must_clear_now = ClearIfComposited() != kSkipped; 1496 bool must_clear_now = ClearIfComposited() != kSkipped;
(...skipping 2475 matching lines...) Expand 10 before | Expand all | Expand 10 after
3972 if (read_framebuffer_binding) { 3972 if (read_framebuffer_binding) {
3973 const char* reason = "framebuffer incomplete"; 3973 const char* reason = "framebuffer incomplete";
3974 if (read_framebuffer_binding->CheckDepthStencilStatus(&reason) != 3974 if (read_framebuffer_binding->CheckDepthStencilStatus(&reason) !=
3975 GL_FRAMEBUFFER_COMPLETE) { 3975 GL_FRAMEBUFFER_COMPLETE) {
3976 SynthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, function_name, 3976 SynthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, function_name,
3977 reason); 3977 reason);
3978 return false; 3978 return false;
3979 } 3979 }
3980 } else { 3980 } else {
3981 if (read_buffer_of_default_framebuffer_ == GL_NONE) { 3981 if (read_buffer_of_default_framebuffer_ == GL_NONE) {
3982 ASSERT(IsWebGL2OrHigher()); 3982 DCHECK(IsWebGL2OrHigher());
3983 SynthesizeGLError(GL_INVALID_OPERATION, function_name, 3983 SynthesizeGLError(GL_INVALID_OPERATION, function_name,
3984 "no image to read from"); 3984 "no image to read from");
3985 return false; 3985 return false;
3986 } 3986 }
3987 } 3987 }
3988 return true; 3988 return true;
3989 } 3989 }
3990 3990
3991 bool WebGLRenderingContextBase::ValidateReadPixelsFormatAndType( 3991 bool WebGLRenderingContextBase::ValidateReadPixelsFormatAndType(
3992 GLenum format, 3992 GLenum format,
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
4158 } 4158 }
4159 } 4159 }
4160 4160
4161 void WebGLRenderingContextBase::RenderbufferStorageImpl( 4161 void WebGLRenderingContextBase::RenderbufferStorageImpl(
4162 GLenum target, 4162 GLenum target,
4163 GLsizei samples, 4163 GLsizei samples,
4164 GLenum internalformat, 4164 GLenum internalformat,
4165 GLsizei width, 4165 GLsizei width,
4166 GLsizei height, 4166 GLsizei height,
4167 const char* function_name) { 4167 const char* function_name) {
4168 ASSERT(!samples); // |samples| > 0 is only valid in WebGL2's 4168 DCHECK(!samples); // |samples| > 0 is only valid in WebGL2's
4169 // renderbufferStorageMultisample(). 4169 // renderbufferStorageMultisample().
4170 ASSERT(!IsWebGL2OrHigher()); // Make sure this is overridden in WebGL 2. 4170 DCHECK(!IsWebGL2OrHigher()); // Make sure this is overridden in WebGL 2.
4171 switch (internalformat) { 4171 switch (internalformat) {
4172 case GL_DEPTH_COMPONENT16: 4172 case GL_DEPTH_COMPONENT16:
4173 case GL_RGBA4: 4173 case GL_RGBA4:
4174 case GL_RGB5_A1: 4174 case GL_RGB5_A1:
4175 case GL_RGB565: 4175 case GL_RGB565:
4176 case GL_STENCIL_INDEX8: 4176 case GL_STENCIL_INDEX8:
4177 ContextGL()->RenderbufferStorage(target, internalformat, width, height); 4177 ContextGL()->RenderbufferStorage(target, internalformat, width, height);
4178 renderbuffer_binding_->SetInternalFormat(internalformat); 4178 renderbuffer_binding_->SetInternalFormat(internalformat);
4179 renderbuffer_binding_->SetSize(width, height); 4179 renderbuffer_binding_->SetSize(width, height);
4180 break; 4180 break;
4181 case GL_SRGB8_ALPHA8_EXT: 4181 case GL_SRGB8_ALPHA8_EXT:
4182 if (!ExtensionEnabled(kEXTsRGBName)) { 4182 if (!ExtensionEnabled(kEXTsRGBName)) {
4183 SynthesizeGLError(GL_INVALID_ENUM, function_name, "sRGB not enabled"); 4183 SynthesizeGLError(GL_INVALID_ENUM, function_name, "sRGB not enabled");
4184 break; 4184 break;
4185 } 4185 }
4186 ContextGL()->RenderbufferStorage(target, internalformat, width, height); 4186 ContextGL()->RenderbufferStorage(target, internalformat, width, height);
4187 renderbuffer_binding_->SetInternalFormat(internalformat); 4187 renderbuffer_binding_->SetInternalFormat(internalformat);
4188 renderbuffer_binding_->SetSize(width, height); 4188 renderbuffer_binding_->SetSize(width, height);
4189 break; 4189 break;
4190 case GL_DEPTH_STENCIL_OES: 4190 case GL_DEPTH_STENCIL_OES:
4191 ASSERT(IsDepthStencilSupported()); 4191 DCHECK(IsDepthStencilSupported());
4192 ContextGL()->RenderbufferStorage(target, GL_DEPTH24_STENCIL8_OES, width, 4192 ContextGL()->RenderbufferStorage(target, GL_DEPTH24_STENCIL8_OES, width,
4193 height); 4193 height);
4194 renderbuffer_binding_->SetSize(width, height); 4194 renderbuffer_binding_->SetSize(width, height);
4195 renderbuffer_binding_->SetInternalFormat(internalformat); 4195 renderbuffer_binding_->SetInternalFormat(internalformat);
4196 break; 4196 break;
4197 default: 4197 default:
4198 SynthesizeGLError(GL_INVALID_ENUM, function_name, 4198 SynthesizeGLError(GL_INVALID_ENUM, function_name,
4199 "invalid internalformat"); 4199 "invalid internalformat");
4200 break; 4200 break;
4201 } 4201 }
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
4552 } 4552 }
4553 4553
4554 // TODO(fmalita): figure why WebGLImageConversion::ImageExtractor can't handle 4554 // TODO(fmalita): figure why WebGLImageConversion::ImageExtractor can't handle
4555 // SVG-backed images, and get rid of this intermediate step. 4555 // SVG-backed images, and get rid of this intermediate step.
4556 PassRefPtr<Image> WebGLRenderingContextBase::DrawImageIntoBuffer( 4556 PassRefPtr<Image> WebGLRenderingContextBase::DrawImageIntoBuffer(
4557 PassRefPtr<Image> pass_image, 4557 PassRefPtr<Image> pass_image,
4558 int width, 4558 int width,
4559 int height, 4559 int height,
4560 const char* function_name) { 4560 const char* function_name) {
4561 RefPtr<Image> image(std::move(pass_image)); 4561 RefPtr<Image> image(std::move(pass_image));
4562 ASSERT(image); 4562 DCHECK(image);
4563 4563
4564 IntSize size(width, height); 4564 IntSize size(width, height);
4565 ImageBuffer* buf = generated_image_cache_.GetImageBuffer(size); 4565 ImageBuffer* buf = generated_image_cache_.GetImageBuffer(size);
4566 if (!buf) { 4566 if (!buf) {
4567 SynthesizeGLError(GL_OUT_OF_MEMORY, function_name, "out of memory"); 4567 SynthesizeGLError(GL_OUT_OF_MEMORY, function_name, "out of memory");
4568 return nullptr; 4568 return nullptr;
4569 } 4569 }
4570 4570
4571 if (!image->CurrentFrameKnownToBeOpaque()) 4571 if (!image->CurrentFrameKnownToBeOpaque())
4572 buf->Canvas()->clear(SK_ColorTRANSPARENT); 4572 buf->Canvas()->clear(SK_ColorTRANSPARENT);
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
5398 function_type = kTexImage; 5398 function_type = kTexImage;
5399 else 5399 else
5400 function_type = kTexSubImage; 5400 function_type = kTexSubImage;
5401 5401
5402 GLsizei width = source_sub_rect.Width(); 5402 GLsizei width = source_sub_rect.Width();
5403 GLsizei height = source_sub_rect.Height(); 5403 GLsizei height = source_sub_rect.Height();
5404 if (!ValidateTexFunc(func_name, function_type, kSourceImageBitmap, target, 5404 if (!ValidateTexFunc(func_name, function_type, kSourceImageBitmap, target,
5405 level, internalformat, width, height, depth, 0, format, 5405 level, internalformat, width, height, depth, 0, format,
5406 type, xoffset, yoffset, zoffset)) 5406 type, xoffset, yoffset, zoffset))
5407 return; 5407 return;
5408 ASSERT(bitmap->BitmapImage()); 5408 DCHECK(bitmap->BitmapImage());
5409 5409
5410 // TODO(kbr): make this work for sub-rectangles of ImageBitmaps. 5410 // TODO(kbr): make this work for sub-rectangles of ImageBitmaps.
5411 if (function_id != kTexSubImage3D && function_id != kTexImage3D && 5411 if (function_id != kTexSubImage3D && function_id != kTexImage3D &&
5412 bitmap->IsAccelerated() && CanUseTexImageByGPU(format, type) && 5412 bitmap->IsAccelerated() && CanUseTexImageByGPU(format, type) &&
5413 !selecting_sub_rectangle) { 5413 !selecting_sub_rectangle) {
5414 if (function_id == kTexImage2D) { 5414 if (function_id == kTexImage2D) {
5415 TexImage2DBase(target, level, internalformat, width, height, 0, format, 5415 TexImage2DBase(target, level, internalformat, width, height, 0, format,
5416 type, 0); 5416 type, 0);
5417 TexImageByGPU(function_id, texture, target, level, 0, 0, 0, bitmap, 5417 TexImageByGPU(function_id, texture, target, level, 0, 0, 0, bitmap,
5418 source_sub_rect); 5418 source_sub_rect);
(...skipping 2036 matching lines...) Expand 10 before | Expand all | Expand 10 after
7455 EventTypeNames::webglcontextlost, false, true, ""); 7455 EventTypeNames::webglcontextlost, false, true, "");
7456 host()->HostDispatchEvent(event); 7456 host()->HostDispatchEvent(event);
7457 restore_allowed_ = event->defaultPrevented(); 7457 restore_allowed_ = event->defaultPrevented();
7458 if (restore_allowed_ && !is_hidden_) { 7458 if (restore_allowed_ && !is_hidden_) {
7459 if (auto_recovery_method_ == kAuto) 7459 if (auto_recovery_method_ == kAuto)
7460 restore_timer_.StartOneShot(0, BLINK_FROM_HERE); 7460 restore_timer_.StartOneShot(0, BLINK_FROM_HERE);
7461 } 7461 }
7462 } 7462 }
7463 7463
7464 void WebGLRenderingContextBase::MaybeRestoreContext(TimerBase*) { 7464 void WebGLRenderingContextBase::MaybeRestoreContext(TimerBase*) {
7465 ASSERT(isContextLost()); 7465 DCHECK(isContextLost());
7466 7466
7467 // The rendering context is not restored unless the default behavior of the 7467 // The rendering context is not restored unless the default behavior of the
7468 // webglcontextlost event was prevented earlier. 7468 // webglcontextlost event was prevented earlier.
7469 // 7469 //
7470 // Because of the way m_restoreTimer is set up for real vs. synthetic lost 7470 // Because of the way m_restoreTimer is set up for real vs. synthetic lost
7471 // context events, we don't have to worry about this test short-circuiting 7471 // context events, we don't have to worry about this test short-circuiting
7472 // the retry loop for real context lost events. 7472 // the retry loop for real context lost events.
7473 if (!restore_allowed_) 7473 if (!restore_allowed_)
7474 return; 7474 return;
7475 7475
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
7826 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( 7826 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(
7827 HTMLCanvasElementOrOffscreenCanvas& result) const { 7827 HTMLCanvasElementOrOffscreenCanvas& result) const {
7828 if (canvas()) { 7828 if (canvas()) {
7829 result.setHTMLCanvasElement(static_cast<HTMLCanvasElement*>(host())); 7829 result.setHTMLCanvasElement(static_cast<HTMLCanvasElement*>(host()));
7830 } else { 7830 } else {
7831 result.setOffscreenCanvas(static_cast<OffscreenCanvas*>(host())); 7831 result.setOffscreenCanvas(static_cast<OffscreenCanvas*>(host()));
7832 } 7832 }
7833 } 7833 }
7834 7834
7835 } // namespace blink 7835 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698