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

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
« no previous file with comments | « third_party/WebKit/Source/modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.idl ('k') | no next file » | 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 (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 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
1497 if (!marked_canvas_dirty_ && !must_clear_now) 1497 if (!marked_canvas_dirty_ && !must_clear_now)
1498 return false; 1498 return false;
1499 1499
1500 canvas()->ClearCopiedImage(); 1500 canvas()->ClearCopiedImage();
1501 marked_canvas_dirty_ = false; 1501 marked_canvas_dirty_ = false;
1502 1502
1503 if (!canvas()->Buffer()) 1503 if (!canvas()->GetOrCreateImageBuffer())
1504 return false; 1504 return false;
1505 1505
1506 ScopedTexture2DRestorer restorer(this); 1506 ScopedTexture2DRestorer restorer(this);
1507 ScopedFramebufferRestorer fbo_restorer(this); 1507 ScopedFramebufferRestorer fbo_restorer(this);
1508 1508
1509 GetDrawingBuffer()->ResolveAndBindForReadAndDraw(); 1509 GetDrawingBuffer()->ResolveAndBindForReadAndDraw();
1510 if (!canvas()->Buffer()->CopyRenderingResultsFromDrawingBuffer( 1510 if (!canvas()
1511 GetDrawingBuffer(), source_buffer)) { 1511 ->GetOrCreateImageBuffer()
1512 ->CopyRenderingResultsFromDrawingBuffer(GetDrawingBuffer(),
1513 source_buffer)) {
1512 // Currently, copyRenderingResultsFromDrawingBuffer is expected to always 1514 // Currently, copyRenderingResultsFromDrawingBuffer is expected to always
1513 // succeed because cases where canvas()-buffer() is not accelerated are 1515 // succeed because cases where canvas()-buffer() is not accelerated are
1514 // handle before reaching this point. If that assumption ever stops holding 1516 // handle before reaching this point. If that assumption ever stops holding
1515 // true, we may need to implement a fallback right here. 1517 // true, we may need to implement a fallback right here.
1516 NOTREACHED(); 1518 NOTREACHED();
1517 return false; 1519 return false;
1518 } 1520 }
1519 1521
1520 return true; 1522 return true;
1521 } 1523 }
(...skipping 3436 matching lines...) Expand 10 before | Expand all | Expand 10 after
4958 4960
4959 void WebGLRenderingContextBase::TexImageCanvasByGPU( 4961 void WebGLRenderingContextBase::TexImageCanvasByGPU(
4960 TexImageFunctionID function_id, 4962 TexImageFunctionID function_id,
4961 HTMLCanvasElement* canvas, 4963 HTMLCanvasElement* canvas,
4962 GLenum target, 4964 GLenum target,
4963 GLuint target_texture, 4965 GLuint target_texture,
4964 GLint xoffset, 4966 GLint xoffset,
4965 GLint yoffset, 4967 GLint yoffset,
4966 const IntRect& source_sub_rectangle) { 4968 const IntRect& source_sub_rectangle) {
4967 if (!canvas->Is3d()) { 4969 if (!canvas->Is3d()) {
4968 ImageBuffer* buffer = canvas->Buffer(); 4970 ImageBuffer* buffer = canvas->GetOrCreateImageBuffer();
4969 if (buffer && 4971 if (buffer &&
4970 !buffer->CopyToPlatformTexture( 4972 !buffer->CopyToPlatformTexture(
4971 FunctionIDToSnapshotReason(function_id), ContextGL(), target, 4973 FunctionIDToSnapshotReason(function_id), ContextGL(), target,
4972 target_texture, unpack_premultiply_alpha_, unpack_flip_y_, 4974 target_texture, unpack_premultiply_alpha_, unpack_flip_y_,
4973 IntPoint(xoffset, yoffset), source_sub_rectangle)) { 4975 IntPoint(xoffset, yoffset), source_sub_rectangle)) {
4974 NOTREACHED(); 4976 NOTREACHED();
4975 } 4977 }
4976 } else { 4978 } else {
4977 WebGLRenderingContextBase* gl = 4979 WebGLRenderingContextBase* gl =
4978 ToWebGLRenderingContextBase(canvas->RenderingContext()); 4980 ToWebGLRenderingContextBase(canvas->RenderingContext());
(...skipping 2845 matching lines...) Expand 10 before | Expand all | Expand 10 after
7824 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( 7826 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(
7825 HTMLCanvasElementOrOffscreenCanvas& result) const { 7827 HTMLCanvasElementOrOffscreenCanvas& result) const {
7826 if (canvas()) { 7828 if (canvas()) {
7827 result.setHTMLCanvasElement(static_cast<HTMLCanvasElement*>(host())); 7829 result.setHTMLCanvasElement(static_cast<HTMLCanvasElement*>(host()));
7828 } else { 7830 } else {
7829 result.setOffscreenCanvas(static_cast<OffscreenCanvas*>(host())); 7831 result.setOffscreenCanvas(static_cast<OffscreenCanvas*>(host()));
7830 } 7832 }
7831 } 7833 }
7832 7834
7833 } // namespace blink 7835 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698