OLD | NEW |
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 23 matching lines...) Expand all Loading... |
34 #include "core/dom/Fullscreen.h" | 34 #include "core/dom/Fullscreen.h" |
35 #include "core/dom/shadow/ShadowRoot.h" | 35 #include "core/dom/shadow/ShadowRoot.h" |
36 #include "core/frame/ImageBitmap.h" | 36 #include "core/frame/ImageBitmap.h" |
37 #include "core/frame/Settings.h" | 37 #include "core/frame/Settings.h" |
38 #include "core/html/parser/HTMLParserIdioms.h" | 38 #include "core/html/parser/HTMLParserIdioms.h" |
39 #include "core/imagebitmap/ImageBitmapOptions.h" | 39 #include "core/imagebitmap/ImageBitmapOptions.h" |
40 #include "core/layout/LayoutImage.h" | 40 #include "core/layout/LayoutImage.h" |
41 #include "core/layout/LayoutVideo.h" | 41 #include "core/layout/LayoutVideo.h" |
42 #include "platform/RuntimeEnabledFeatures.h" | 42 #include "platform/RuntimeEnabledFeatures.h" |
43 #include "platform/UserGestureIndicator.h" | 43 #include "platform/UserGestureIndicator.h" |
| 44 #include "platform/graphics/ColorSpaceFilter.h" |
| 45 #include "platform/graphics/ColorSpaceProfile.h" |
44 #include "platform/graphics/GraphicsContext.h" | 46 #include "platform/graphics/GraphicsContext.h" |
| 47 #include "platform/graphics/GraphicsScreen.h" |
45 #include "platform/graphics/ImageBuffer.h" | 48 #include "platform/graphics/ImageBuffer.h" |
46 #include "platform/graphics/gpu/Extensions3DUtil.h" | 49 #include "platform/graphics/gpu/Extensions3DUtil.h" |
47 #include "public/platform/WebCanvas.h" | 50 #include "public/platform/WebCanvas.h" |
48 #include "public/platform/WebGraphicsContext3D.h" | 51 #include "public/platform/WebGraphicsContext3D.h" |
49 | 52 |
50 namespace blink { | 53 namespace blink { |
51 | 54 |
52 using namespace HTMLNames; | 55 using namespace HTMLNames; |
53 | 56 |
54 inline HTMLVideoElement::HTMLVideoElement(Document& document) | 57 inline HTMLVideoElement::HTMLVideoElement(Document& document) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 } | 190 } |
188 | 191 |
189 void HTMLVideoElement::updateDisplayState() | 192 void HTMLVideoElement::updateDisplayState() |
190 { | 193 { |
191 if (posterImageURL().isEmpty()) | 194 if (posterImageURL().isEmpty()) |
192 setDisplayMode(Video); | 195 setDisplayMode(Video); |
193 else if (displayMode() < Poster) | 196 else if (displayMode() < Poster) |
194 setDisplayMode(Poster); | 197 setDisplayMode(Poster); |
195 } | 198 } |
196 | 199 |
197 void HTMLVideoElement::paintCurrentFrame(SkCanvas* canvas, const IntRect& destRe
ct, const SkPaint* paint) const | 200 void HTMLVideoElement::paintCurrentFrame(SkCanvas* canvas, const IntRect& destRe
ct, const SkPaint* paint, ColorSpaceProfile* target) const |
198 { | 201 { |
199 if (!webMediaPlayer()) | 202 if (!webMediaPlayer()) |
200 return; | 203 return; |
201 | 204 |
202 SkXfermode::Mode mode; | 205 SkXfermode::Mode mode; |
203 if (!paint || !SkXfermode::AsMode(paint->getXfermode(), &mode)) | 206 if (!paint || !SkXfermode::AsMode(paint->getXfermode(), &mode)) |
204 mode = SkXfermode::kSrcOver_Mode; | 207 mode = SkXfermode::kSrcOver_Mode; |
205 | 208 |
| 209 // FIXME: read the video color space from the video frame and use it as the
source color profile |
| 210 // rather than assuming an sRGB source as is done here. |
| 211 RefPtr<SkColorFilter> colorTransform; |
| 212 if (RefPtr<ColorSpaceProfile> targetProfile = target) { |
| 213 RefPtr<ColorSpaceProfile> sourceProfile = screenColorProfile(ScreenDevic
e::sRGB); |
| 214 colorTransform = createColorSpaceFilter(sourceProfile.get(), targetProfi
le.get()); |
| 215 } |
| 216 |
| 217 SkPictureRecorder recorder; |
| 218 IntRect sourceRect = IntRect(0, 0, videoWidth(), videoHeight()); |
| 219 SkCanvas* recordingCanvas = recorder.beginRecording(sourceRect); |
206 // TODO(junov, philipj): crbug.com/456529 Pass the whole SkPaint instead of
only alpha and xfermode | 220 // TODO(junov, philipj): crbug.com/456529 Pass the whole SkPaint instead of
only alpha and xfermode |
207 webMediaPlayer()->paint(canvas, destRect, paint ? paint->getAlpha() : 0xFF,
mode); | 221 // and maybe correctly handle the video source color profile as well. |
| 222 webMediaPlayer()->paint(recordingCanvas, sourceRect, 0xFF, SkXfermode::kSrc_
Mode); |
| 223 RefPtr<SkPicture> recorded = adoptRef(recorder.endRecording()); |
| 224 |
| 225 SkPaint transformPaint; |
| 226 transformPaint.setColorFilter(colorTransform.get()); |
| 227 transformPaint.setAlpha(paint ? paint->getAlpha() : 0xFF); |
| 228 transformPaint.setXfermodeMode(mode); |
| 229 transformPaint.setFilterQuality(kLow_SkFilterQuality); |
| 230 |
| 231 SkISize size = SkISize::Make(videoWidth(), videoHeight()); |
| 232 RefPtr<SkImage> image = adoptRef(SkImage::NewFromPicture(recorded.get(), siz
e, nullptr, nullptr)); |
| 233 canvas->drawImageRect(image.get(), SkIRect::MakeSize(size), destRect, &trans
formPaint); |
208 } | 234 } |
209 | 235 |
210 bool HTMLVideoElement::copyVideoTextureToPlatformTexture(WebGraphicsContext3D* c
ontext, Platform3DObject texture, GLenum internalFormat, GLenum type, bool premu
ltiplyAlpha, bool flipY) | 236 bool HTMLVideoElement::copyVideoTextureToPlatformTexture(WebGraphicsContext3D* c
ontext, Platform3DObject texture, GLenum internalFormat, GLenum type, bool premu
ltiplyAlpha, bool flipY) |
211 { | 237 { |
212 if (!webMediaPlayer()) | 238 if (!webMediaPlayer()) |
213 return false; | 239 return false; |
214 | 240 |
215 ASSERT(Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalFo
rmat, type, 0)); | 241 ASSERT(Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalFo
rmat, type, 0)); |
216 return webMediaPlayer()->copyVideoTextureToPlatformTexture(context, texture,
internalFormat, type, premultiplyAlpha, flipY); | 242 return webMediaPlayer()->copyVideoTextureToPlatformTexture(context, texture,
internalFormat, type, premultiplyAlpha, flipY); |
217 } | 243 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 } | 319 } |
294 | 320 |
295 IntSize intrinsicSize(videoWidth(), videoHeight()); | 321 IntSize intrinsicSize(videoWidth(), videoHeight()); |
296 // FIXME: Not sure if we dhould we be doing anything with the AccelerationHi
nt argument here? | 322 // FIXME: Not sure if we dhould we be doing anything with the AccelerationHi
nt argument here? |
297 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(intrinsicSize); | 323 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(intrinsicSize); |
298 if (!imageBuffer) { | 324 if (!imageBuffer) { |
299 *status = InvalidSourceImageStatus; | 325 *status = InvalidSourceImageStatus; |
300 return nullptr; | 326 return nullptr; |
301 } | 327 } |
302 | 328 |
303 paintCurrentFrame(imageBuffer->canvas(), IntRect(IntPoint(0, 0), intrinsicSi
ze), nullptr); | 329 paintCurrentFrame(imageBuffer->canvas(), IntRect(IntPoint(0, 0), intrinsicSi
ze), nullptr, nullptr); |
304 RefPtr<Image> snapshot = imageBuffer->newImageSnapshot(); | 330 RefPtr<Image> snapshot = imageBuffer->newImageSnapshot(); |
305 if (!snapshot) { | 331 if (!snapshot) { |
306 *status = InvalidSourceImageStatus; | 332 *status = InvalidSourceImageStatus; |
307 return nullptr; | 333 return nullptr; |
308 } | 334 } |
309 | 335 |
310 *status = NormalSourceImageStatus; | 336 *status = NormalSourceImageStatus; |
311 return snapshot.release(); | 337 return snapshot.release(); |
312 } | 338 } |
313 | 339 |
(...skipping 24 matching lines...) Expand all Loading... |
338 return ScriptPromise(); | 364 return ScriptPromise(); |
339 } | 365 } |
340 if (!sw || !sh) { | 366 if (!sw || !sh) { |
341 exceptionState.throwDOMException(IndexSizeError, String::format("The sou
rce %s provided is 0.", sw ? "height" : "width")); | 367 exceptionState.throwDOMException(IndexSizeError, String::format("The sou
rce %s provided is 0.", sw ? "height" : "width")); |
342 return ScriptPromise(); | 368 return ScriptPromise(); |
343 } | 369 } |
344 return ImageBitmapSource::fulfillImageBitmap(scriptState, ImageBitmap::creat
e(this, IntRect(sx, sy, sw, sh), eventTarget.toDOMWindow()->document(), options)
); | 370 return ImageBitmapSource::fulfillImageBitmap(scriptState, ImageBitmap::creat
e(this, IntRect(sx, sy, sw, sh), eventTarget.toDOMWindow()->document(), options)
); |
345 } | 371 } |
346 | 372 |
347 } // namespace blink | 373 } // namespace blink |
OLD | NEW |