summaryrefslogtreecommitdiffstats
path: root/o3d/core/cross/gl
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-08 19:50:29 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-08 19:50:29 +0000
commit16f5c4de8b926dc889859cfff03c9328edb60a5c (patch)
treec6d7a6f51973164ae28ff3157f0cf6356736c1d7 /o3d/core/cross/gl
parentc890e98205d97b57534f2eac00618a2864d61bb5 (diff)
downloadchromium_src-16f5c4de8b926dc889859cfff03c9328edb60a5c.zip
chromium_src-16f5c4de8b926dc889859cfff03c9328edb60a5c.tar.gz
chromium_src-16f5c4de8b926dc889859cfff03c9328edb60a5c.tar.bz2
This CL adds client.toDataURL which gets the contents
of the client area as a data url (which is a base64 encoded string of a png file) data urls are part of the HTML5 standard and supported by firefox, safari and chrome. http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-canvas-todataurl That means you can now do this var dataURL = client.toDataURL(); // make an IMG tag display the screenshot someImgTag.src = dataURL; // use the IMG tag to draw into a canvas someCanvasContext.drawImage(someImageTag, ...); It also means there is no need for the test builds anymore "test-dbg-d3d", "test-opt-d3d" etc as toDataURL is part of the public API and can therefore always be used to take screenshots in any build. I updated the selenium code to use it. There are a few issues: 1) The GL version has the same limitations as taking a screenshot before. Namely that the client area must be on screen. We need to fix this. 2) We need to add support for origin-clean. See https://tracker.corp.google.com/story/show/180334 Review URL: http://codereview.chromium.org/164130 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22869 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/core/cross/gl')
-rw-r--r--o3d/core/cross/gl/renderer_gl.cc16
-rw-r--r--o3d/core/cross/gl/renderer_gl.h5
-rw-r--r--o3d/core/cross/gl/texture_gl.h6
-rw-r--r--o3d/core/cross/gl/utils_gl.h6
4 files changed, 10 insertions, 23 deletions
diff --git a/o3d/core/cross/gl/renderer_gl.cc b/o3d/core/cross/gl/renderer_gl.cc
index c22cda3..4a8b215 100644
--- a/o3d/core/cross/gl/renderer_gl.cc
+++ b/o3d/core/cross/gl/renderer_gl.cc
@@ -1560,10 +1560,7 @@ RenderDepthStencilSurface::Ref RendererGL::CreateDepthStencilSurface(
height));
}
-// Saves a png screenshot 'file_name.png'.
-// Returns true on success and false on failure.
-bool RendererGL::SaveScreen(const String& file_name) {
-#ifdef TESTING
+Bitmap::Ref RendererGL::TakeScreenshot() {;
MakeCurrentLazy();
Bitmap::Ref bitmap = Bitmap::Ref(new Bitmap(service_locator()));
bitmap->Allocate(Texture::ARGB8, width(), height(), 1, false);
@@ -1574,16 +1571,7 @@ bool RendererGL::SaveScreen(const String& file_name) {
// might exhibit suprise translucency.
::glReadPixels(0, 0, width(), height(), GL_BGRA, GL_UNSIGNED_BYTE,
bitmap->image_data());
- bool result = bitmap->SaveToPNGFile((file_name + ".png").c_str());
- if (!result) {
- O3D_ERROR(service_locator())
- << "Failed to save screen into " << file_name;
- }
- return result;
-#else
- // Not a test build, always return false.
- return false;
-#endif
+ return bitmap;
}
const int* RendererGL::GetRGBAUByteNSwizzleTable() {
diff --git a/o3d/core/cross/gl/renderer_gl.h b/o3d/core/cross/gl/renderer_gl.h
index 24d8d01..534ea9c 100644
--- a/o3d/core/cross/gl/renderer_gl.h
+++ b/o3d/core/cross/gl/renderer_gl.h
@@ -144,9 +144,8 @@ class RendererGL : public Renderer {
int width,
int height);
- // Saves a png screenshot 'file_name.png'.
- // Returns true on success and false on failure.
- virtual bool SaveScreen(const String& file_name);
+ // Overridden from Renderer.
+ virtual Bitmap::Ref TakeScreenshot();
// Overridden from Renderer.
virtual const int* GetRGBAUByteNSwizzleTable();
diff --git a/o3d/core/cross/gl/texture_gl.h b/o3d/core/cross/gl/texture_gl.h
index 6b97b7f..567bf2b 100644
--- a/o3d/core/cross/gl/texture_gl.h
+++ b/o3d/core/cross/gl/texture_gl.h
@@ -32,8 +32,8 @@
// This file contains the declarations for Texture2DGL and TextureCUBEGL.
-#ifndef O3D_CORE_CROSS_GL_TEXTURE_GL_H__
-#define O3D_CORE_CROSS_GL_TEXTURE_GL_H__
+#ifndef O3D_CORE_CROSS_GL_TEXTURE_GL_H_
+#define O3D_CORE_CROSS_GL_TEXTURE_GL_H_
// Precompiled header comes before everything else.
#include "core/cross/precompile.h"
@@ -235,4 +235,4 @@ class TextureCUBEGL : public TextureCUBE {
} // namespace o3d
-#endif // O3D_CORE_CROSS_GL_TEXTURE_GL_H__
+#endif // O3D_CORE_CROSS_GL_TEXTURE_GL_H_
diff --git a/o3d/core/cross/gl/utils_gl.h b/o3d/core/cross/gl/utils_gl.h
index b6b87ff..a7af934 100644
--- a/o3d/core/cross/gl/utils_gl.h
+++ b/o3d/core/cross/gl/utils_gl.h
@@ -30,8 +30,8 @@
*/
-#ifndef O3D_CORE_CROSS_GL_UTILS_GL_H__
-#define O3D_CORE_CROSS_GL_UTILS_GL_H__
+#ifndef O3D_CORE_CROSS_GL_UTILS_GL_H_
+#define O3D_CORE_CROSS_GL_UTILS_GL_H_
#include "base/basictypes.h"
#include "core/cross/stream.h"
@@ -44,4 +44,4 @@ Stream::Semantic GLVertexAttributeToStream(const unsigned int attr, int *index);
} // namespace o3d
-#endif // O3D_CORE_CROSS_GL_UTILS_GL_H__
+#endif // O3D_CORE_CROSS_GL_UTILS_GL_H_