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

Side by Side Diff: Source/core/html/HTMLVideoElement.cpp

Issue 181693006: Refactoring source image usage in CanvasRenderingContext2D (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010 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 15 matching lines...) Expand all
26 #include "config.h" 26 #include "config.h"
27 #include "core/html/HTMLVideoElement.h" 27 #include "core/html/HTMLVideoElement.h"
28 28
29 #include "CSSPropertyNames.h" 29 #include "CSSPropertyNames.h"
30 #include "HTMLNames.h" 30 #include "HTMLNames.h"
31 #include "bindings/v8/ExceptionState.h" 31 #include "bindings/v8/ExceptionState.h"
32 #include "core/dom/Attribute.h" 32 #include "core/dom/Attribute.h"
33 #include "core/dom/Document.h" 33 #include "core/dom/Document.h"
34 #include "core/dom/ExceptionCode.h" 34 #include "core/dom/ExceptionCode.h"
35 #include "core/html/HTMLImageLoader.h" 35 #include "core/html/HTMLImageLoader.h"
36 #include "core/html/canvas/CanvasRenderingContext.h"
36 #include "core/html/parser/HTMLParserIdioms.h" 37 #include "core/html/parser/HTMLParserIdioms.h"
37 #include "core/frame/Settings.h" 38 #include "core/frame/Settings.h"
38 #include "core/rendering/RenderImage.h" 39 #include "core/rendering/RenderImage.h"
39 #include "core/rendering/RenderVideo.h" 40 #include "core/rendering/RenderVideo.h"
40 #include "platform/UserGestureIndicator.h" 41 #include "platform/UserGestureIndicator.h"
41 42
42 namespace WebCore { 43 namespace WebCore {
43 44
44 using namespace HTMLNames; 45 using namespace HTMLNames;
45 46
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 167 }
167 168
168 void HTMLVideoElement::updateDisplayState() 169 void HTMLVideoElement::updateDisplayState()
169 { 170 {
170 if (posterImageURL().isEmpty()) 171 if (posterImageURL().isEmpty())
171 setDisplayMode(Video); 172 setDisplayMode(Video);
172 else if (displayMode() < Poster) 173 else if (displayMode() < Poster)
173 setDisplayMode(Poster); 174 setDisplayMode(Poster);
174 } 175 }
175 176
176 void HTMLVideoElement::paintCurrentFrameInContext(GraphicsContext* context, cons t IntRect& destRect) 177 void HTMLVideoElement::paintCurrentFrameInContext(GraphicsContext* context, cons t IntRect& destRect) const
177 { 178 {
178 MediaPlayer* player = HTMLMediaElement::player(); 179 MediaPlayer* player = HTMLMediaElement::player();
179 if (!player) 180 if (!player)
180 return; 181 return;
181 player->paint(context, destRect); 182 player->paint(context, destRect);
182 } 183 }
183 184
184 bool HTMLVideoElement::copyVideoTextureToPlatformTexture(blink::WebGraphicsConte xt3D* context, Platform3DObject texture, GLint level, GLenum type, GLenum intern alFormat, bool premultiplyAlpha, bool flipY) 185 bool HTMLVideoElement::copyVideoTextureToPlatformTexture(blink::WebGraphicsConte xt3D* context, Platform3DObject texture, GLint level, GLenum type, GLenum intern alFormat, bool premultiplyAlpha, bool flipY)
185 { 186 {
186 if (!player()) 187 if (!player())
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 if (url.isEmpty()) 226 if (url.isEmpty())
226 return KURL(); 227 return KURL();
227 return document().completeURL(url); 228 return document().completeURL(url);
228 } 229 }
229 230
230 KURL HTMLVideoElement::mediaPlayerPosterURL() 231 KURL HTMLVideoElement::mediaPlayerPosterURL()
231 { 232 {
232 return posterImageURL(); 233 return posterImageURL();
233 } 234 }
234 235
236 PassRefPtr<Image> HTMLVideoElement::getSourceImageForCanvas(HTMLCanvasElement* c anvas, ExceptionState& exceptionState, CanvasImageSourceUsage usage, bool* isVol atile) const
237 {
238 ASSERT(usage != DrawCanvasImageSourceUsage); // Drawing should use paintCurr entFrameInContext
239 if (isVolatile)
240 *isVolatile = false;
241 if (!hasAvailableVideoFrame())
242 return nullptr;
243
244 IntSize intrinsicSize(videoWidth(), videoHeight());
245 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(intrinsicSize);
246 if (!imageBuffer)
247 return nullptr;
248
249 paintCurrentFrameInContext(imageBuffer->context(), IntRect(IntPoint(0, 0), i ntrinsicSize));
250
251 return imageBuffer->copyImage(imageBuffer->fastCopyImageMode(), Unscaled);
235 } 252 }
253
254 bool HTMLVideoElement::wouldTaintOrigin(CanvasRenderingContext* destinationConte xt) const
255 {
256 return !hasSingleSecurityOrigin() || (!(player() && player()->didPassCORSAcc essCheck()) && destinationContext->wouldTaintOrigin(currentSrc()));
257 }
258
259 FloatSize HTMLVideoElement::sourceSize() const
260 {
261 return FloatSize(videoWidth(), videoHeight());
262 }
263
264 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698