Chromium Code Reviews

Side by Side Diff: core/cross/cairo/image_2d.cc

Issue 2825074: Initial version rendering 2D path for O3D. This will eventually allow O3D app... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/o3d/
Patch Set: '' Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « core/cross/cairo/image_2d.h ('k') | core/cross/cairo/renderer_cairo.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2010, Google Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32
33 #include "core/cross/cairo/image_2d.h"
34 #include "core/cross/error.h"
35 #include "core/cross/renderer.h"
36 #include "core/cross/cairo/renderer_cairo.h"
37 #include "core/cross/cairo/texture_cairo.h"
38
39 namespace o3d {
40
41 O3D_DEFN_CLASS(Image2D, ParamObject);
42
43 Image2D::Image2D(ServiceLocator* service_locator)
44 : ParamObject(service_locator), texture_(NULL),
45 param_cache_manager_(service_locator->GetService<Renderer>()),
46 weak_pointer_manager_(this) {
47 // TODO(fransiskusx): better format
48 src_data_ = NULL;
49 src_pitch_ = 0;
50 src_width_ = 0;
51 src_height_ = 0;
52 dest_x_ = 0;
53 dest_y_ = 0;
54 alpha_ = 0;
55 scale_x_ = 0;
56 scale_y_ = 0;
57 translate_x_ = 0;
58 translate_y_ = 0;
59 }
60
61 void Image2D::updateTextureResource() {
62 TextureResource* resource = texture_->GetResource();
63 src_data_ = resource->data;
64 dest_x_ = resource->left;
65 dest_y_ = resource->top;
66 src_width_ = resource->width;
67 src_height_ = resource->height;
68 src_pitch_ = resource->pitch;
69 }
70
71 ObjectBase::Ref Image2D::Create(ServiceLocator* service_locator) {
72 Renderer* renderer = service_locator->GetService<Renderer>();
73 if (NULL == renderer) {
74 O3D_ERROR(service_locator) << "No Render Device Available";
75 return ObjectBase::Ref();
76 }
77
78 Image2D* image = new Image2D(service_locator);
79
80 RendererCairo* renderer2d = down_cast<RendererCairo*>(renderer);
81 renderer2d->AddImage2D(image);
82
83 return ObjectBase::Ref(image);
84 }
85
86 } // namespace o3d
87
OLDNEW
« no previous file with comments | « core/cross/cairo/image_2d.h ('k') | core/cross/cairo/renderer_cairo.h » ('j') | no next file with comments »

Powered by Google App Engine