OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/backing_store_gtk.h" | 5 #include "content/browser/renderer_host/backing_store_gtk.h" |
6 | 6 |
7 #include <cairo-xlib.h> | 7 #include <cairo-xlib.h> |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <sys/ipc.h> | 10 #include <sys/ipc.h> |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 return false; | 512 return false; |
513 } | 513 } |
514 // Create the shared memory segment for the image and map it. | 514 // Create the shared memory segment for the image and map it. |
515 if (image->bytes_per_line == 0 || image->height == 0 || | 515 if (image->bytes_per_line == 0 || image->height == 0 || |
516 static_cast<size_t>(image->height) > | 516 static_cast<size_t>(image->height) > |
517 (std::numeric_limits<size_t>::max() / image->bytes_per_line)) { | 517 (std::numeric_limits<size_t>::max() / image->bytes_per_line)) { |
518 XDestroyImage(image); | 518 XDestroyImage(image); |
519 return false; | 519 return false; |
520 } | 520 } |
521 shminfo.shmid = shmget(IPC_PRIVATE, image->bytes_per_line * image->height, | 521 shminfo.shmid = shmget(IPC_PRIVATE, image->bytes_per_line * image->height, |
522 IPC_CREAT|0666); | 522 IPC_CREAT|0600); |
523 if (shminfo.shmid == -1) { | 523 if (shminfo.shmid == -1) { |
524 XDestroyImage(image); | 524 XDestroyImage(image); |
525 LOG(WARNING) << "Failed to get shared memory segment. " | |
Daniel Erat
2012/09/13 22:04:39
How frequently can this be logged?
palmer
2012/09/24 16:26:11
This one, once. Some of the other logging statemen
| |
526 "Performance may be degraded."; | |
525 return false; | 527 return false; |
528 } else { | |
529 VLOG(1) << "Got shared memory segment " << shminfo.shmid; | |
526 } | 530 } |
527 | 531 |
528 void* mapped_memory = shmat(shminfo.shmid, NULL, SHM_RDONLY); | 532 void* mapped_memory = shmat(shminfo.shmid, NULL, SHM_RDONLY); |
529 shmctl(shminfo.shmid, IPC_RMID, 0); | 533 shmctl(shminfo.shmid, IPC_RMID, 0); |
530 if (mapped_memory == (void*)-1) { | 534 if (mapped_memory == (void*)-1) { |
531 XDestroyImage(image); | 535 XDestroyImage(image); |
532 return false; | 536 return false; |
533 } | 537 } |
534 shminfo.shmaddr = image->data = static_cast<char*>(mapped_memory); | 538 shminfo.shmaddr = image->data = static_cast<char*>(mapped_memory); |
535 | 539 |
536 if (!XShmAttach(display_, &shminfo) || | 540 if (!XShmAttach(display_, &shminfo) || |
537 !XShmGetImage(display_, pixmap_, image, rect.x(), rect.y(), | 541 !XShmGetImage(display_, pixmap_, image, rect.x(), rect.y(), |
538 AllPlanes)) { | 542 AllPlanes)) { |
539 DestroySharedImage(display_, image, &shminfo); | 543 DestroySharedImage(display_, image, &shminfo); |
544 LOG(WARNING) << "X failed to get shared memory segment. " | |
545 "Performance may be degraded."; | |
540 return false; | 546 return false; |
541 } | 547 } |
548 | |
549 VLOG(1) << "Using X shared memory segment " << shminfo.shmid; | |
542 } else { | 550 } else { |
551 LOG(WARNING) << "Not using X shared memory."; | |
543 // Non-shared memory case just copy the image from the server. | 552 // Non-shared memory case just copy the image from the server. |
544 image = XGetImage(display_, pixmap_, | 553 image = XGetImage(display_, pixmap_, |
545 rect.x(), rect.y(), width, height, | 554 rect.x(), rect.y(), width, height, |
546 AllPlanes, ZPixmap); | 555 AllPlanes, ZPixmap); |
547 } | 556 } |
548 | 557 |
549 // TODO(jhawkins): Need to convert the image data if the image bits per pixel | 558 // TODO(jhawkins): Need to convert the image data if the image bits per pixel |
550 // is not 32. | 559 // is not 32. |
551 // Note that this also initializes the output bitmap as opaque. | 560 // Note that this also initializes the output bitmap as opaque. |
552 if (!output->initialize(width, height, true) || | 561 if (!output->initialize(width, height, true) || |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
659 | 668 |
660 cairo_identity_matrix(cr); | 669 cairo_identity_matrix(cr); |
661 | 670 |
662 cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height()); | 671 cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height()); |
663 cairo_fill(cr); | 672 cairo_fill(cr); |
664 cairo_destroy(cr); | 673 cairo_destroy(cr); |
665 } | 674 } |
666 #endif | 675 #endif |
667 | 676 |
668 } // namespace content | 677 } // namespace content |
OLD | NEW |