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

Side by Side Diff: core/cross/gl/renderer_gl.cc

Issue 164130: This CL adds client.toDataURL which gets the contents... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 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 | « core/cross/gl/renderer_gl.h ('k') | core/cross/image_utils.h » ('j') | 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 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 1553
1554 RenderDepthStencilSurface::Ref RendererGL::CreateDepthStencilSurface( 1554 RenderDepthStencilSurface::Ref RendererGL::CreateDepthStencilSurface(
1555 int width, 1555 int width,
1556 int height) { 1556 int height) {
1557 return RenderDepthStencilSurface::Ref( 1557 return RenderDepthStencilSurface::Ref(
1558 new RenderDepthStencilSurfaceGL(service_locator(), 1558 new RenderDepthStencilSurfaceGL(service_locator(),
1559 width, 1559 width,
1560 height)); 1560 height));
1561 } 1561 }
1562 1562
1563 // Saves a png screenshot 'file_name.png'. 1563 Bitmap::Ref RendererGL::TakeScreenshot() {;
1564 // Returns true on success and false on failure.
1565 bool RendererGL::SaveScreen(const String& file_name) {
1566 #ifdef TESTING
1567 MakeCurrentLazy(); 1564 MakeCurrentLazy();
1568 Bitmap::Ref bitmap = Bitmap::Ref(new Bitmap(service_locator())); 1565 Bitmap::Ref bitmap = Bitmap::Ref(new Bitmap(service_locator()));
1569 bitmap->Allocate(Texture::ARGB8, width(), height(), 1, false); 1566 bitmap->Allocate(Texture::ARGB8, width(), height(), 1, false);
1570 1567
1571 // Note: glReadPixels captures the alpha component of the frame buffer as well 1568 // Note: glReadPixels captures the alpha component of the frame buffer as well
1572 // as the color components, the browser usually ignores the alpha channel when 1569 // as the color components, the browser usually ignores the alpha channel when
1573 // drawing to the screen, so unless the alpha is 1, the png image generated 1570 // drawing to the screen, so unless the alpha is 1, the png image generated
1574 // might exhibit suprise translucency. 1571 // might exhibit suprise translucency.
1575 ::glReadPixels(0, 0, width(), height(), GL_BGRA, GL_UNSIGNED_BYTE, 1572 ::glReadPixels(0, 0, width(), height(), GL_BGRA, GL_UNSIGNED_BYTE,
1576 bitmap->image_data()); 1573 bitmap->image_data());
1577 bool result = bitmap->SaveToPNGFile((file_name + ".png").c_str()); 1574 return bitmap;
1578 if (!result) {
1579 O3D_ERROR(service_locator())
1580 << "Failed to save screen into " << file_name;
1581 }
1582 return result;
1583 #else
1584 // Not a test build, always return false.
1585 return false;
1586 #endif
1587 } 1575 }
1588 1576
1589 const int* RendererGL::GetRGBAUByteNSwizzleTable() { 1577 const int* RendererGL::GetRGBAUByteNSwizzleTable() {
1590 static int swizzle_table[] = { 0, 1, 2, 3, }; 1578 static int swizzle_table[] = { 0, 1, 2, 3, };
1591 return swizzle_table; 1579 return swizzle_table;
1592 } 1580 }
1593 1581
1594 // This is a factory function for creating Renderer objects. Since 1582 // This is a factory function for creating Renderer objects. Since
1595 // we're implementing GL, we only ever return a GL renderer. 1583 // we're implementing GL, we only ever return a GL renderer.
1596 Renderer* Renderer::CreateDefaultRenderer(ServiceLocator* service_locator) { 1584 Renderer* Renderer::CreateDefaultRenderer(ServiceLocator* service_locator) {
1597 return RendererGL::CreateDefault(service_locator); 1585 return RendererGL::CreateDefault(service_locator);
1598 } 1586 }
1599 1587
1600 } // namespace o3d 1588 } // namespace o3d
OLDNEW
« no previous file with comments | « core/cross/gl/renderer_gl.h ('k') | core/cross/image_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698