OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 17 matching lines...) Expand all Loading... | |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 | 32 |
33 #include "platform/graphics/ImageBufferSurface.h" | 33 #include "platform/graphics/ImageBufferSurface.h" |
34 | 34 |
35 #include "platform/graphics/GraphicsContext.h" | 35 #include "platform/graphics/GraphicsContext.h" |
36 #include "platform/graphics/ImageBuffer.h" | 36 #include "platform/graphics/ImageBuffer.h" |
37 #include "platform/graphics/StaticBitmapImage.h" | 37 #include "platform/graphics/StaticBitmapImage.h" |
38 #include "third_party/skia/include/core/SkBitmap.h" | |
38 #include "third_party/skia/include/core/SkCanvas.h" | 39 #include "third_party/skia/include/core/SkCanvas.h" |
39 #include "third_party/skia/include/core/SkDevice.h" | |
40 #include "third_party/skia/include/core/SkImage.h" | 40 #include "third_party/skia/include/core/SkImage.h" |
41 #include "third_party/skia/include/core/SkPicture.h" | 41 #include "third_party/skia/include/core/SkPicture.h" |
42 | 42 |
43 namespace { | |
44 | |
45 SkBitmap ReadPixels(SkCanvas* canvas) | |
Justin Novosad
2015/11/04 16:29:36
Blink style: 'readPixels'
| |
46 { | |
47 SkBitmap bitmap; | |
48 bitmap.setInfo(canvas->imageInfo()); | |
49 canvas->readPixels(&bitmap, 0, 0); | |
50 return bitmap; | |
51 } | |
52 | |
53 } | |
54 | |
43 namespace blink { | 55 namespace blink { |
44 | 56 |
45 ImageBufferSurface::ImageBufferSurface(const IntSize& size, OpacityMode opacityM ode) | 57 ImageBufferSurface::ImageBufferSurface(const IntSize& size, OpacityMode opacityM ode) |
46 : m_opacityMode(opacityMode) | 58 : m_opacityMode(opacityMode) |
47 , m_size(size) | 59 , m_size(size) |
48 { | 60 { |
49 setIsHidden(false); | 61 setIsHidden(false); |
50 } | 62 } |
51 | 63 |
52 ImageBufferSurface::~ImageBufferSurface() { } | 64 ImageBufferSurface::~ImageBufferSurface() { } |
(...skipping 21 matching lines...) Expand all Loading... | |
74 void ImageBufferSurface::draw(GraphicsContext* context, const FloatRect& destRec t, const FloatRect& srcRect, SkXfermode::Mode op) | 86 void ImageBufferSurface::draw(GraphicsContext* context, const FloatRect& destRec t, const FloatRect& srcRect, SkXfermode::Mode op) |
75 { | 87 { |
76 RefPtr<SkImage> snapshot = newImageSnapshot(PreferNoAcceleration); | 88 RefPtr<SkImage> snapshot = newImageSnapshot(PreferNoAcceleration); |
77 if (!snapshot) | 89 if (!snapshot) |
78 return; | 90 return; |
79 | 91 |
80 RefPtr<Image> image = StaticBitmapImage::create(snapshot.release()); | 92 RefPtr<Image> image = StaticBitmapImage::create(snapshot.release()); |
81 context->drawImage(image.get(), destRect, srcRect, op); | 93 context->drawImage(image.get(), destRect, srcRect, op); |
82 } | 94 } |
83 | 95 |
84 const SkBitmap& ImageBufferSurface::deprecatedBitmapForOverwrite() | 96 const SkBitmap ImageBufferSurface::deprecatedBitmapForOverwrite() |
85 { | 97 { |
86 ASSERT_NOT_REACHED(); // should only be called on non-accelerated surface ty pes, which have overrides | 98 ASSERT_NOT_REACHED(); // should only be called on non-accelerated surface ty pes, which have overrides |
87 return canvas()->getDevice()->accessBitmap(false); // Because we have to ret urn something for the code to compile, and it can't be a local (by address). | 99 return ReadPixels(canvas()); |
f(malita)
2015/11/05 13:53:26
This looks like we're just trying to make the comp
| |
88 } | 100 } |
89 | 101 |
90 | 102 |
91 void ImageBufferSurface::flush() | 103 void ImageBufferSurface::flush() |
92 { | 104 { |
93 canvas()->flush(); | 105 canvas()->flush(); |
94 } | 106 } |
95 | 107 |
96 bool ImageBufferSurface::writePixels(const SkImageInfo& origInfo, const void* pi xels, size_t rowBytes, int x, int y) | 108 bool ImageBufferSurface::writePixels(const SkImageInfo& origInfo, const void* pi xels, size_t rowBytes, int x, int y) |
97 { | 109 { |
98 return canvas()->writePixels(origInfo, pixels, rowBytes, x, y); | 110 return canvas()->writePixels(origInfo, pixels, rowBytes, x, y); |
99 } | 111 } |
100 | 112 |
101 } // namespace blink | 113 } // namespace blink |
OLD | NEW |