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

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

Issue 2849463005: Refactor ImageBuffer to make OffscreenCanvas match HTMLCanvasElement (Closed)
Patch Set: x 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 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 if (isContextLost()) 1492 if (isContextLost())
1493 return false; 1493 return false;
1494 1494
1495 bool must_clear_now = ClearIfComposited() != kSkipped; 1495 bool must_clear_now = ClearIfComposited() != kSkipped;
1496 if (!marked_canvas_dirty_ && !must_clear_now) 1496 if (!marked_canvas_dirty_ && !must_clear_now)
1497 return false; 1497 return false;
1498 1498
1499 canvas()->ClearCopiedImage(); 1499 canvas()->ClearCopiedImage();
1500 marked_canvas_dirty_ = false; 1500 marked_canvas_dirty_ = false;
1501 1501
1502 if (!canvas()->Buffer()) 1502 if (!canvas()->GetImageBuffer())
1503 return false; 1503 return false;
1504 1504
1505 ScopedTexture2DRestorer restorer(this); 1505 ScopedTexture2DRestorer restorer(this);
1506 ScopedFramebufferRestorer fbo_restorer(this); 1506 ScopedFramebufferRestorer fbo_restorer(this);
1507 1507
1508 GetDrawingBuffer()->ResolveAndBindForReadAndDraw(); 1508 GetDrawingBuffer()->ResolveAndBindForReadAndDraw();
1509 if (!canvas()->Buffer()->CopyRenderingResultsFromDrawingBuffer( 1509 if (!canvas()->GetImageBuffer()->CopyRenderingResultsFromDrawingBuffer(
1510 GetDrawingBuffer(), source_buffer)) { 1510 GetDrawingBuffer(), source_buffer)) {
1511 // Currently, copyRenderingResultsFromDrawingBuffer is expected to always 1511 // Currently, copyRenderingResultsFromDrawingBuffer is expected to always
1512 // succeed because cases where canvas()-buffer() is not accelerated are 1512 // succeed because cases where canvas()-buffer() is not accelerated are
1513 // handle before reaching this point. If that assumption ever stops holding 1513 // handle before reaching this point. If that assumption ever stops holding
1514 // true, we may need to implement a fallback right here. 1514 // true, we may need to implement a fallback right here.
1515 NOTREACHED(); 1515 NOTREACHED();
1516 return false; 1516 return false;
1517 } 1517 }
1518 1518
1519 return true; 1519 return true;
(...skipping 3437 matching lines...) Expand 10 before | Expand all | Expand 10 after
4957 4957
4958 void WebGLRenderingContextBase::TexImageCanvasByGPU( 4958 void WebGLRenderingContextBase::TexImageCanvasByGPU(
4959 TexImageFunctionID function_id, 4959 TexImageFunctionID function_id,
4960 HTMLCanvasElement* canvas, 4960 HTMLCanvasElement* canvas,
4961 GLenum target, 4961 GLenum target,
4962 GLuint target_texture, 4962 GLuint target_texture,
4963 GLint xoffset, 4963 GLint xoffset,
4964 GLint yoffset, 4964 GLint yoffset,
4965 const IntRect& source_sub_rectangle) { 4965 const IntRect& source_sub_rectangle) {
4966 if (!canvas->Is3d()) { 4966 if (!canvas->Is3d()) {
4967 ImageBuffer* buffer = canvas->Buffer(); 4967 ImageBuffer* buffer = canvas->GetImageBuffer();
4968 if (buffer && 4968 if (buffer &&
4969 !buffer->CopyToPlatformTexture( 4969 !buffer->CopyToPlatformTexture(
4970 FunctionIDToSnapshotReason(function_id), ContextGL(), target, 4970 FunctionIDToSnapshotReason(function_id), ContextGL(), target,
4971 target_texture, unpack_premultiply_alpha_, unpack_flip_y_, 4971 target_texture, unpack_premultiply_alpha_, unpack_flip_y_,
4972 IntPoint(xoffset, yoffset), source_sub_rectangle)) { 4972 IntPoint(xoffset, yoffset), source_sub_rectangle)) {
4973 NOTREACHED(); 4973 NOTREACHED();
4974 } 4974 }
4975 } else { 4975 } else {
4976 WebGLRenderingContextBase* gl = 4976 WebGLRenderingContextBase* gl =
4977 ToWebGLRenderingContextBase(canvas->RenderingContext()); 4977 ToWebGLRenderingContextBase(canvas->RenderingContext());
(...skipping 2845 matching lines...) Expand 10 before | Expand all | Expand 10 after
7823 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( 7823 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(
7824 HTMLCanvasElementOrOffscreenCanvas& result) const { 7824 HTMLCanvasElementOrOffscreenCanvas& result) const {
7825 if (canvas()) { 7825 if (canvas()) {
7826 result.setHTMLCanvasElement(static_cast<HTMLCanvasElement*>(host())); 7826 result.setHTMLCanvasElement(static_cast<HTMLCanvasElement*>(host()));
7827 } else { 7827 } else {
7828 result.setOffscreenCanvas(static_cast<OffscreenCanvas*>(host())); 7828 result.setOffscreenCanvas(static_cast<OffscreenCanvas*>(host()));
7829 } 7829 }
7830 } 7830 }
7831 7831
7832 } // namespace blink 7832 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698