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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 : HTMLElement(canvasTag, document) | 79 : HTMLElement(canvasTag, document) |
80 , DocumentVisibilityObserver(document) | 80 , DocumentVisibilityObserver(document) |
81 , m_size(DefaultWidth, DefaultHeight) | 81 , m_size(DefaultWidth, DefaultHeight) |
82 , m_ignoreReset(false) | 82 , m_ignoreReset(false) |
83 , m_accelerationDisabled(false) | 83 , m_accelerationDisabled(false) |
84 , m_externallyAllocatedMemory(0) | 84 , m_externallyAllocatedMemory(0) |
85 , m_originClean(true) | 85 , m_originClean(true) |
86 , m_didFailToCreateImageBuffer(false) | 86 , m_didFailToCreateImageBuffer(false) |
87 , m_didClearImageBuffer(false) | 87 , m_didClearImageBuffer(false) |
88 { | 88 { |
89 setHasCustomStyleCallbacks(); | |
89 } | 90 } |
90 | 91 |
91 DEFINE_NODE_FACTORY(HTMLCanvasElement) | 92 DEFINE_NODE_FACTORY(HTMLCanvasElement) |
92 | 93 |
93 HTMLCanvasElement::~HTMLCanvasElement() | 94 HTMLCanvasElement::~HTMLCanvasElement() |
94 { | 95 { |
95 resetDirtyRect(); | 96 resetDirtyRect(); |
96 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_external lyAllocatedMemory); | 97 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_external lyAllocatedMemory); |
97 #if !ENABLE(OILPAN) | 98 #if !ENABLE(OILPAN) |
98 HashSet<RawPtr<CanvasObserver> >::iterator end = m_observers.end(); | 99 HashSet<RawPtr<CanvasObserver> >::iterator end = m_observers.end(); |
(...skipping 13 matching lines...) Expand all Loading... | |
112 } | 113 } |
113 | 114 |
114 RenderObject* HTMLCanvasElement::createRenderer(RenderStyle* style) | 115 RenderObject* HTMLCanvasElement::createRenderer(RenderStyle* style) |
115 { | 116 { |
116 LocalFrame* frame = document().frame(); | 117 LocalFrame* frame = document().frame(); |
117 if (frame && frame->script().canExecuteScripts(NotAboutToExecuteScript)) | 118 if (frame && frame->script().canExecuteScripts(NotAboutToExecuteScript)) |
118 return new RenderHTMLCanvas(this); | 119 return new RenderHTMLCanvas(this); |
119 return HTMLElement::createRenderer(style); | 120 return HTMLElement::createRenderer(style); |
120 } | 121 } |
121 | 122 |
123 void HTMLCanvasElement::didRecalcStyle(StyleRecalcChange) | |
124 { | |
125 m_imageBuffer->setFilterLevel(computedStyle()->imageRendering() == ImageRend eringPixelated ? SkPaint::kNone_FilterLevel : SkPaint::kLow_FilterLevel); | |
Justin Novosad
2014/09/11 15:42:30
You need to verify hasImageBuffer() here. If the
| |
126 } | |
127 | |
122 Node::InsertionNotificationRequest HTMLCanvasElement::insertedInto(ContainerNode * node) | 128 Node::InsertionNotificationRequest HTMLCanvasElement::insertedInto(ContainerNode * node) |
123 { | 129 { |
124 setIsInCanvasSubtree(true); | 130 setIsInCanvasSubtree(true); |
125 return HTMLElement::insertedInto(node); | 131 return HTMLElement::insertedInto(node); |
126 } | 132 } |
127 | 133 |
128 void HTMLCanvasElement::addObserver(CanvasObserver* observer) | 134 void HTMLCanvasElement::addObserver(CanvasObserver* observer) |
129 { | 135 { |
130 m_observers.add(observer); | 136 m_observers.add(observer); |
131 } | 137 } |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
483 if (RuntimeEnabledFeatures::displayList2dCanvasEnabled()) { | 489 if (RuntimeEnabledFeatures::displayList2dCanvasEnabled()) { |
484 OwnPtr<ImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSu rface(size(), opacityMode)); | 490 OwnPtr<ImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSu rface(size(), opacityMode)); |
485 if (surface->isValid()) | 491 if (surface->isValid()) |
486 return surface.release(); | 492 return surface.release(); |
487 } | 493 } |
488 | 494 |
489 if (shouldAccelerate(deviceSize)) { | 495 if (shouldAccelerate(deviceSize)) { |
490 if (document().settings()) | 496 if (document().settings()) |
491 *msaaSampleCount = document().settings()->accelerated2dCanvasMSAASam pleCount(); | 497 *msaaSampleCount = document().settings()->accelerated2dCanvasMSAASam pleCount(); |
492 OwnPtr<ImageBufferSurface> surface = adoptPtr(new Canvas2DImageBufferSur face(size(), opacityMode, *msaaSampleCount)); | 498 OwnPtr<ImageBufferSurface> surface = adoptPtr(new Canvas2DImageBufferSur face(size(), opacityMode, *msaaSampleCount)); |
499 surface->setFilterLevel(computedStyle()->imageRendering() == ImageRender ingPixelated ? SkPaint::kNone_FilterLevel : SkPaint::kLow_FilterLevel); | |
493 if (surface->isValid()) | 500 if (surface->isValid()) |
494 return surface.release(); | 501 return surface.release(); |
495 } | 502 } |
496 | 503 |
497 return adoptPtr(new UnacceleratedImageBufferSurface(size(), opacityMode)); | 504 return adoptPtr(new UnacceleratedImageBufferSurface(size(), opacityMode)); |
498 } | 505 } |
499 | 506 |
500 void HTMLCanvasElement::createImageBuffer() | 507 void HTMLCanvasElement::createImageBuffer() |
501 { | 508 { |
502 createImageBufferInternal(); | 509 createImageBufferInternal(); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
740 { | 747 { |
741 return !originClean(); | 748 return !originClean(); |
742 } | 749 } |
743 | 750 |
744 FloatSize HTMLCanvasElement::sourceSize() const | 751 FloatSize HTMLCanvasElement::sourceSize() const |
745 { | 752 { |
746 return FloatSize(width(), height()); | 753 return FloatSize(width(), height()); |
747 } | 754 } |
748 | 755 |
749 } | 756 } |
OLD | NEW |