| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 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 | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 : HTMLElement(canvasTag, document) | 80 : HTMLElement(canvasTag, document) |
| 81 , DocumentVisibilityObserver(document) | 81 , DocumentVisibilityObserver(document) |
| 82 , m_size(DefaultWidth, DefaultHeight) | 82 , m_size(DefaultWidth, DefaultHeight) |
| 83 , m_ignoreReset(false) | 83 , m_ignoreReset(false) |
| 84 , m_accelerationDisabled(false) | 84 , m_accelerationDisabled(false) |
| 85 , m_externallyAllocatedMemory(0) | 85 , m_externallyAllocatedMemory(0) |
| 86 , m_originClean(true) | 86 , m_originClean(true) |
| 87 , m_didFailToCreateImageBuffer(false) | 87 , m_didFailToCreateImageBuffer(false) |
| 88 , m_didClearImageBuffer(false) | 88 , m_didClearImageBuffer(false) |
| 89 { | 89 { |
| 90 setHasCustomStyleCallbacks(); |
| 90 } | 91 } |
| 91 | 92 |
| 92 DEFINE_NODE_FACTORY(HTMLCanvasElement) | 93 DEFINE_NODE_FACTORY(HTMLCanvasElement) |
| 93 | 94 |
| 94 HTMLCanvasElement::~HTMLCanvasElement() | 95 HTMLCanvasElement::~HTMLCanvasElement() |
| 95 { | 96 { |
| 96 resetDirtyRect(); | 97 resetDirtyRect(); |
| 97 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_external
lyAllocatedMemory); | 98 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_external
lyAllocatedMemory); |
| 98 #if !ENABLE(OILPAN) | 99 #if !ENABLE(OILPAN) |
| 99 HashSet<RawPtr<CanvasObserver> >::iterator end = m_observers.end(); | 100 HashSet<RawPtr<CanvasObserver> >::iterator end = m_observers.end(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 113 } | 114 } |
| 114 | 115 |
| 115 RenderObject* HTMLCanvasElement::createRenderer(RenderStyle* style) | 116 RenderObject* HTMLCanvasElement::createRenderer(RenderStyle* style) |
| 116 { | 117 { |
| 117 LocalFrame* frame = document().frame(); | 118 LocalFrame* frame = document().frame(); |
| 118 if (frame && frame->script().canExecuteScripts(NotAboutToExecuteScript)) | 119 if (frame && frame->script().canExecuteScripts(NotAboutToExecuteScript)) |
| 119 return new RenderHTMLCanvas(this); | 120 return new RenderHTMLCanvas(this); |
| 120 return HTMLElement::createRenderer(style); | 121 return HTMLElement::createRenderer(style); |
| 121 } | 122 } |
| 122 | 123 |
| 124 void HTMLCanvasElement::didRecalcStyle(StyleRecalcChange) |
| 125 { |
| 126 //printf("HTMLCanvasElement::didRecalcStyle\n"); |
| 127 if (!hasImageBuffer()) |
| 128 return; |
| 129 //printf("HTMLCanvasElement::didRecalcStyle hasImageBuffer\n"); |
| 130 m_imageBuffer->setFilterLevel(computedStyle()->imageRendering() == ImageRend
eringPixelated ? SkPaint::kNone_FilterLevel : SkPaint::kLow_FilterLevel); |
| 131 } |
| 132 |
| 123 Node::InsertionNotificationRequest HTMLCanvasElement::insertedInto(ContainerNode
* node) | 133 Node::InsertionNotificationRequest HTMLCanvasElement::insertedInto(ContainerNode
* node) |
| 124 { | 134 { |
| 125 setIsInCanvasSubtree(true); | 135 setIsInCanvasSubtree(true); |
| 126 return HTMLElement::insertedInto(node); | 136 return HTMLElement::insertedInto(node); |
| 127 } | 137 } |
| 128 | 138 |
| 129 void HTMLCanvasElement::addObserver(CanvasObserver* observer) | 139 void HTMLCanvasElement::addObserver(CanvasObserver* observer) |
| 130 { | 140 { |
| 131 m_observers.add(observer); | 141 m_observers.add(observer); |
| 132 } | 142 } |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 // pixel readback, but that is unavoidable in this case. | 537 // pixel readback, but that is unavoidable in this case. |
| 528 // FIXME: Actually, avoid setting m_accelerationDisabled at all when | 538 // FIXME: Actually, avoid setting m_accelerationDisabled at all when |
| 529 // doing GPU-based rasterization. | 539 // doing GPU-based rasterization. |
| 530 if (m_accelerationDisabled) | 540 if (m_accelerationDisabled) |
| 531 return adoptPtr(new UnacceleratedImageBufferSurface(deviceSize, opac
ityMode)); | 541 return adoptPtr(new UnacceleratedImageBufferSurface(deviceSize, opac
ityMode)); |
| 532 return adoptPtr(new WebGLImageBufferSurface(deviceSize, opacityMode)); | 542 return adoptPtr(new WebGLImageBufferSurface(deviceSize, opacityMode)); |
| 533 } | 543 } |
| 534 | 544 |
| 535 OwnPtr<RecordingImageBufferFallbackSurfaceFactory> surfaceFactory = createSu
rfaceFactory(deviceSize, msaaSampleCount); | 545 OwnPtr<RecordingImageBufferFallbackSurfaceFactory> surfaceFactory = createSu
rfaceFactory(deviceSize, msaaSampleCount); |
| 536 | 546 |
| 537 if (RuntimeEnabledFeatures::displayList2dCanvasEnabled()) { | 547 if (RuntimeEnabledFeatures::displayList2dCanvasEnabled() && false) { |
| 538 OwnPtr<ImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSu
rface(deviceSize, surfaceFactory.release(), opacityMode)); | 548 OwnPtr<ImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSu
rface(deviceSize, surfaceFactory.release(), opacityMode)); |
| 539 if (surface->isValid()) | 549 if (surface->isValid()) |
| 540 return surface.release(); | 550 return surface.release(); |
| 541 surfaceFactory = createSurfaceFactory(deviceSize, msaaSampleCount); // r
ecreate because old previous one was released | 551 surfaceFactory = createSurfaceFactory(deviceSize, msaaSampleCount); // r
ecreate because old previous one was released |
| 542 } | 552 } |
| 543 | 553 |
| 544 return surfaceFactory->createSurface(deviceSize, opacityMode); | 554 return surfaceFactory->createSurface(deviceSize, opacityMode); |
| 545 } | 555 } |
| 546 | 556 |
| 547 void HTMLCanvasElement::createImageBuffer() | 557 void HTMLCanvasElement::createImageBuffer() |
| (...skipping 22 matching lines...) Expand all Loading... |
| 570 return; | 580 return; |
| 571 | 581 |
| 572 int msaaSampleCount; | 582 int msaaSampleCount; |
| 573 OwnPtr<ImageBufferSurface> surface = createImageBufferSurface(deviceSize, &m
saaSampleCount); | 583 OwnPtr<ImageBufferSurface> surface = createImageBufferSurface(deviceSize, &m
saaSampleCount); |
| 574 if (!surface->isValid()) | 584 if (!surface->isValid()) |
| 575 return; | 585 return; |
| 576 | 586 |
| 577 m_imageBuffer = ImageBuffer::create(surface.release()); | 587 m_imageBuffer = ImageBuffer::create(surface.release()); |
| 578 m_imageBuffer->setClient(this); | 588 m_imageBuffer->setClient(this); |
| 579 | 589 |
| 590 m_imageBuffer->setFilterLevel(computedStyle()->imageRendering() == ImageRend
eringPixelated ? SkPaint::kNone_FilterLevel : SkPaint::kLow_FilterLevel); |
| 591 |
| 580 m_didFailToCreateImageBuffer = false; | 592 m_didFailToCreateImageBuffer = false; |
| 581 | 593 |
| 582 updateExternallyAllocatedMemory(); | 594 updateExternallyAllocatedMemory(); |
| 583 | 595 |
| 584 if (is3D()) { | 596 if (is3D()) { |
| 585 // Early out for WebGL canvases | 597 // Early out for WebGL canvases |
| 586 return; | 598 return; |
| 587 } | 599 } |
| 588 | 600 |
| 589 m_imageBuffer->setClient(this); | 601 m_imageBuffer->setClient(this); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 { | 806 { |
| 795 return !originClean(); | 807 return !originClean(); |
| 796 } | 808 } |
| 797 | 809 |
| 798 FloatSize HTMLCanvasElement::sourceSize() const | 810 FloatSize HTMLCanvasElement::sourceSize() const |
| 799 { | 811 { |
| 800 return FloatSize(width(), height()); | 812 return FloatSize(width(), height()); |
| 801 } | 813 } |
| 802 | 814 |
| 803 } | 815 } |
| OLD | NEW |