Merge revision 643 and revision 648 changes:

- Improve the cefclient transparency test by adding the ability to view individual pixel values (issue #584).
- Change cefclient off-screen rendering example to account for premultiplied alpha values (issue #584).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@649 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-05-25 14:33:01 +00:00
parent 2bd2007fb9
commit 0bccf1bff2
5 changed files with 86 additions and 11 deletions

View File

@ -110,8 +110,8 @@ void ClientOSRenderer::Initialize() {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if (transparent_) {
// Alpha blending style.
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Alpha blending style. Texture values have premultiplied alpha.
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
initialized_ = true;
@ -355,6 +355,28 @@ void ClientOSRenderer::IncrementSpin(float spinDX, float spinDY) {
spin_y_ -= spinDY;
}
bool ClientOSRenderer::GetPixelValue(int x, int y, unsigned char& r,
unsigned char& g, unsigned char& b,
unsigned char& a) {
if (!view_buffer_)
return false;
ASSERT(x >= 0 && x < view_width_);
ASSERT(y >= 0 && y < view_height_);
int pixel_bytes = transparent_ ? 4 : 3;
int y_flipped = view_height_ - y;
int index = (view_width_ * y_flipped * pixel_bytes) + (x * pixel_bytes);
r = view_buffer_[index];
g = view_buffer_[index+1];
b = view_buffer_[index+2];
if (transparent_)
a = view_buffer_[index+3];
return true;
}
void ClientOSRenderer::SetBufferSize(int width, int height, bool view) {
int dst_size = width * height * (transparent_?4:3);