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

Side by Side Diff: Source/core/platform/graphics/ImageBuffer.cpp

Issue 22929012: Change Canvas2DLayerBridge to stay alive until last mailbox is returned. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Trivial fix for layout test failure Created 7 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008, Google Inc. All rights reserved. 2 * Copyright (c) 2008, Google Inc. All rights reserved.
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
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 are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "third_party/skia/include/gpu/GrContext.h" 57 #include "third_party/skia/include/gpu/GrContext.h"
58 #include "third_party/skia/include/gpu/SkGpuDevice.h" 58 #include "third_party/skia/include/gpu/SkGpuDevice.h"
59 #include "wtf/MathExtras.h" 59 #include "wtf/MathExtras.h"
60 #include "wtf/text/Base64.h" 60 #include "wtf/text/Base64.h"
61 #include "wtf/text/WTFString.h" 61 #include "wtf/text/WTFString.h"
62 62
63 using namespace std; 63 using namespace std;
64 64
65 namespace WebCore { 65 namespace WebCore {
66 66
67 static SkCanvas* createAcceleratedCanvas(const IntSize& size, OwnPtr<Canvas2DLay erBridge>* outLayerBridge, OpacityMode opacityMode) 67 static SkCanvas* createAcceleratedCanvas(const IntSize& size, Canvas2DLayerBridg ePtr* outLayerBridge, OpacityMode opacityMode)
68 { 68 {
69 RefPtr<GraphicsContext3D> context3D = SharedGraphicsContext3D::get(); 69 RefPtr<GraphicsContext3D> context3D = SharedGraphicsContext3D::get();
70 if (!context3D) 70 if (!context3D)
71 return 0; 71 return 0;
72 Canvas2DLayerBridge::OpacityMode bridgeOpacityMode = opacityMode == Opaque ? Canvas2DLayerBridge::Opaque : Canvas2DLayerBridge::NonOpaque; 72 Canvas2DLayerBridge::OpacityMode bridgeOpacityMode = opacityMode == Opaque ? Canvas2DLayerBridge::Opaque : Canvas2DLayerBridge::NonOpaque;
73 *outLayerBridge = Canvas2DLayerBridge::create(context3D.release(), size, bri dgeOpacityMode); 73 *outLayerBridge = Canvas2DLayerBridge::create(context3D.release(), size, bri dgeOpacityMode);
74 // If canvas buffer allocation failed, debug build will have asserted 74 // If canvas buffer allocation failed, debug build will have asserted
75 // For release builds, we must verify whether the device has a render target 75 // For release builds, we must verify whether the device has a render target
76 return (*outLayerBridge) ? (*outLayerBridge)->getCanvas() : 0; 76 return (*outLayerBridge) ? (*outLayerBridge)->getCanvas() : 0;
77 } 77 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // We're using context acquisition as a signal that someone is about to render into our buffer and we need 170 // We're using context acquisition as a signal that someone is about to render into our buffer and we need
171 // to be ready. This isn't logically const-correct, hence the cast. 171 // to be ready. This isn't logically const-correct, hence the cast.
172 const_cast<Canvas2DLayerBridge*>(m_layerBridge.get())->contextAcquired() ; 172 const_cast<Canvas2DLayerBridge*>(m_layerBridge.get())->contextAcquired() ;
173 } 173 }
174 return m_context.get(); 174 return m_context.get();
175 } 175 }
176 176
177 177
178 bool ImageBuffer::isValid() const 178 bool ImageBuffer::isValid() const
179 { 179 {
180 if (m_layerBridge.get()) 180 if (m_layerBridge)
181 return const_cast<Canvas2DLayerBridge*>(m_layerBridge.get())->isValid(); 181 return const_cast<Canvas2DLayerBridge*>(m_layerBridge.get())->isValid();
182 return true; 182 return true;
183 } 183 }
184 184
185 static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap) 185 static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap)
186 { 186 {
187 SkBitmap tmp; 187 SkBitmap tmp;
188 if (!bitmap.deepCopyTo(&tmp, bitmap.config())) 188 if (!bitmap.deepCopyTo(&tmp, bitmap.config()))
189 bitmap.copyTo(&tmp, bitmap.config()); 189 bitmap.copyTo(&tmp, bitmap.config());
190 190
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) 492 if (!encodeImage(imageData, mimeType, quality, &encodedImage))
493 return "data:,"; 493 return "data:,";
494 494
495 Vector<char> base64Data; 495 Vector<char> base64Data;
496 base64Encode(encodedImage, base64Data); 496 base64Encode(encodedImage, base64Data);
497 497
498 return "data:" + mimeType + ";base64," + base64Data; 498 return "data:" + mimeType + ";base64," + base64Data;
499 } 499 }
500 500
501 } // namespace WebCore 501 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/ImageBuffer.h ('k') | Source/core/platform/graphics/chromium/Canvas2DLayerBridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698