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

Side by Side Diff: Source/core/frame/ImageBitmap.cpp

Issue 1170523002: Removing GraphicsContext from ImageBuffer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix unit test crashes Created 5 years, 6 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
« no previous file with comments | « no previous file | Source/core/frame/LocalFrame.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/frame/ImageBitmap.h" 6 #include "core/frame/ImageBitmap.h"
7 7
8 #include "core/html/HTMLCanvasElement.h" 8 #include "core/html/HTMLCanvasElement.h"
9 #include "core/html/HTMLVideoElement.h" 9 #include "core/html/HTMLVideoElement.h"
10 #include "core/html/ImageData.h" 10 #include "core/html/ImageData.h"
11 #include "platform/graphics/BitmapImage.h" 11 #include "platform/graphics/BitmapImage.h"
12 #include "platform/graphics/GraphicsContext.h" 12 #include "platform/graphics/GraphicsContext.h"
13 #include "platform/graphics/ImageBuffer.h" 13 #include "platform/graphics/ImageBuffer.h"
14 #include "platform/graphics/paint/DisplayItemListContextRecorder.h"
15 #include "platform/graphics/paint/DrawingRecorder.h" 14 #include "platform/graphics/paint/DrawingRecorder.h"
15 #include "platform/graphics/paint/SkPictureBuilder.h"
16 #include "wtf/RefPtr.h" 16 #include "wtf/RefPtr.h"
17 17
18 namespace blink { 18 namespace blink {
19 19
20 static inline IntRect normalizeRect(const IntRect& rect) 20 static inline IntRect normalizeRect(const IntRect& rect)
21 { 21 {
22 return IntRect(std::min(rect.x(), rect.maxX()), 22 return IntRect(std::min(rect.x(), rect.maxX()),
23 std::min(rect.y(), rect.maxY()), 23 std::min(rect.y(), rect.maxY()),
24 std::max(rect.width(), -rect.width()), 24 std::max(rect.width(), -rect.width()),
25 std::max(rect.height(), -rect.height())); 25 std::max(rect.height(), -rect.height()));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 playerSize = video->webMediaPlayer()->naturalSize(); 66 playerSize = video->webMediaPlayer()->naturalSize();
67 67
68 IntRect videoRect = IntRect(IntPoint(), playerSize); 68 IntRect videoRect = IntRect(IntPoint(), playerSize);
69 IntRect srcRect = intersection(cropRect, videoRect); 69 IntRect srcRect = intersection(cropRect, videoRect);
70 IntRect dstRect(IntPoint(), srcRect.size()); 70 IntRect dstRect(IntPoint(), srcRect.size());
71 71
72 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(videoRect.size()); 72 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(videoRect.size());
73 if (!buffer) 73 if (!buffer)
74 return; 74 return;
75 75
76 SkPictureBuilder pictureBuilder(videoRect);
76 { 77 {
77 DisplayItemListContextRecorder contextRecorder(*buffer->context()); 78 GraphicsContext& paintContext = pictureBuilder.context();
78 GraphicsContext& paintContext = contextRecorder.context();
79 79
80 DrawingRecorder recorder(paintContext, *buffer, DisplayItem::VideoBitmap , videoRect); 80 DrawingRecorder recorder(paintContext, *buffer, DisplayItem::VideoBitmap , videoRect);
81 if (!recorder.canUseCachedDrawing()) { 81 if (!recorder.canUseCachedDrawing()) {
82 paintContext.clip(dstRect); 82 paintContext.clip(dstRect);
83 paintContext.translate(-srcRect.x(), -srcRect.y()); 83 paintContext.translate(-srcRect.x(), -srcRect.y());
84 } 84 }
85 } 85 }
86 RefPtr<const SkPicture> recording = pictureBuilder.endRecording();
87 buffer->canvas()->drawPicture(recording.get());
Stephen White 2015/06/04 18:33:10 chrishtr@: Not new to this patch, but why are we g
chrishtr 2015/06/04 19:58:00 Agree that this looks wrong and we should just dra
86 88
87 video->paintCurrentFrame(buffer->canvas(), videoRect, nullptr); 89 video->paintCurrentFrame(buffer->canvas(), videoRect, nullptr);
88 m_bitmap = buffer->copyImage(DontCopyBackingStore); 90 m_bitmap = buffer->copyImage(DontCopyBackingStore);
89 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro pRect.y())), srcRect.size()); 91 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro pRect.y())), srcRect.size());
90 } 92 }
91 93
92 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect) 94 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect)
93 : m_imageElement(nullptr) 95 : m_imageElement(nullptr)
94 , m_cropRect(cropRect) 96 , m_cropRect(cropRect)
95 , m_bitmapOffset(IntPoint()) 97 , m_bitmapOffset(IntPoint())
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 return FloatSize(width(), height()); 230 return FloatSize(width(), height());
229 } 231 }
230 232
231 DEFINE_TRACE(ImageBitmap) 233 DEFINE_TRACE(ImageBitmap)
232 { 234 {
233 visitor->trace(m_imageElement); 235 visitor->trace(m_imageElement);
234 ImageLoaderClient::trace(visitor); 236 ImageLoaderClient::trace(visitor);
235 } 237 }
236 238
237 } // namespace blink 239 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/core/frame/LocalFrame.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698