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

Side by Side Diff: Source/platform/graphics/ImageBuffer.cpp

Issue 1288773005: 2D canvas: remain in deferred rendering mode with canvas to canvas drawImage (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add init of snapShot state Created 5 years, 4 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 | « Source/platform/graphics/ImageBuffer.h ('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) 2008, Google Inc. All rights reserved. 2 * Copyright (c) 2008, Google Inc. All rights reserved.
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 { 71 {
72 OwnPtr<ImageBufferSurface> surface(adoptPtr(new UnacceleratedImageBufferSurf ace(size, opacityMode))); 72 OwnPtr<ImageBufferSurface> surface(adoptPtr(new UnacceleratedImageBufferSurf ace(size, opacityMode)));
73 if (!surface->isValid()) 73 if (!surface->isValid())
74 return nullptr; 74 return nullptr;
75 return adoptPtr(new ImageBuffer(surface.release())); 75 return adoptPtr(new ImageBuffer(surface.release()));
76 } 76 }
77 77
78 ImageBuffer::ImageBuffer(PassOwnPtr<ImageBufferSurface> surface) 78 ImageBuffer::ImageBuffer(PassOwnPtr<ImageBufferSurface> surface)
79 : m_surface(surface) 79 : m_surface(surface)
80 , m_client(0) 80 , m_client(0)
81 , m_snapshotState(InitialSnapshotState)
81 { 82 {
82 m_surface->setImageBuffer(this); 83 m_surface->setImageBuffer(this);
83 } 84 }
84 85
85 ImageBuffer::~ImageBuffer() 86 ImageBuffer::~ImageBuffer()
86 { 87 {
87 } 88 }
88 89
89 SkCanvas* ImageBuffer::canvas() const 90 SkCanvas* ImageBuffer::canvas() const
90 { 91 {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 143 }
143 144
144 void ImageBuffer::resetCanvas(SkCanvas* canvas) const 145 void ImageBuffer::resetCanvas(SkCanvas* canvas) const
145 { 146 {
146 if (m_client) 147 if (m_client)
147 m_client->restoreCanvasMatrixClipStack(canvas); 148 m_client->restoreCanvasMatrixClipStack(canvas);
148 } 149 }
149 150
150 PassRefPtr<SkImage> ImageBuffer::newSkImageSnapshot() const 151 PassRefPtr<SkImage> ImageBuffer::newSkImageSnapshot() const
151 { 152 {
153 if (m_snapshotState == InitialSnapshotState)
154 m_snapshotState = DidAcquireSnapshot;
155
152 if (!isSurfaceValid()) 156 if (!isSurfaceValid())
153 return nullptr; 157 return nullptr;
154 return m_surface->newImageSnapshot(); 158 return m_surface->newImageSnapshot();
155 } 159 }
156 160
157 PassRefPtr<Image> ImageBuffer::newImageSnapshot() const 161 PassRefPtr<Image> ImageBuffer::newImageSnapshot() const
158 { 162 {
159 if (!isSurfaceValid()) 163 RefPtr<SkImage> snapshot = newSkImageSnapshot();
160 return nullptr;
161 RefPtr<SkImage> snapshot = m_surface->newImageSnapshot();
162 if (!snapshot) 164 if (!snapshot)
163 return nullptr; 165 return nullptr;
164 return StaticBitmapImage::create(snapshot); 166 return StaticBitmapImage::create(snapshot);
165 } 167 }
166 168
169 void ImageBuffer::didDraw(const FloatRect& rect) const
170 {
171 if (m_snapshotState == DidAcquireSnapshot)
172 m_snapshotState = DrawnToAfterSnapshot;
173 m_surface->didDraw(rect);
174 }
175
167 WebLayer* ImageBuffer::platformLayer() const 176 WebLayer* ImageBuffer::platformLayer() const
168 { 177 {
169 return m_surface->layer(); 178 return m_surface->layer();
170 } 179 }
171 180
172 bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3 DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premu ltiplyAlpha, bool flipY) 181 bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3 DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premu ltiplyAlpha, bool flipY)
173 { 182 {
174 if (!m_surface->isAccelerated() || !isSurfaceValid()) 183 if (!m_surface->isAccelerated() || !isSurfaceValid())
175 return false; 184 return false;
176 185
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); 371 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
363 372
364 Vector<char> encodedImage; 373 Vector<char> encodedImage;
365 if (!encodeImage(*this, mimeType, quality, &encodedImage)) 374 if (!encodeImage(*this, mimeType, quality, &encodedImage))
366 return "data:,"; 375 return "data:,";
367 376
368 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); 377 return "data:" + mimeType + ";base64," + base64Encode(encodedImage);
369 } 378 }
370 379
371 } // namespace blink 380 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/ImageBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698