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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 CHECK(grContext); | 51 CHECK(grContext); |
52 | 52 |
53 SkAlphaType alphaType = | 53 SkAlphaType alphaType = |
54 (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; | 54 (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
55 SkImageInfo info = | 55 SkImageInfo info = |
56 SkImageInfo::MakeN32(size.width(), size.height(), alphaType); | 56 SkImageInfo::MakeN32(size.width(), size.height(), alphaType); |
57 SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); | 57 SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); |
58 m_surface = SkSurface::MakeRenderTarget( | 58 m_surface = SkSurface::MakeRenderTarget( |
59 grContext, SkBudgeted::kYes, info, 0 /* sampleCount */, | 59 grContext, SkBudgeted::kYes, info, 0 /* sampleCount */, |
60 Opaque == opacityMode ? nullptr : &disableLCDProps); | 60 Opaque == opacityMode ? nullptr : &disableLCDProps); |
61 if (!m_surface.get()) | 61 if (!m_surface) |
62 return; | 62 return; |
63 clear(); | 63 clear(); |
| 64 |
| 65 // Always save an initial frame, to support resetting the top level matrix |
| 66 // and clip. |
| 67 m_surface->getCanvas()->save(); |
64 } | 68 } |
65 | 69 |
66 bool AcceleratedImageBufferSurface::isValid() const { | 70 bool AcceleratedImageBufferSurface::isValid() const { |
67 return m_surface && SharedGpuContext::isValid() && | 71 return m_surface && SharedGpuContext::isValid() && |
68 m_contextId == SharedGpuContext::contextId(); | 72 m_contextId == SharedGpuContext::contextId(); |
69 } | 73 } |
70 | 74 |
71 sk_sp<SkImage> AcceleratedImageBufferSurface::newImageSnapshot(AccelerationHint, | 75 sk_sp<SkImage> AcceleratedImageBufferSurface::newImageSnapshot(AccelerationHint, |
72 SnapshotReason) { | 76 SnapshotReason) { |
73 return m_surface->makeImageSnapshot(); | 77 return m_surface->makeImageSnapshot(); |
74 } | 78 } |
75 | 79 |
76 GLuint AcceleratedImageBufferSurface::getBackingTextureHandleForOverwrite() { | 80 GLuint AcceleratedImageBufferSurface::getBackingTextureHandleForOverwrite() { |
77 if (!m_surface) | 81 if (!m_surface) |
78 return 0; | 82 return 0; |
79 return skia::GrBackendObjectToGrGLTextureInfo( | 83 return skia::GrBackendObjectToGrGLTextureInfo( |
80 m_surface->getTextureHandle( | 84 m_surface->getTextureHandle( |
81 SkSurface::kDiscardWrite_TextureHandleAccess)) | 85 SkSurface::kDiscardWrite_TextureHandleAccess)) |
82 ->fID; | 86 ->fID; |
83 } | 87 } |
84 | 88 |
85 } // namespace blink | 89 } // namespace blink |
OLD | NEW |